Module: Subtrac

Defined in:
lib/subtrac.rb,
lib/subtrac/svn.rb,
lib/subtrac/trac.rb,
lib/subtrac/apache.rb,
lib/subtrac/client.rb,
lib/subtrac/config.rb,
lib/subtrac/project.rb,
lib/subtrac/version.rb,
lib/subtrac/commands.rb,
lib/subtrac/template.rb,
lib/subtrac/commands/create.rb,
lib/subtrac/commands/install.rb,
lib/subtrac/commands/create_template.rb

Defined Under Namespace

Modules: Commands Classes: Apache, Client, Config, Project, Svn, Template, Trac

Constant Summary collapse

SUBTRAC_ROOT =
"#{File.dirname(__FILE__)}/"
SUBTRAC_ENV =
(ENV['SUBTRAC_ENV'] || 'development').dup
VERSION =
'0.1.40'

Class Method Summary collapse

Class Method Details

.create_project(project, client, template = nil) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/subtrac.rb', line 120

def create_project(project,client,template=nil)

  load_config()

  project = ask("What is the name of the project you would like to create? ") if project.nil?
  client = ask("Which client is this project for? ") if client.nil?
  use_custom_template = agree("Would you like to use a custom template for this project? [y/n]") if template.nil?
  if use_custom_template then
    list_of_templates = Dir.entries(File.join(Config.svn_dir,"templates"))
    
    # The new and improved choose()...
    #choices = %{#{list_of_templates}} # %w{ruby python perl}
    say("\nThis is the new mode (default)...")
    choose do |menu|
      menu.prompt = "Which template would you like to use for this project?  "
      list_of_templates.each do |t|
        unless File.directory?(t)
          menu.choice t do template = t end
        end
      end
    end
  else
    template = "blank"
  end

  # create default project
  project = Project.new(project,client,template)

  # get these out for binding...we'll tidy up later
  #client = project.client
  Config.project = project
  Config.client = project.client

  # create the svn repo
  svn = Svn.new
  svn.create_project(project)

  # create the trac site
  trac = Trac.new
  trac.create_project(project)

  # create the apache configuration
  apache = Apache.new
  apache.create_project(project)

  project.clear_temp()

  # fix privileges
  give_apache_privileges()

end

.install(args, options) ⇒ Object

Install



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/subtrac.rb', line 56

def install(args,options)
  
  load_config()

  puts "\n==== Installing development server files ===="

  if options.defaults then
    overwrite = options.clean
    confirm_default_client = true
  else
    # check where we are installing
    Config.confirm_or_update(:install_dir,"install_dir")
  
    unless !File.directory?(Config.install_dir) 
      # Ask if the user agrees (yes or no)
      confirm_clean = agree("Err, it seems there's some stuff in there. You sure you want me to overwrite? [Y/n]") if options.clean
      overwrite = agree("Doubly sure? I can't undo this....[Y/n]") if confirm_clean
    end

    # confirm server
    Config.confirm_or_update(:server_name,"server_name")

    # ask for hostname
    Config.confirm_or_update(:server_hostname,"server_hostname")

    # default client/project name
    Config.confirm_or_update(:default_client,"default_client")
    Config.confirm_or_update(:default_project,"default_project")

  end

  say("Ok we're about to install now, these are the options you have chosen:
  installation directory: #{Config.install_dir}
  overwrite: #{overwrite}
  server name: #{Config.server_name}
  server hostname: #{Config.server_hostname}
  default client: #{Config.default_client}
  default project: #{Config.default_project}")

  confirm = agree("Is this ok? [y/n]")  

  exit 0 if !confirm

  create_environment_directories(overwrite)

  #create a new virtual host
  apache = Apache.new
  apache.create_virtual_host()

  # create the trac site
  trac = Trac.new
  trac.install_common_files()

  install_common_files()
  configure_admin_user()

  # create default project
  create_project(Config.default_project,Config.default_client,"blank")

  # store any user preferences for later use
  Config.save()

end

.load_configObject

Loads the configuration YML file



51
52
53
# File 'lib/subtrac.rb', line 51

def load_config
  Config.load() if !Config.loaded?
end