simonmenke-capricorn 0.2.07 → 0.2.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,14 +5,14 @@ specify do |s|
5
5
  s.homepage = %q{Fix this}
6
6
 
7
7
  s.author = "[AUTHOR]"
8
- s.email = %q{Fix this}
8
+ s.email = "[EMAIL]"
9
9
 
10
10
  s.ignore_files %r{^public/(\d{3}|index)\.html$}
11
11
  s.ignore_files %r{^public/favicon.ico$}
12
12
  s.ignore_files %r{^public/robots.txt$}
13
13
  s.ignore_files %r{^public/images/rails\.png$}
14
14
  s.ignore_files %r{^lib/tasks}
15
- s.ignore_files %r{^config/(boot|database|environment|initializers|locales)}
15
+ s.ignore_files %r{^config/(boot|database|environment|initializers)}
16
16
  s.ignore_files %r{^app/controllers/application_controller.rb}
17
17
  s.ignore_files %r{^app/helpers/application_helper.rb}
18
18
  s.ignore_files %r{^db/schema.rb}
data/lib/capricorn.rb CHANGED
@@ -51,7 +51,7 @@ module Capricorn
51
51
  RELOAD_STATUS = 103
52
52
  QUICK_CERT = "http://segment7.net/projects/ruby/QuickCert/QuickCert-1.0.2.tar.gz"
53
53
 
54
- THOR_VERSION = '>= 0.9.9'
54
+ THOR_VERSION = '= 0.9.9'
55
55
  RUBIGEN_VERSION = '>= 1.5.2'
56
56
 
57
57
  Capricorn::ExceptionHandler.setup
@@ -43,12 +43,30 @@ module Capricorn
43
43
  Dir.chdir(system.satellite_root) do
44
44
  system.as_user(system.web_user, system.web_group) do
45
45
 
46
+ clean_index_html_file
46
47
  write_environment
47
48
  clean_links
48
49
  @dependecies.reverse_each do |spec|
49
50
  link_engine(spec)
50
51
  end
51
52
 
53
+ FileUtils.symlink(
54
+ File.join(system.satellite_root, "public"),
55
+ File.join(system.satellite_root, "public/vendor", satellite.module_name),
56
+ :verbose => true) rescue nil
57
+
58
+ if File.exist? 'public/crossdomain.xml'
59
+ File.unlink 'public/crossdomain.xml'
60
+ end
61
+ File.open('public/crossdomain.xml', 'w+') do |f|
62
+ f.write %{<?xml version="1.0" encoding="UTF-8"?>
63
+ <cross-domain-policy xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.adobe.com/xml/schemas/PolicyFile.xsd">
64
+ <allow-access-from domain="*" />
65
+ <site-control permitted-cross-domain-policies="master-only"/>
66
+ <allow-http-request-headers-from domain="*" headers="*" secure="false"/>
67
+ </cross-domain-policy>}
68
+ end
69
+
52
70
  end
53
71
  run_migrations
54
72
  end
@@ -56,6 +74,13 @@ module Capricorn
56
74
 
57
75
  private
58
76
 
77
+ def clean_index_html_file
78
+ index_html = File.join(system.satellite_root, 'public', 'index.html')
79
+ if File.file?(index_html)
80
+ FileUtils.rm_f(index_html, :verbose => true) rescue nil
81
+ end
82
+ end
83
+
59
84
  def link(src, dst)
60
85
  FileUtils.mkdir_p(File.dirname(dst), :verbose => true)
61
86
  FileUtils.mkdir_p(src, :verbose => true)
@@ -100,6 +125,15 @@ module Capricorn
100
125
  end
101
126
  end
102
127
 
128
+ path = File.join(spec.full_gem_path, 'config/locales')
129
+ if File.directory?(path)
130
+ FileUtils.mkdir_p("config/locales", :verbose => true)
131
+ Dir.glob("#{path}/*.{rb,yml,yaml}").each do |locale_file|
132
+ FileUtils.ln_s(locale_file, "config/locales/#{File.basename(locale_file)}",
133
+ :verbose => true) rescue nil
134
+ end
135
+ end
136
+
103
137
  path = File.join(spec.full_gem_path, 'db', 'migrate')
104
138
  if File.directory?(path)
105
139
  FileUtils.mkdir_p("db/migrate", :verbose => true)
@@ -114,6 +148,9 @@ module Capricorn
114
148
  end
115
149
 
116
150
  def clean_links
151
+ Dir.glob("config/locales/*").each do |path|
152
+ FileUtils.rm_rf(path) if File.symlink?(path)
153
+ end
117
154
  FileUtils.rm_rf("lib/tasks/vendor", :verbose => true)
118
155
  FileUtils.rm_rf("public/vendor", :verbose => true)
119
156
  end
@@ -196,7 +233,12 @@ module Capricorn
196
233
 
197
234
  # update a gem
198
235
  def gem_update(name, options={})
199
- if !(gem_cmd('update', name, options) =~ /Nothing to update/)
236
+ output = if name == :all
237
+ gem_cmd('update', nil, options)
238
+ else
239
+ gem_cmd('update', name, options)
240
+ end
241
+ if !(output =~ /Nothing to update/)
200
242
  gem_refresh
201
243
  true
202
244
  else
@@ -5,27 +5,27 @@ module Capricorn
5
5
 
6
6
  class Engines < Thor
7
7
  desc 'install DOMAIN NAME', 'install an engine'
8
- method_options :version => :required, :lib => :optional, :source => :optional, :token => :optional
8
+ method_options :version => :required, :lib => :optional, :source => :optional, :token => :optional, :immediate => :boolean
9
9
  def install(domain, name)
10
10
  desc = { :version => options[:version] }
11
11
  desc[:lib] = options[:lib] if options[:lib]
12
12
  desc[:source] = options[:source] if options[:source]
13
- Capricorn.client(options[:token]).install_engine(domain, name, desc)
13
+ Capricorn.client(options[:token]).install_engine(domain, name, desc, options[:immediate])
14
14
  end
15
15
 
16
16
  desc 'update DOMAIN NAME', 'update an engine'
17
- method_options :version => :required, :lib => :optional, :source => :optional, :token => :optional
17
+ method_options :version => :required, :lib => :optional, :source => :optional, :token => :optional, :immediate => :boolean
18
18
  def update(domain, name)
19
19
  desc = { :version => options[:version] }
20
20
  desc[:lib] = options[:lib] if options[:lib]
21
21
  desc[:source] = options[:source] if options[:source]
22
- Capricorn.client(options[:token]).update_engine(domain, name, desc)
22
+ Capricorn.client(options[:token]).update_engine(domain, name, desc, options[:immediate])
23
23
  end
24
24
 
25
25
  desc 'uninstall DOMAIN NAME', 'uninstall an engine'
26
- method_options :token => :optional
26
+ method_options :token => :optional, :immediate => :boolean
27
27
  def uninstall(domain, name)
28
- Capricorn.client(options[:token]).uninstall_engine(domain, name)
28
+ Capricorn.client(options[:token]).uninstall_engine(domain, name, options[:immediate])
29
29
  end
30
30
  end
31
31
 
@@ -4,15 +4,28 @@ module Capricorn
4
4
  module Apps # :nodoc:
5
5
 
6
6
  class Satellite < Thor
7
- desc 'list', 'show all managed satellites'
7
+ desc 'list [DOMAIN]', 'show info for managed satellites'
8
8
  method_options :token => :optional
9
- def list
10
- satellites = Capricorn.client(options[:token]).satellites
9
+ def list(domain=nil)
10
+ satellites = Capricorn.client(options[:token]).satellites.dup
11
+
12
+ names_by_index = []
11
13
  satellites.size.times do |i|
12
14
  sat = satellites[i]
13
- puts sat.domain
14
- sat.engines.each do |name, options|
15
- puts "- #{name} #{options.inspect}"
15
+ names_by_index.push([sat.domain, i])
16
+ end
17
+ names_by_index.sort! { |a,b| a.first <=> b.first }
18
+
19
+ names_by_index.each do |(domain_, i)|
20
+ sat = satellites[i]
21
+ if domain.nil? or sat.domain.include?(domain)
22
+ puts [
23
+ sat.domain,
24
+ (sat.development ? ['development:', sat.module_name] : [])
25
+ ].flatten.join(' ')
26
+ sat.engines.each do |name, options|
27
+ puts "- #{name} #{options.inspect}"
28
+ end
16
29
  end
17
30
  end
18
31
  rescue => e
@@ -21,16 +34,34 @@ module Capricorn
21
34
  end
22
35
 
23
36
  desc 'install DOMAIN', 'install a satellite'
24
- method_options :token => :optional
37
+ method_options :token => :optional, :immediate => :boolean
25
38
  def install(domain)
26
- Capricorn.client(options[:token]).install_satellite(domain)
39
+ Capricorn.client(options[:token]).install_satellite(domain, options[:immediate])
27
40
  end
28
41
 
29
42
  desc 'uninstall DOMAIN', 'uninstall a satellite'
30
- method_options :token => :optional
43
+ method_options :token => :optional, :immediate => :boolean
31
44
  def uninstall(domain)
32
- Capricorn.client(options[:token]).uninstall_satellite(domain)
45
+ Capricorn.client(options[:token]).uninstall_satellite(domain, options[:immediate])
33
46
  end
47
+
48
+ desc 'relink DOMAIN', 'relink a satellite'
49
+ method_options :token => :optional, :immediate => :boolean
50
+ def relink(domain)
51
+ Capricorn.client(options[:token]).relink_satellite(domain, options[:immediate])
52
+ end
53
+
54
+ desc 'update DOMAIN', 'update the installed engines of a satellite'
55
+ method_options :token => :optional, :immediate => :boolean
56
+ def update(domain)
57
+ Capricorn.client(options[:token]).update_satellite(domain, options[:immediate])
58
+ end
59
+
60
+ # desc 'upgrade DOMAIN', 'upgrade/rebuild the rails app of a satellite'
61
+ # method_options :token => :optional, :immediate => :boolean
62
+ # def upgrade(domain)
63
+ # Capricorn.client(options[:token]).upgrade_satellite(domain)
64
+ # end
34
65
  end
35
66
 
36
67
  end
@@ -54,6 +54,12 @@ module Capricorn
54
54
  Capricorn.client(options[:token]).update_server
55
55
  end
56
56
 
57
+ desc "gupdate", 'update the gems'
58
+ method_options :token => :optional
59
+ def gupdate
60
+ Capricorn.client(options[:token]).update_gems
61
+ end
62
+
57
63
  desc "version", 'version of the server'
58
64
  method_options :token => :optional
59
65
  def version
@@ -35,6 +35,9 @@ module Capricorn
35
35
  @next_id += 1
36
36
  @jobs[job.id] = job
37
37
  @job_queue.push job.id
38
+ if options[:immediate]
39
+ @immediated_jobs.push(id)
40
+ end
38
41
  return job.id
39
42
  end
40
43
  end
@@ -11,6 +11,7 @@ module Capricorn
11
11
  include Capricorn::Satellite::Persistence
12
12
 
13
13
  attr_reader :domain, :engines
14
+ attr_accessor :development, :module_name
14
15
 
15
16
  def initialize(domain)
16
17
  if Hash === domain
@@ -20,6 +21,7 @@ module Capricorn
20
21
  else
21
22
  @domain = domain
22
23
  @engines = {}
24
+ @development = false
23
25
  end
24
26
  @domain.gsub!(/^www\./, '')
25
27
  end
@@ -12,6 +12,26 @@ module Capricorn
12
12
  end
13
13
  end
14
14
 
15
+ def update_all_engines
16
+ @engines.each do |gem_name,options|
17
+ Capricorn.system.gem_update(gem_name)
18
+
19
+ dep = Gem::Dependency.new(gem_name.to_s, Gem::Requirement.default)
20
+ specs = Gem::SourceIndex.from_installed_gems.search(dep)
21
+
22
+ return false if specs.empty?
23
+
24
+ specs.sort! do |a,b|
25
+ b.version <=> a.version
26
+ end
27
+
28
+ spec_version = specs.first.version.to_s
29
+ options[:version] = spec_version
30
+ end
31
+
32
+ return true
33
+ end
34
+
15
35
  def update_engine(name, options={})
16
36
  if @engines.key? name
17
37
  @engines[name] = options
@@ -48,14 +48,36 @@ module Capricorn
48
48
  end
49
49
  end
50
50
 
51
- def install_satellite(domain)
52
- Capricorn.system.install_satellite(domain)
51
+ def update_gems
52
+ Capricorn.system.gem_update(:all)
53
53
  end
54
54
 
55
- def uninstall_satellite(domain)
55
+ def install_satellite(domain, immediate)
56
+ Capricorn.system.install_satellite(domain, immediate)
57
+ end
58
+
59
+ def relink_satellite(domain, immediate)
60
+ satellite = Capricorn.system.find_satellite(domain)
61
+ if satellite
62
+ Capricorn.system.relink_satellite(satellite, immediate)
63
+ else
64
+ Capricorn.log "Satellite not found (#{domain})"
65
+ end
66
+ end
67
+
68
+ def update_satellite(domain, immediate)
69
+ satellite = Capricorn.system.find_satellite(domain)
70
+ if satellite
71
+ Capricorn.system.update_satellite(satellite, immediate)
72
+ else
73
+ Capricorn.log "Satellite not found (#{domain})"
74
+ end
75
+ end
76
+
77
+ def uninstall_satellite(domain, immediate)
56
78
  satellite = Capricorn.system.find_satellite(domain)
57
79
  if satellite
58
- Capricorn.system.uninstall_satellite(satellite)
80
+ Capricorn.system.uninstall_satellite(satellite, immediate)
59
81
  else
60
82
  Capricorn.log "Satellite not found (#{domain})"
61
83
  end
@@ -70,28 +92,28 @@ module Capricorn
70
92
  end
71
93
  end
72
94
 
73
- def install_engine(domain, name, options={})
95
+ def install_engine(domain, name, options, immediate)
74
96
  satellite = Capricorn.system.find_satellite(domain)
75
97
  if satellite
76
- Capricorn.system.install_engine(satellite, name, options)
98
+ Capricorn.system.install_engine(satellite, name, options, immediate)
77
99
  else
78
100
  Capricorn.log "Satellite not found (#{domain})"
79
101
  end
80
102
  end
81
103
 
82
- def update_engine(domain, name, options={})
104
+ def update_engine(domain, name, options, immediate)
83
105
  satellite = Capricorn.system.find_satellite(domain)
84
106
  if satellite
85
- Capricorn.system.update_engine(satellite, name, options)
107
+ Capricorn.system.update_engine(satellite, name, options, immediate)
86
108
  else
87
109
  Capricorn.log "Satellite not found (#{domain})"
88
110
  end
89
111
  end
90
112
 
91
- def uninstall_engine(domain, name)
113
+ def uninstall_engine(domain, name, immediate)
92
114
  satellite = Capricorn.system.find_satellite(domain)
93
115
  if satellite
94
- Capricorn.system.uninstall_engine(satellite, name)
116
+ Capricorn.system.uninstall_engine(satellite, name, immediate)
95
117
  else
96
118
  Capricorn.log "Satellite not found (#{domain})"
97
119
  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, :make_development_satellite
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, :update_gems, :relink_satellite, :update_satellite
18
18
 
19
19
  class << self
20
20
  undef_method :allow
@@ -67,8 +67,8 @@ module Capricorn
67
67
  File.join(@root, *args)
68
68
  end
69
69
 
70
- def install_satellite(domain)
71
- self.queue.enqueue("install new satellite #{domain}", :domain => domain) do |options|
70
+ def install_satellite(domain, immediate)
71
+ self.queue.enqueue("install new satellite #{domain}", :domain => domain, :immediate => immediate) do |options|
72
72
  satellite = Capricorn::Satellite.new(options[:domain])
73
73
 
74
74
  run_action_on :install_satellite, satellite
@@ -77,9 +77,37 @@ module Capricorn
77
77
  end
78
78
  end
79
79
 
80
- def uninstall_satellite(satellite)
80
+ def relink_satellite(satellite, immediate)
81
+ self.queue.enqueue("relink #{satellite.domain}", :satellite => satellite, :immediate => immediate) do |options|
82
+ satellite = options[:satellite]
83
+
84
+ if satellite
85
+ run_action_on :link_satellite, satellite
86
+ save_satellite! satellite
87
+ end
88
+ end
89
+ end
90
+
91
+ def update_satellite(satellite, immediate)
81
92
  if satellite
82
- self.queue.enqueue("uninstall #{satellite.domain}", :satellite => satellite) do |options|
93
+ self.queue.enqueue("update #{satellite.domain}", :satellite => satellite, :immediate => immediate) do |options|
94
+
95
+ satellite = options[:satellite]
96
+ if satellite.update_all_engines
97
+ run_action_on :update_engine, satellite
98
+ run_action_on :link_satellite, satellite
99
+ save_satellite! satellite
100
+ end
101
+
102
+ end
103
+ else
104
+ false
105
+ end
106
+ end
107
+
108
+ def uninstall_satellite(satellite, immediate)
109
+ if satellite
110
+ self.queue.enqueue("uninstall #{satellite.domain}", :satellite => satellite, :immediate => immediate) do |options|
83
111
  run_action_on :uninstall_satellite, options[:satellite]
84
112
  destroy_satellite! options[:satellite]
85
113
  end
@@ -90,6 +118,8 @@ module Capricorn
90
118
 
91
119
  def make_development_satellite(satellite, name)
92
120
  if satellite
121
+ satellite.module_name = name.to_s
122
+ satellite.development = true
93
123
  Capricorn.runtime_gem('rubigen', Capricorn::RUBIGEN_VERSION)
94
124
  resolve_options_with satellite do
95
125
  as_user(web_user, web_group) do
@@ -98,6 +128,11 @@ module Capricorn
98
128
  FileUtils.rm_r("doc", :verbose => true) rescue nil
99
129
  FileUtils.rm_r("README", :verbose => true) rescue nil
100
130
  FileUtils.rm_r("public/javascripts", :verbose => true) rescue nil
131
+ FileUtils.mkdir_p("public/vendor", :verbose => true) rescue nil
132
+ FileUtils.ln_s(
133
+ File.join(satellite_root, "public"),
134
+ File.join(satellite_root, "public/vendor", satellite.module_name),
135
+ :verbose => true) rescue nil
101
136
 
102
137
  require 'rubigen/scripts/generate'
103
138
  RubiGen::Base.use_application_sources!
@@ -106,15 +141,16 @@ module Capricorn
106
141
  end
107
142
  end
108
143
  end
144
+ save_satellite! satellite
109
145
  else
110
146
  false
111
147
  end
112
148
  end
113
149
 
114
- def install_engine(satellite, name, options={})
150
+ def install_engine(satellite, name, options, immediate)
115
151
  if satellite
116
152
  self.queue.enqueue("install #{satellite.domain}: #{name} #{options.inspect}",
117
- :satellite => satellite, :name => name, :options => options) do |options|
153
+ :satellite => satellite, :name => name, :options => options, :immediate => immediate) do |options|
118
154
 
119
155
  satellite, name, options = options[:satellite], options[:name], options[:options]
120
156
  resolve_options_with(satellite) { ensure_presence_of_gem(name, options) }
@@ -130,10 +166,10 @@ module Capricorn
130
166
  end
131
167
  end
132
168
 
133
- def update_engine(satellite, name, options={})
169
+ def update_engine(satellite, name, options, immediate)
134
170
  if satellite
135
171
  self.queue.enqueue("update #{satellite.domain}: #{name} #{options.inspect}",
136
- :satellite => satellite, :name => name, :options => options) do |options|
172
+ :satellite => satellite, :name => name, :options => options, :immediate => immediate) do |options|
137
173
 
138
174
  satellite, name, options = options[:satellite], options[:name], options[:options]
139
175
  resolve_options_with(satellite) { ensure_presence_of_gem(name, options) }
@@ -149,10 +185,10 @@ module Capricorn
149
185
  end
150
186
  end
151
187
 
152
- def uninstall_engine(satellite, name)
188
+ def uninstall_engine(satellite, name, immediate)
153
189
  if satellite
154
190
  self.queue.enqueue("uninstall #{satellite.domain}: #{name}",
155
- :satellite => satellite, :name => name) do |options|
191
+ :satellite => satellite, :name => name, :immediate => immediate) do |options|
156
192
 
157
193
  satellite, name = options[:satellite], options[:name]
158
194
  if satellite.remove_engine(name)
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.07
4
+ version: 0.2.25
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-18 00:00:00 -07:00
12
+ date: 2009-09-16 00:00:00 -07:00
13
13
  default_executable: capricorn
14
14
  dependencies: []
15
15
 
@@ -77,6 +77,7 @@ files:
77
77
  - app_generators/engine/templates/tasks/engine_tasks.rake
78
78
  has_rdoc: false
79
79
  homepage: http://github.com/simonmenke/capricorn
80
+ licenses:
80
81
  post_install_message:
81
82
  rdoc_options: []
82
83
 
@@ -97,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
98
  requirements: []
98
99
 
99
100
  rubyforge_project:
100
- rubygems_version: 1.2.0
101
+ rubygems_version: 1.3.5
101
102
  signing_key:
102
103
  specification_version: 3
103
104
  summary: Manage satellites