Class: CIJoePassenger::Add

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/cijoe_passenger/add.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = [], options = {}, config = {}) ⇒ Add

Returns a new instance of Add.



10
11
12
13
14
15
16
17
# File 'lib/cijoe_passenger/add.rb', line 10

def initialize(args=[], options={}, config={})
  super
  if @repo == ''
    @repo = @name
    @name = @repo.slice(/.*\/(.*).git$/, 1)
  end
  @git = Git.new([name])
end

Instance Attribute Details

#gitObject (readonly)

Returns the value of attribute git.



4
5
6
# File 'lib/cijoe_passenger/add.rb', line 4

def git
  @git
end

Instance Method Details

#add_app_to_rackObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/cijoe_passenger/add.rb', line 23

def add_app_to_rack
  append_file 'config.ru' do
    <<-CONFIG
\n\nmap "/#{name}" do
  work_path = File.join(Dir.pwd, '#{name}')
  module CIJoePassenger
module Apps
  class #{name.capitalize} < Base; end
end
  end
  CIJoePassenger::Apps::#{name.capitalize}.configure do |config|
config.set :project_path, work_path
config.set :show_exceptions, true
config.set :lock, true
  end
  run CIJoePassenger::Apps::#{name.capitalize}
end
    CONFIG
  end
end

#cloneObject



19
20
21
# File 'lib/cijoe_passenger/add.rb', line 19

def clone
  git.clone(repo)
end

#configure_campfireObject



49
50
51
52
53
# File 'lib/cijoe_passenger/add.rb', line 49

def configure_campfire
  campfire.each do |k, v|
    @git.add_config_to_repo("campfire.#{k}", v)
  end
end

#configure_cijoe_runner(runner = nil) ⇒ Object



44
45
46
47
# File 'lib/cijoe_passenger/add.rb', line 44

def configure_cijoe_runner(runner = nil)
  runner ||= ::CIJoePassenger::Config.runner
  git.add_config_to_repo("cijoe.runner", runner)
end

#remindObject



59
60
61
# File 'lib/cijoe_passenger/add.rb', line 59

def remind
  puts "\n\n*** Don't forget to setup #{name}/config/database.yml and/or bundle install ***"
end

#restartObject



55
56
57
# File 'lib/cijoe_passenger/add.rb', line 55

def restart
  run "touch tmp/restart.txt"
end