simonmenke-capricorn 0.2.00 → 0.2.03

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,8 +3,8 @@ class EngineGenerator < RubiGen::Base
3
3
 
4
4
  def initialize(runtime_args, runtime_options = {})
5
5
  super
6
- @destination_root = args.shift
7
- @engine_name = File.basename(File.expand_path(@destination_root)).underscore
6
+ @destination_root = File.expand_path('.')
7
+ @engine_name = args.shift.underscore
8
8
  end
9
9
 
10
10
  def manifest
@@ -23,15 +23,16 @@ class EngineGenerator < RubiGen::Base
23
23
  m.directory "rails"
24
24
  m.directory "tasks"
25
25
 
26
- m.template('config/routes.rb', "config/routes.rb")
27
- m.template('Gmfile', "Gmfile")
28
- m.template('rails/init.rb', "rails/init.rb")
29
- m.template('init.rb', "init.rb")
30
- m.template('tasks/engine_tasks.rake', "tasks/#{engine_name}_tasks.rake")
31
- m.template('README.rdoc', "README.rdoc")
32
- m.template('MIT-LICENSE.txt', "MIT-LICENSE.txt")
33
- m.template('lib/engine.rb', "lib/#{engine_name}.rb")
34
- m.template('gitignore', ".gitignore")
26
+ m.template('config/routes.rb', "config/routes.rb")
27
+ m.template('config/initializers/rails_init.rb', "config/initializers/rails_init.rb")
28
+ m.template('Gmfile', "Gmfile")
29
+ m.template('rails/init.rb', "rails/init.rb")
30
+ m.template('init.rb', "init.rb")
31
+ m.template('tasks/engine_tasks.rake', "tasks/#{engine_name}_tasks.rake")
32
+ m.template('README.rdoc', "README.rdoc")
33
+ m.template('MIT-LICENSE.txt', "MIT-LICENSE.txt")
34
+ m.template('lib/engine.rb', "lib/#{engine_name}.rb")
35
+ m.template('gitignore', ".gitignore")
35
36
 
36
37
  end
37
38
  end
@@ -0,0 +1,20 @@
1
+ specify do |s|
2
+ s.name = %q{<%= engine_name %>}
3
+ s.version = "0.0.1"
4
+ s.summary = %q{Fix this}
5
+ s.homepage = %q{Fix this}
6
+
7
+ s.author = "[AUTHOR]"
8
+ s.email = %q{Fix this}
9
+
10
+ s.ignore_files %r{^public/(\d{3}|index)\.html$}
11
+ s.ignore_files %r{^public/favicon.ico$}
12
+ s.ignore_files %r{^public/robots.txt$}
13
+ s.ignore_files %r{^public/images/rails\.png$}
14
+ s.ignore_files %r{^lib/tasks}
15
+ s.ignore_files %r{^config/(boot|database|environment|initializers|locales)}
16
+ s.ignore_files %r{^app/controllers/application_controller.rb}
17
+ s.ignore_files %r{^app/helpers/application_helper.rb}
18
+ s.ignore_files %r{^db/schema.rb}
19
+ s.ignore_files %r{^public/system}
20
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 [AUTHOR]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,7 @@
1
+ = <%= engine_name.humanize %>
2
+
3
+
4
+ == Example
5
+
6
+
7
+ Copyright (c) 2009 [AUTHOR], released under the MIT license
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__)+'/../../init'
@@ -0,0 +1,9 @@
1
+ *.gem
2
+ rdoc
3
+ .DS_Store
4
+ log/*
5
+ tmp/*
6
+ lib/tasks/vendor/*
7
+ public/vendor/*
8
+ db/migrate/*create_lalala_assets*
9
+ db/schema*
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :<%= engine_name %> do
3
+ # # Task goes here
4
+ # end
@@ -71,7 +71,7 @@ module Capricorn
71
71
  gems_header = " # Gems added by engine_manager:\n \n"
72
72
 
73
73
  gsub_file('config/environment.rb') do |content|
74
- content.gsub! /^\s*config.gem.+\n/, ''
74
+ content.gsub!(/^\s*config.gem.+\n/, '')
75
75
  content.gsub! %r{#{Regexp.escape(rails_header)}(#{Regexp.escape(gems_header)})?},
76
76
  "#{rails_header}#{gems_header}"
77
77
 
@@ -105,7 +105,7 @@ module Capricorn
105
105
  FileUtils.mkdir_p("db/migrate", :verbose => true)
106
106
  unlinked_migrations.concat(Dir.glob("#{path}/*.rb"))
107
107
  linked_migrations.each do |migration, target|
108
- if target.starts_with? spec.full_gem_path
108
+ if target[0,spec.full_gem_path.size] == spec.full_gem_path
109
109
  unlinked_migrations.delete(target)
110
110
  unused_migrations.delete(migration)
111
111
  end
@@ -133,7 +133,14 @@ module Capricorn
133
133
  end
134
134
  system.as_user(system.web_user, system.web_group) do
135
135
  unlinked_migrations.each do |migration|
136
- FileUtils.ln_s(migration, "db/migrate/#{File.basename(migration)}", :verbose => true)
136
+
137
+ begin
138
+ FileUtils.ln_s(migration, "db/migrate/#{File.basename(migration)}", :verbose => true)
139
+ rescue
140
+ FileUtils.rm_rf("db/migrate/#{File.basename(migration)}", :verbose => true)
141
+ retry
142
+ end
143
+
137
144
  end
138
145
  end
139
146
 
@@ -171,18 +178,30 @@ module Capricorn
171
178
  # install a gem.
172
179
  def gem_install(name, options={})
173
180
  gem_cmd('install', name, options)
181
+ gem_refresh
182
+ end
183
+
184
+ def gem_refresh
185
+ original_paths = Gem.path
186
+ Gem.refresh
187
+ Gem.send(:set_paths, original_paths.compact.join(File::PATH_SEPARATOR))
174
188
  end
175
189
 
176
190
  # check if a gem is installed
177
191
  def gem_installed(name, options)
178
192
  version = options[:version] || '0.0.0'
179
193
  options = { :version => version, :installed => true }
180
- (gem_cmd('list', name, options).strip == 'true')
194
+ (gem_cmd('list', name, options).strip =~ /true/)
181
195
  end
182
196
 
183
197
  # update a gem
184
198
  def gem_update(name, options={})
185
- !(gem_cmd('update', name, options) =~ /Nothing to update/)
199
+ if !(gem_cmd('update', name, options) =~ /Nothing to update/)
200
+ gem_refresh
201
+ true
202
+ else
203
+ false
204
+ end
186
205
  end
187
206
 
188
207
  # ensure the presence of a gem
@@ -207,9 +226,7 @@ module Capricorn
207
226
  "--#{k}=#{v.inspect}"
208
227
  end
209
228
  end
210
- output = user_run(user, "#{gem_bin_path} #{cmd} #{args.join(' ')}")
211
- Gem.refresh
212
- output
229
+ user_run(user, "#{gem_bin_path} #{cmd} #{args.join(' ')}")
213
230
  end
214
231
 
215
232
  end
@@ -9,11 +9,20 @@ module Capricorn
9
9
  # restart the current satellite.
10
10
  def restart
11
11
  system.as_user(system.web_user, system.web_group) do
12
- tmp_restart = File.join(system.satellite_root, 'tmp', 'restart.txt')
12
+ tmp_restart = system.passenger_restart_txt
13
13
  FileUtils.touch tmp_restart, :verbose => true
14
14
  end
15
15
  end
16
16
 
17
+ module Config
18
+
19
+ # set the passneger restart file.
20
+ def passenger_restart_txt(&block)
21
+ satellite_option(:passenger_restart_txt, block) { |v,s| v || File.join(satellite_root, 'tmp', 'restart.txt') }
22
+ end
23
+
24
+ end
25
+
17
26
  end
18
27
  end
19
28
  end
@@ -47,7 +47,14 @@ module Capricorn
47
47
  FileUtils.chown_R(system.web_user, system.web_group, httpdocs_path)
48
48
 
49
49
  File.open(File.join(system.satellite_root, '../conf/vhost.conf'), 'w+') do |f|
50
- f.puts "DocumentRoot #{httpdocs_path}/public"
50
+ f.write %{DocumentRoot #{httpdocs_path}/public
51
+ <Directory "#{httpdocs_path}/public">
52
+ Options All
53
+ AllowOverride All
54
+ Order allow,deny
55
+ Allow from all
56
+ </Directory>
57
+ }
51
58
  end
52
59
  end
53
60
 
@@ -60,17 +67,30 @@ module Capricorn
60
67
  end
61
68
 
62
69
  def create_database
63
- db_name = satellite.domain.downcase.gsub(/[^a-z]+/, '_')[0,63]
70
+ db_name = database_name_for(satellite)
64
71
  db_user = db_name[0,13]
65
72
  db_pswd = (rand(1_000_000_000) + 10_000).to_s
66
73
 
67
- system.create_database(satellite.basedomain, "#{db_name}_d", "#{db_user}_ud", db_pswd)
68
- system.create_database(satellite.basedomain, "#{db_name}_t", "#{db_user}_ut", db_pswd)
69
- system.create_database(satellite.basedomain, "#{db_name}_p", "#{db_user}_up", db_pswd)
70
-
74
+ create_database_for(satellite, :d, db_name, db_user, db_pswd)
75
+ create_database_for(satellite, :t, db_name, db_user, db_pswd)
76
+ create_database_for(satellite, :p, db_name, db_user, db_pswd)
71
77
 
72
78
  system.as_user(system.web_user, system.web_group) do
73
- config = %{
79
+ db_file = File.join(system.satellite_root, 'config', 'database.yml')
80
+ write_database_config(db_file, db_name, db_user, db_pswd)
81
+ end
82
+ end
83
+
84
+ def drop_databases
85
+ db_name = satellite.domain.downcase.gsub(/[^a-z]+/, '_')[0,63]
86
+
87
+ system.drop_database("#{db_name}_d")
88
+ system.drop_database("#{db_name}_t")
89
+ system.drop_database("#{db_name}_p")
90
+ end
91
+
92
+ def write_database_config(db_file, db_name, db_user, db_pswd)
93
+ File.open(db_file, 'w+') { |f| f.write(%{
74
94
  development:
75
95
  adapter: mysql
76
96
  database: #{db_name}_d
@@ -97,19 +117,17 @@ production:
97
117
  host: localhost
98
118
  encoding: utf8
99
119
  socket: /var/lib/mysql/mysql.sock
100
- }
101
-
102
- db_file = File.join(system.satellite_root, 'config', 'database.yml')
103
- File.open(db_file, 'w+') { |f| f.write config }
104
- end
120
+ }) }
105
121
  end
106
122
 
107
- def drop_databases
108
- db_name = satellite.domain.downcase.gsub(/[^a-z]+/, '_')[0,63]
109
-
110
- system.drop_database("#{db_name}_d")
111
- system.drop_database("#{db_name}_t")
112
- system.drop_database("#{db_name}_p")
123
+ def database_name_for(satellite)
124
+ satellite.domain.downcase.gsub(/[^a-z]+/, '_')[0,63]
125
+ end
126
+
127
+ def create_database_for(satellite, environment, db_name, db_user, db_pswd)
128
+ db_name = "#{db_name}_#{environment}"
129
+ db_user = "#{db_user}_u#{environment}"
130
+ system.create_database(satellite.basedomain, db_name, db_user, db_pswd)
113
131
  end
114
132
 
115
133
  module Helper
@@ -25,7 +25,7 @@ module Capricorn
25
25
  (options[:all] || k.group_name == group) &&
26
26
  Thor::Util.constant_to_thor_path(k.name) =~ search
27
27
  end
28
- display_klasses(false, classes)
28
+ display_klasses(classes)
29
29
  end
30
30
  end
31
31
 
@@ -44,48 +44,37 @@ module Capricorn
44
44
 
45
45
  private
46
46
 
47
- def display_klasses(with_modules = false, klasses = Thor.subclasses)
48
- klasses -= [Thor, Capricorn::AppRunner] unless with_modules
49
- raise Error, "No Thor tasks available" if klasses.empty?
47
+ def display_klasses(klasses = Thor.subclasses)
48
+ klasses -= [Thor, Capricorn::AppRunner]
50
49
 
51
- if with_modules && !thor_yaml.empty?
52
- max_name = thor_yaml.max { |(xk, xv), (yk, yv)| xk.to_s.size <=> yk.to_s.size }.first.size
53
- modules_label = "Modules"
54
- namespaces_label = "Namespaces"
55
- column_width = [max_name + 4, modules_label.size + 1].max
56
-
57
- print "%-#{column_width}s" % modules_label
58
- puts namespaces_label
59
- print "%-#{column_width}s" % ("-" * modules_label.size)
60
- puts "-" * namespaces_label.size
50
+ if klasses.empty?
51
+ puts "\033[1;34mNo Thor tasks available\033[0m"
52
+ else
53
+ maxima = column_maxima_for(klasses)
61
54
 
62
- thor_yaml.each do |name, info|
63
- print "%-#{column_width}s" % name
64
- puts info[:constants].map { |c| Thor::Util.constant_to_thor_path(c) }.join(", ")
65
- end
66
-
67
- puts
55
+ puts # add some spacing
56
+ klasses.each { |k| display_tasks(k, maxima.first, maxima.last) }
68
57
  end
69
-
58
+ end
59
+
60
+ def column_maxima_for(klasses)
70
61
  # Calculate the largest base class name
71
- max_base = klasses.max do |x,y|
62
+ klass_with_longest_name = klasses.max do |x,y|
72
63
  Thor::Util.constant_to_thor_path(x.name).size <=> Thor::Util.constant_to_thor_path(y.name).size
73
- end.name.size
64
+ end
65
+ max_base = klass_with_longest_name.name.size
74
66
 
75
67
  # Calculate the size of the largest option description
76
68
  max_left_item = klasses.max do |x,y|
77
- (x.maxima.usage + x.maxima.opt).to_i <=> (y.maxima.usage + y.maxima.opt).to_i
69
+ total_x = (x.maxima.usage + x.maxima.opt).to_i
70
+ total_y = (y.maxima.usage + y.maxima.opt).to_i
71
+ total_x <=> total_y
78
72
  end
79
73
 
80
74
  max_left = max_left_item.maxima.usage + max_left_item.maxima.opt
81
75
 
82
- unless klasses.empty?
83
- puts # add some spacing
84
- klasses.each { |k| display_tasks(k, max_base, max_left); }
85
- else
86
- puts "\033[1;34mNo Thor tasks available\033[0m"
87
- end
88
- end
76
+ return [max_base, max_left]
77
+ end
89
78
 
90
79
  def display_tasks(klass, max_base, max_left)
91
80
  if klass.tasks.values.length > 1
@@ -4,19 +4,10 @@ module Capricorn
4
4
  module Apps # :nodoc:
5
5
 
6
6
  class Dev < Thor
7
- desc "create NAME", "create a new engine"
8
- def create(name)
7
+ desc "activate DOMAIN NAME", "turn an existing satelite into a development satelite"
8
+ def activate(domain, name)
9
9
  Capricorn.runtime_gem('rubigen', Capricorn::RUBIGEN_VERSION)
10
-
11
- system("rails #{name}")
12
-
13
- FileUtils.rm_r("#{name}/doc", :verbose => true)
14
- FileUtils.rm_r("#{name}/README", :verbose => true)
15
- FileUtils.rm_r("#{name}/public/javascripts", :verbose => true)
16
-
17
- require 'rubigen/scripts/generate'
18
- RubiGen::Base.use_application_sources!
19
- RubiGen::Scripts::Generate.new.run(["-f", name], :generator => 'engine')
10
+ Capricorn.client.make_development_satellite(domain, name)
20
11
  end
21
12
  end
22
13
 
@@ -41,15 +41,10 @@ module Capricorn
41
41
  puts "Pid file #{PidFile.pid_file} already exists. Not starting."
42
42
  exit 1
43
43
  end
44
- Capricorn::Daemon::PidFile.store(Process.pid)
45
- Dir.chdir Capricorn.system.root
46
- File.umask 0000
47
44
 
48
- Capricorn::ExceptionHandler.redirect_std
45
+ setup_child
46
+ regitser_handlers(daemon, &block)
49
47
 
50
- trap("TERM") { daemon.stop; exit }
51
- at_exit { Capricorn::Daemon::PidFile.destroy if $master }
52
- at_exit(&block) if block
53
48
  daemon.start
54
49
  end
55
50
  puts "Daemon started."
@@ -66,6 +61,21 @@ module Capricorn
66
61
  puts "Pid file found, but process was not running. The daemon may have died."
67
62
  end
68
63
 
64
+ private
65
+
66
+ def self.setup_child
67
+ Capricorn::Daemon::PidFile.store(Process.pid)
68
+ Dir.chdir Capricorn.system.root
69
+ File.umask 0000
70
+ Capricorn::ExceptionHandler.redirect_std
71
+ end
72
+
73
+ def self.regitser_handlers(daemon, &block)
74
+ trap("TERM") { daemon.stop; exit }
75
+ at_exit { Capricorn::Daemon::PidFile.destroy if $master }
76
+ at_exit(&block) if block
77
+ end
78
+
69
79
  end
70
80
  end
71
81
  end
@@ -56,6 +56,7 @@ module Capricorn
56
56
  end
57
57
 
58
58
  def log(*args, &block)
59
+ args = [args.inspect] if args.size == 1 and Array === args.first
59
60
  logger.out.info(*args, &block)
60
61
  end
61
62
 
@@ -20,7 +20,7 @@ module Gem # :nodoc:
20
20
  alias_method :to_ruby_without_engines, :to_ruby # :nodoc:
21
21
  def to_ruby # :nodoc:
22
22
  code = to_ruby_without_engines
23
- code.gsub! /s\.engine_dependencies\s+[=]([^\n]+)/, 's.instance_variable_set(:@engine_dependencies,\1)'
23
+ code.gsub!(/s\.engine_dependencies\s+[=]([^\n]+)/, 's.instance_variable_set(:@engine_dependencies,\1)')
24
24
  code
25
25
  end
26
26
  end
@@ -21,7 +21,7 @@ module Thor::Util # :nodoc:
21
21
 
22
22
  def self.constant_to_thor_path(*args) # :nodoc:
23
23
  path = old_constant_to_thor_path(*args)
24
- path.sub! /^#{Thor.namespace}:/, '' if Thor.namespace
24
+ path.sub!(/^#{Thor.namespace}:/, '') if Thor.namespace
25
25
  path
26
26
  end
27
27
 
@@ -16,7 +16,8 @@ module Capricorn
16
16
  @worker = Thread.new(self) do |job_queue|
17
17
  while job_queue.running? or job_queue.peek
18
18
 
19
- if job = job_queue.peek
19
+ job = job_queue.peek
20
+ if job
20
21
  job.run(job_queue)
21
22
  job_queue.delete(job.id)
22
23
  else
@@ -1,6 +1,7 @@
1
1
 
2
2
  module Capricorn
3
3
  class Satellite
4
+ include DRbUndumped
4
5
 
5
6
  autoload :Actions, File.dirname(__FILE__)+'/satellite/actions'
6
7
  autoload :Persistence, File.dirname(__FILE__)+'/satellite/persistence'
@@ -20,7 +21,7 @@ module Capricorn
20
21
  @domain = domain
21
22
  @engines = {}
22
23
  end
23
- @domain.gsub! /^www\./, ''
24
+ @domain.gsub!(/^www\./, '')
24
25
  end
25
26
 
26
27
  def basedomain
@@ -31,55 +31,50 @@ module Capricorn
31
31
  # start the failsafe runner.
32
32
  def start_with_failsafe
33
33
  $master = true
34
- stop_server = false
35
- wait_before_start = 0
36
34
  retries = 0
37
- until stop_server
38
- if wait_before_start > 0
39
- sleep(wait_before_start)
40
- wait_before_start = 0
41
- end
42
-
43
- pid = Process.fork { self.run_server }
35
+ loop do
36
+ pid = self.run_server
44
37
  return unless pid
45
38
  Process.waitpid(pid, 0)
39
+
46
40
  case $?.exitstatus
47
41
  when Capricorn::STOP_STATUS
48
- stop_server = true
49
- retries = 0
42
+ return
50
43
  when Capricorn::RESTART_STATUS
51
- wait_before_start = 2
52
- retries = 0
44
+ retries = 0
53
45
  when Capricorn::RELOAD_STATUS
54
- stop_server = true
55
- retries = 0
56
46
  Capricorn::Daemon::PidFile.destroy
57
47
  Capricorn.system.run %{#{Capricorn::BIN_PATH} #{ORIGINAL_ARGV.join(' ')}}
48
+ return
58
49
  else
59
50
  retries += 1
60
- stop_server = true if retries >= 3
51
+ return if retries >= 3
61
52
  end
53
+
54
+ sleep(2)
62
55
  end
63
56
  end
64
57
 
65
58
  # start the actual DRb server
66
59
  def run_server
67
- $master = false
68
- Dir.chdir(Capricorn.system.root)
69
-
70
- Capricorn.log "Server started"
71
- uri = "druby://#{Capricorn.system.server_hostname}:#{Capricorn.system.server_port}"
72
- DRb.start_service uri, self.proxy, self.options_for_server
73
- Capricorn.log "listening at #{self.construct_uri(uri)}"
74
- make_client_cert_public!
75
-
76
- at_exit do
77
- Capricorn.system.queue.stop!
78
- Capricorn.log "Server stopped"
60
+ Process.fork do
61
+ $master = false
62
+ Dir.chdir(Capricorn.system.root)
63
+
64
+ Capricorn.log "Server started"
65
+ uri = "druby://#{Capricorn.system.server_hostname}:#{Capricorn.system.server_port}"
66
+ DRb.start_service uri, self.proxy, self.options_for_server
67
+ Capricorn.log "listening at #{self.construct_uri(uri)}"
68
+ make_client_cert_public!
69
+
70
+ at_exit do
71
+ Capricorn.system.queue.stop!
72
+ Capricorn.log "Server stopped"
73
+ end
74
+
75
+ DRb.thread.join
76
+ exit($exitstatus || Capricorn::STOP_STATUS)
79
77
  end
80
-
81
- DRb.thread.join
82
- exit($exitstatus || Capricorn::STOP_STATUS)
83
78
  end
84
79
 
85
80
  end
@@ -14,7 +14,7 @@ module Capricorn
14
14
  end
15
15
  end
16
16
 
17
- allow :stop_server, :restart_server, :reload_server, :server_version, :update_server, :install_satellite, :uninstall_satellite, :install_engine, :update_engine, :uninstall_engine, :satellites, :queued_jobs, :cancel_job, :immediate_job
17
+ allow :stop_server, :restart_server, :reload_server, :server_version, :update_server, :install_satellite, :uninstall_satellite, :install_engine, :update_engine, :uninstall_engine, :satellites, :queued_jobs, :cancel_job, :immediate_job, :make_development_satellite
18
18
 
19
19
  class << self
20
20
  undef_method :allow
@@ -36,21 +36,28 @@ module Capricorn
36
36
  FileUtils.mkdir_p('/tmp/quick_cert')
37
37
  File.chmod(0700, '/tmp/quick_cert')
38
38
 
39
- Dir.chdir('/tmp/quick_cert') do
40
- Capricorn.system.run "curl -O #{Capricorn::QUICK_CERT}"
41
- Capricorn.system.run "tar xzf QuickCert-1.0.2.tar.gz"
42
-
43
- Dir.chdir('/tmp/quick_cert/QuickCert-1.0.2') do
44
- Capricorn.system.run "#{Capricorn.system.ruby_path} ./setup.rb config"
45
- Capricorn.system.run "#{Capricorn.system.ruby_path} ./setup.rb setup"
46
- Capricorn.system.run "#{Capricorn.system.ruby_path} ./setup.rb install"
47
- end
48
- end
39
+ download_quick_cert!
40
+ build_quick_cert!
49
41
 
50
42
  FileUtils.rm_rf('/tmp/quick_cert')
51
43
  end
52
44
  end
53
45
 
46
+ def download_quick_cert!
47
+ Dir.chdir('/tmp/quick_cert') do
48
+ Capricorn.system.run "curl -O #{Capricorn::QUICK_CERT}"
49
+ Capricorn.system.run "tar xzf QuickCert-1.0.2.tar.gz"
50
+ end
51
+ end
52
+
53
+ def build_quick_cert!
54
+ Dir.chdir('/tmp/quick_cert/QuickCert-1.0.2') do
55
+ Capricorn.system.run "#{Capricorn.system.ruby_path} ./setup.rb config"
56
+ Capricorn.system.run "#{Capricorn.system.ruby_path} ./setup.rb setup"
57
+ Capricorn.system.run "#{Capricorn.system.ruby_path} ./setup.rb install"
58
+ end
59
+ end
60
+
54
61
  def dump_quick_cert_config!
55
62
  return if File.file? Capricorn.system.path('quick_cert', 'qc_config')
56
63
 
@@ -61,6 +61,15 @@ module Capricorn
61
61
  end
62
62
  end
63
63
 
64
+ def make_development_satellite(domain, name)
65
+ satellite = Capricorn.system.find_satellite(domain)
66
+ if satellite
67
+ Capricorn.system.make_development_satellite(satellite, name)
68
+ else
69
+ Capricorn.log "Satellite not found (#{domain})"
70
+ end
71
+ end
72
+
64
73
  def install_engine(domain, name, options={})
65
74
  satellite = Capricorn.system.find_satellite(domain)
66
75
  if satellite
@@ -88,13 +88,36 @@ module Capricorn
88
88
  end
89
89
  end
90
90
 
91
+ def make_development_satellite(satellite, name)
92
+ if satellite
93
+ Capricorn.runtime_gem('rubigen', Capricorn::RUBIGEN_VERSION)
94
+ resolve_options_with satellite do
95
+ as_user(web_user, web_group) do
96
+ Dir.chdir(satellite_root) do
97
+
98
+ FileUtils.rm_r("doc", :verbose => true) rescue nil
99
+ FileUtils.rm_r("README", :verbose => true) rescue nil
100
+ FileUtils.rm_r("public/javascripts", :verbose => true) rescue nil
101
+
102
+ require 'rubigen/scripts/generate'
103
+ RubiGen::Base.use_application_sources!
104
+ RubiGen::Scripts::Generate.new.run(["-f", name], :generator => 'engine')
105
+
106
+ end
107
+ end
108
+ end
109
+ else
110
+ false
111
+ end
112
+ end
113
+
91
114
  def install_engine(satellite, name, options={})
92
115
  if satellite
93
116
  self.queue.enqueue("install #{satellite.domain}: #{name} #{options.inspect}",
94
117
  :satellite => satellite, :name => name, :options => options) do |options|
95
118
 
96
119
  satellite, name, options = options[:satellite], options[:name], options[:options]
97
- ensure_presence_of_gem(name, options)
120
+ resolve_options_with(satellite) { ensure_presence_of_gem(name, options) }
98
121
  if satellite.add_engine(name, options)
99
122
  run_action_on :install_engine, satellite
100
123
  run_action_on :link_satellite, satellite
@@ -113,7 +136,7 @@ module Capricorn
113
136
  :satellite => satellite, :name => name, :options => options) do |options|
114
137
 
115
138
  satellite, name, options = options[:satellite], options[:name], options[:options]
116
- ensure_presence_of_gem(name, options)
139
+ resolve_options_with(satellite) { ensure_presence_of_gem(name, options) }
117
140
  if satellite.update_engine(name, options)
118
141
  run_action_on :update_engine, satellite
119
142
  run_action_on :link_satellite, satellite
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simonmenke-capricorn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.00
4
+ version: 0.2.03
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Menke
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-03 00:00:00 -07:00
12
+ date: 2009-06-16 00:00:00 -07:00
13
13
  default_executable: capricorn
14
14
  dependencies: []
15
15
 
@@ -64,10 +64,16 @@ files:
64
64
  - lib/capricorn.rb
65
65
  - lib/rubygems_plugin.rb
66
66
  - app_generators/engine/engine_generator.rb
67
+ - app_generators/engine/templates/config/initializers/rails_init.rb
67
68
  - app_generators/engine/templates/config/routes.rb
69
+ - app_generators/engine/templates/gitignore
70
+ - app_generators/engine/templates/Gmfile
68
71
  - app_generators/engine/templates/init.rb
69
72
  - app_generators/engine/templates/lib/engine.rb
73
+ - app_generators/engine/templates/MIT-LICENSE.txt
70
74
  - app_generators/engine/templates/rails/init.rb
75
+ - app_generators/engine/templates/README.rdoc
76
+ - app_generators/engine/templates/tasks/engine_tasks.rake
71
77
  has_rdoc: false
72
78
  homepage: http://github.com/simonmenke/capricorn
73
79
  post_install_message: