capricorn 0.2.25 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/README.md +1 -0
- data/bin/capricorn-app-scaffolder +27 -0
- data/bin/capricorn-gem-spec +33 -0
- data/bin/capricornctl +12 -0
- data/bin/capricornd +31 -0
- data/erlang/lib/bert/doc/overview.edoc +4 -0
- data/erlang/lib/bert/ebin/bert.app +9 -0
- data/erlang/lib/bert/rebar.config +3 -0
- data/erlang/lib/bert/src/bert.erl +69 -0
- data/erlang/lib/bertio/doc/overview.edoc +4 -0
- data/erlang/lib/bertio/ebin/bertio.app +9 -0
- data/erlang/lib/bertio/rebar.config +3 -0
- data/erlang/lib/bertio/src/bertio.erl +28 -0
- data/erlang/lib/bertrpc/doc/overview.edoc +4 -0
- data/erlang/lib/bertrpc/ebin/bertrpc.app +12 -0
- data/erlang/lib/bertrpc/include/bertrpc.hrl +1 -0
- data/erlang/lib/bertrpc/rebar.config +5 -0
- data/erlang/lib/bertrpc/src/bertrpc.erl +471 -0
- data/erlang/lib/bertrpc/src/bertrpc_hello_world.erl +148 -0
- data/erlang/lib/bertrpc/src/fd_tcp.erl +376 -0
- data/erlang/lib/capricorn/doc/overview.edoc +4 -0
- data/erlang/lib/capricorn/ebin/capricorn.app +56 -0
- data/erlang/lib/capricorn/include/capricorn.hrl +76 -0
- data/erlang/lib/capricorn/rebar.config +3 -0
- data/erlang/lib/capricorn/src/cap_application.erl +170 -0
- data/erlang/lib/capricorn/src/cap_cluster.erl +121 -0
- data/erlang/lib/capricorn/src/cap_cluster_gems.erl +422 -0
- data/erlang/lib/capricorn/src/cap_config.erl +25 -0
- data/erlang/lib/capricorn/src/cap_dets_updater.erl +26 -0
- data/erlang/lib/capricorn/src/cap_event_sup.erl +35 -0
- data/erlang/lib/capricorn/src/cap_events.erl +24 -0
- data/erlang/lib/capricorn/src/cap_external_api.erl +87 -0
- data/erlang/lib/capricorn/src/cap_external_apps_api.erl +125 -0
- data/erlang/lib/capricorn/src/cap_external_gems_api.erl +85 -0
- data/erlang/lib/capricorn/src/cap_external_machines_api.erl +18 -0
- data/erlang/lib/capricorn/src/cap_gem_utils.erl +111 -0
- data/erlang/lib/capricorn/src/cap_internal_api.erl +69 -0
- data/erlang/lib/capricorn/src/cap_internal_apps_api.erl +38 -0
- data/erlang/lib/capricorn/src/cap_log.erl +113 -0
- data/erlang/lib/capricorn/src/cap_machine.erl +338 -0
- data/erlang/lib/capricorn/src/cap_machine_apps.erl +410 -0
- data/erlang/lib/capricorn/src/cap_machine_apps_sup.erl +57 -0
- data/erlang/lib/capricorn/src/cap_sup.erl +200 -0
- data/erlang/lib/capricorn/src/cap_util.erl +278 -0
- data/erlang/lib/capricorn/src/capricorn.erl +45 -0
- data/erlang/lib/capricorn/src/capricorn_app.erl +36 -0
- data/erlang/lib/emq/ebin/emq.app +17 -0
- data/erlang/lib/emq/src/emq.erl +261 -0
- data/erlang/lib/emq/src/emq_app.erl +11 -0
- data/erlang/lib/emq/src/emq_pool.erl +178 -0
- data/erlang/lib/emq/src/emq_queue.erl +332 -0
- data/erlang/lib/emq/src/emq_status.erl +148 -0
- data/erlang/lib/emq/src/emq_sup.erl +132 -0
- data/erlang/lib/gcd/ebin/gcd.app +18 -0
- data/erlang/lib/gcd/include/gcd.hrl +5 -0
- data/erlang/lib/gcd/rebar.config +3 -0
- data/erlang/lib/gcd/src/gcd.erl +51 -0
- data/erlang/lib/gcd/src/gcd_app.erl +13 -0
- data/erlang/lib/gcd/src/gcd_event.erl +39 -0
- data/erlang/lib/gcd/src/gcd_server.erl +30 -0
- data/erlang/lib/gcd/src/gcd_srv.erl +186 -0
- data/erlang/lib/gcd/src/gcd_sup.erl +18 -0
- data/erlang/rebar +0 -0
- data/erlang/rebar.config +9 -0
- data/erlang/rel/overlay/bin/capricornd +146 -0
- data/erlang/rel/overlay/erts-vsn/bin/erl +34 -0
- data/erlang/rel/overlay/erts-vsn/bin/nodetool +80 -0
- data/erlang/rel/overlay/etc/capricorn/app.config +59 -0
- data/erlang/rel/overlay/etc/capricorn/cluster-vm.args +21 -0
- data/erlang/rel/overlay/etc/capricorn/machine-vm.args +21 -0
- data/erlang/rel/reltool.config +43 -0
- data/ext/Makefile +2 -0
- data/ext/extconf.rb +1 -0
- data/lib/capricorn-client.rb +86 -0
- data/lib/capricorn-client/cli/applications.rb +256 -0
- data/lib/capricorn-client/cli/gems.rb +57 -0
- data/lib/capricorn-client/cli/machines.rb +9 -0
- data/lib/capricorn-client/helpers.rb +62 -0
- data/lib/capricorn.rb +5 -99
- data/lib/capricorn/driver.rb +86 -0
- data/lib/capricorn/recipes/apache-debian.rb +112 -0
- data/lib/capricorn/recipes/centos-plesk.rb +162 -0
- data/lib/capricorn/recipes/macports.rb +54 -0
- data/lib/capricorn/system_context.rb +49 -0
- data/lib/capricorn/version.rb +5 -0
- metadata +233 -74
- data/app_generators/engine/engine_generator.rb +0 -40
- data/app_generators/engine/templates/Gmfile +0 -20
- data/app_generators/engine/templates/MIT-LICENSE.txt +0 -20
- data/app_generators/engine/templates/README.rdoc +0 -7
- data/app_generators/engine/templates/config/initializers/rails_init.rb +0 -1
- data/app_generators/engine/templates/config/routes.rb +0 -2
- data/app_generators/engine/templates/gitignore +0 -9
- data/app_generators/engine/templates/init.rb +0 -1
- data/app_generators/engine/templates/lib/engine.rb +0 -4
- data/app_generators/engine/templates/rails/init.rb +0 -1
- data/app_generators/engine/templates/tasks/engine_tasks.rake +0 -4
- data/bin/capricorn +0 -20
- data/lib/capricorn/actor.rb +0 -23
- data/lib/capricorn/actor/actions.rb +0 -76
- data/lib/capricorn/actors/apache_actor.rb +0 -56
- data/lib/capricorn/actors/base_actor.rb +0 -335
- data/lib/capricorn/actors/host_file_actor.rb +0 -77
- data/lib/capricorn/actors/mysql_actor.rb +0 -20
- data/lib/capricorn/actors/passenger_actor.rb +0 -28
- data/lib/capricorn/actors/plesk_actor.rb +0 -228
- data/lib/capricorn/actors/sqlite3_actor.rb +0 -44
- data/lib/capricorn/app_runner.rb +0 -108
- data/lib/capricorn/apps/dev.rb +0 -15
- data/lib/capricorn/apps/engines.rb +0 -33
- data/lib/capricorn/apps/jobs.rb +0 -35
- data/lib/capricorn/apps/satellite.rb +0 -68
- data/lib/capricorn/apps/server.rb +0 -73
- data/lib/capricorn/client.rb +0 -48
- data/lib/capricorn/client/auth_token.rb +0 -98
- data/lib/capricorn/daemon.rb +0 -81
- data/lib/capricorn/exception_handler.rb +0 -79
- data/lib/capricorn/extentions/rubygems_plugin.rb +0 -27
- data/lib/capricorn/extentions/thor_extentions.rb +0 -32
- data/lib/capricorn/job_queue.rb +0 -203
- data/lib/capricorn/satellite.rb +0 -52
- data/lib/capricorn/satellite/actions.rb +0 -55
- data/lib/capricorn/satellite/dependency_loader.rb +0 -82
- data/lib/capricorn/satellite/persistence.rb +0 -50
- data/lib/capricorn/server.rb +0 -144
- data/lib/capricorn/server/daemon.rb +0 -83
- data/lib/capricorn/server/proxy.rb +0 -25
- data/lib/capricorn/server/security.rb +0 -120
- data/lib/capricorn/system.rb +0 -218
- data/lib/capricorn/system/config.rb +0 -49
- data/lib/capricorn/system/helper.rb +0 -21
- data/lib/capricorn/system/options.rb +0 -79
- data/lib/capricorn/system/process_user.rb +0 -73
- data/lib/capricorn/system/satellites.rb +0 -44
- data/lib/capricorn/system/shell.rb +0 -80
- data/lib/rubygems_plugin.rb +0 -1
- data/spec/actor/actions_spec.rb +0 -13
- data/spec/spec_helper.rb +0 -1
@@ -1,79 +0,0 @@
|
|
1
|
-
|
2
|
-
module Capricorn
|
3
|
-
module ExceptionHandler
|
4
|
-
|
5
|
-
def self.setup(out=STDOUT, err=STDERR)
|
6
|
-
if String === out
|
7
|
-
@out = Logger.new(out, 'daily')
|
8
|
-
@stdout = @out.instance_variable_get('@logdev').instance_variable_get('@dev')
|
9
|
-
else
|
10
|
-
@out = Logger.new(out)
|
11
|
-
@stdout = out
|
12
|
-
end
|
13
|
-
|
14
|
-
if String === err
|
15
|
-
@err = Logger.new(err, 'daily')
|
16
|
-
@stderr = @err.instance_variable_get('@logdev').instance_variable_get('@dev')
|
17
|
-
else
|
18
|
-
@err = Logger.new(err)
|
19
|
-
@stderr = err
|
20
|
-
end
|
21
|
-
|
22
|
-
@out.level = Logger::DEBUG
|
23
|
-
@err.level = Logger::DEBUG
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.err
|
27
|
-
@err
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.out
|
31
|
-
@out
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.stderr
|
35
|
-
@stderr
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.stdout
|
39
|
-
@stdout
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.redirect_std
|
43
|
-
if STDOUT != self.stdout
|
44
|
-
STDOUT.reopen self.stdout
|
45
|
-
end
|
46
|
-
|
47
|
-
if STDERR != self.stderr
|
48
|
-
STDERR.reopen self.stderr
|
49
|
-
end
|
50
|
-
|
51
|
-
STDIN.reopen "/dev/null"
|
52
|
-
end
|
53
|
-
|
54
|
-
def logger
|
55
|
-
Capricorn::ExceptionHandler
|
56
|
-
end
|
57
|
-
|
58
|
-
def log(*args, &block)
|
59
|
-
args = [args.inspect] if args.size == 1 and Array === args.first
|
60
|
-
logger.out.info(*args, &block)
|
61
|
-
end
|
62
|
-
|
63
|
-
def report
|
64
|
-
yield
|
65
|
-
rescue Exception => e
|
66
|
-
if StandardError === e
|
67
|
-
logger.err.error(e)
|
68
|
-
else
|
69
|
-
logger.err.fatal(e)
|
70
|
-
end
|
71
|
-
raise e
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def FileUtils.fu_output_message(msg)
|
78
|
-
Capricorn::ExceptionHandler.out.info(msg)
|
79
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'rubygems/specification'
|
2
|
-
|
3
|
-
module Gem # :nodoc:
|
4
|
-
class Specification
|
5
|
-
attribute :engine_dependencies, {}
|
6
|
-
|
7
|
-
def add_engine_dependency(name, options={})
|
8
|
-
name = name.to_s
|
9
|
-
add_runtime_dependency(name, *[options[:version]].compact)
|
10
|
-
@engine_dependencies ||= {}
|
11
|
-
@engine_dependencies[name] = options
|
12
|
-
end
|
13
|
-
|
14
|
-
alias_method :ruby_code_without_engines, :ruby_code # :nodoc:
|
15
|
-
def ruby_code(obj) # :nodoc:
|
16
|
-
return obj.inspect if Hash === obj
|
17
|
-
return ruby_code_without_engines(obj)
|
18
|
-
end
|
19
|
-
|
20
|
-
alias_method :to_ruby_without_engines, :to_ruby # :nodoc:
|
21
|
-
def to_ruby # :nodoc:
|
22
|
-
code = to_ruby_without_engines
|
23
|
-
code.gsub!(/s\.engine_dependencies\s+[=]([^\n]+)/, 's.instance_variable_set(:@engine_dependencies,\1)')
|
24
|
-
code
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
Capricorn.runtime_gem('thor', Capricorn::THOR_VERSION)
|
2
|
-
|
3
|
-
class Thor
|
4
|
-
class << self
|
5
|
-
attr_accessor :real_namespace # :nodoc:
|
6
|
-
end
|
7
|
-
def self.namespace=(value)
|
8
|
-
Thor.real_namespace = value
|
9
|
-
end
|
10
|
-
def self.namespace
|
11
|
-
Thor.real_namespace
|
12
|
-
end
|
13
|
-
self.namespace = nil
|
14
|
-
end
|
15
|
-
|
16
|
-
module Thor::Util # :nodoc:
|
17
|
-
class << self
|
18
|
-
alias_method :old_constant_to_thor_path, :constant_to_thor_path
|
19
|
-
alias_method :old_constant_from_thor_path, :constant_from_thor_path
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.constant_to_thor_path(*args) # :nodoc:
|
23
|
-
path = old_constant_to_thor_path(*args)
|
24
|
-
path.sub!(/^#{Thor.namespace}:/, '') if Thor.namespace
|
25
|
-
path
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.constant_from_thor_path(path) # :nodoc:
|
29
|
-
path = "#{Thor.namespace}:"+path if Thor.namespace
|
30
|
-
old_constant_from_thor_path(path)
|
31
|
-
end
|
32
|
-
end
|
data/lib/capricorn/job_queue.rb
DELETED
@@ -1,203 +0,0 @@
|
|
1
|
-
require 'thread'
|
2
|
-
|
3
|
-
module Capricorn
|
4
|
-
class JobQueue
|
5
|
-
include DRbUndumped
|
6
|
-
|
7
|
-
# create a new job queue
|
8
|
-
def initialize
|
9
|
-
@immediated_jobs = Array.new
|
10
|
-
@canceled_jobs = Array.new
|
11
|
-
@job_queue = Array.new
|
12
|
-
@jobs = Hash.new
|
13
|
-
@mutex = Mutex.new
|
14
|
-
@next_id = 1
|
15
|
-
|
16
|
-
@worker = Thread.new(self) do |job_queue|
|
17
|
-
while job_queue.running? or job_queue.peek
|
18
|
-
|
19
|
-
job = job_queue.peek
|
20
|
-
if job
|
21
|
-
job.run(job_queue)
|
22
|
-
job_queue.delete(job.id)
|
23
|
-
else
|
24
|
-
sleep(1)
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# enqueue a new job with the given +name+, +options+ and +proc+
|
32
|
-
def enqueue(name, options={}, &proc)
|
33
|
-
@mutex.synchronize do
|
34
|
-
job = Job.new(@next_id, name, options, &proc)
|
35
|
-
@next_id += 1
|
36
|
-
@jobs[job.id] = job
|
37
|
-
@job_queue.push job.id
|
38
|
-
if options[:immediate]
|
39
|
-
@immediated_jobs.push(id)
|
40
|
-
end
|
41
|
-
return job.id
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# dequeue the next job of the queue.
|
46
|
-
def dequeue
|
47
|
-
@mutex.synchronize do
|
48
|
-
id = @job_queue.shift
|
49
|
-
return @jobs.delete(id) if id
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# delete the job associated with the given +id+.
|
54
|
-
def delete(id)
|
55
|
-
@mutex.synchronize do
|
56
|
-
id = @job_queue.delete(id)
|
57
|
-
return @jobs.delete(id) if id
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
# peek at the next job in the queue
|
62
|
-
def peek
|
63
|
-
job = nil
|
64
|
-
@mutex.synchronize do
|
65
|
-
id = @job_queue.first
|
66
|
-
job = @jobs[id] if id
|
67
|
-
end
|
68
|
-
job
|
69
|
-
end
|
70
|
-
|
71
|
-
# get the size of the job queue
|
72
|
-
def size
|
73
|
-
@mutex.synchronize do
|
74
|
-
@job_queue.size
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
# cancel the job associated with the given +id+.
|
79
|
-
def cancel(id)
|
80
|
-
@mutex.synchronize do
|
81
|
-
id = @job_queue.delete(id)
|
82
|
-
if id
|
83
|
-
@jobs.delete(id)
|
84
|
-
@canceled_jobs.push(id)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
# is the job associated with the given +id+ canceled.
|
90
|
-
def canceled?(id)
|
91
|
-
@mutex.synchronize do
|
92
|
-
return !@canceled_jobs.delete(id).nil?
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
# run the job associated with the given +id+ immediately.
|
97
|
-
def immediate(id)
|
98
|
-
@mutex.synchronize do
|
99
|
-
@immediated_jobs.push(id) if @jobs[id]
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
# should the job associated with the given +id+ be run immediately.
|
104
|
-
def immediated?(id)
|
105
|
-
@mutex.synchronize do
|
106
|
-
return !@immediated_jobs.delete(id).nil?
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
# join the worker thread
|
111
|
-
def join!
|
112
|
-
@worker.join
|
113
|
-
end
|
114
|
-
|
115
|
-
# wait until the queue is empty then stop the worker
|
116
|
-
def stop!
|
117
|
-
@mutex.synchronize do
|
118
|
-
@stopped = true
|
119
|
-
end
|
120
|
-
join!
|
121
|
-
end
|
122
|
-
|
123
|
-
# is the queue stopping or stopped?
|
124
|
-
def stopped?
|
125
|
-
@mutex.synchronize do
|
126
|
-
return !!@stopped
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
# is the queue running
|
131
|
-
def running?
|
132
|
-
!stopped?
|
133
|
-
end
|
134
|
-
|
135
|
-
# iterate through all the jobs on the queue
|
136
|
-
def each
|
137
|
-
@mutex.synchronize do
|
138
|
-
@job_queue.each do |id|
|
139
|
-
job = @jobs[id]
|
140
|
-
canceled = @canceled_jobs.include?(id)
|
141
|
-
immediated = @immediated_jobs.include?(id)
|
142
|
-
|
143
|
-
yield(job, canceled, immediated)
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
class Job
|
149
|
-
include DRbUndumped
|
150
|
-
|
151
|
-
attr_accessor :id, :name, :options, :proc
|
152
|
-
|
153
|
-
def initialize(id, name, options={}, &proc)
|
154
|
-
@id = id.to_i
|
155
|
-
@mutex = Mutex.new
|
156
|
-
@name, @options, @proc = name, options, proc
|
157
|
-
@run_at = Time.now + (options.delete(:delay) || 30)
|
158
|
-
end
|
159
|
-
|
160
|
-
def delay
|
161
|
-
@mutex.synchronize do
|
162
|
-
delay = @run_at - Time.now
|
163
|
-
delay = 0 if delay < 0
|
164
|
-
return delay
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
def running?
|
169
|
-
@mutex.synchronize do
|
170
|
-
return @running
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
def waiting?
|
175
|
-
@mutex.synchronize do
|
176
|
-
return @waiting
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
def run(job_queue)
|
181
|
-
Capricorn.report do
|
182
|
-
@waiting = true
|
183
|
-
immediated = canceled = false
|
184
|
-
Capricorn.log "waiting #{@run_at - Time.now}s."
|
185
|
-
until immediated or canceled or @run_at <= Time.now
|
186
|
-
sleep(1)
|
187
|
-
canceled = job_queue.canceled?(self.id)
|
188
|
-
immediated = job_queue.immediated?(self.id)
|
189
|
-
end
|
190
|
-
|
191
|
-
unless canceled
|
192
|
-
@waiting = false
|
193
|
-
@running = true
|
194
|
-
Capricorn.log("[queue]> #{@name}")
|
195
|
-
@proc.call(@options)
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
end
|
201
|
-
|
202
|
-
end
|
203
|
-
end
|
data/lib/capricorn/satellite.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
|
2
|
-
module Capricorn
|
3
|
-
class Satellite
|
4
|
-
include DRbUndumped
|
5
|
-
|
6
|
-
autoload :Actions, File.dirname(__FILE__)+'/satellite/actions'
|
7
|
-
autoload :Persistence, File.dirname(__FILE__)+'/satellite/persistence'
|
8
|
-
autoload :DependencyLoader, File.dirname(__FILE__)+'/satellite/dependency_loader'
|
9
|
-
|
10
|
-
include Capricorn::Satellite::Actions
|
11
|
-
include Capricorn::Satellite::Persistence
|
12
|
-
|
13
|
-
attr_reader :domain, :engines
|
14
|
-
attr_accessor :development, :module_name
|
15
|
-
|
16
|
-
def initialize(domain)
|
17
|
-
if Hash === domain
|
18
|
-
domain.each do |name, value|
|
19
|
-
instance_variable_set("@#{name}".to_sym, value)
|
20
|
-
end
|
21
|
-
else
|
22
|
-
@domain = domain
|
23
|
-
@engines = {}
|
24
|
-
@development = false
|
25
|
-
end
|
26
|
-
@domain.gsub!(/^www\./, '')
|
27
|
-
end
|
28
|
-
|
29
|
-
def basedomain
|
30
|
-
unless @basedomain
|
31
|
-
parts = self.domain.split('.')
|
32
|
-
parts = parts[-2..-1]
|
33
|
-
@basedomain = parts.join('.')
|
34
|
-
end
|
35
|
-
@basedomain
|
36
|
-
end
|
37
|
-
|
38
|
-
def subdomain
|
39
|
-
unless @subdomain
|
40
|
-
parts = self.domain.split('.')
|
41
|
-
parts = parts[0..-3]
|
42
|
-
@subdomain = parts.join('.')
|
43
|
-
end
|
44
|
-
@subdomain unless @subdomain == ''
|
45
|
-
end
|
46
|
-
|
47
|
-
def subdomain?
|
48
|
-
!self.subdomain.nil?
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
|
2
|
-
module Capricorn
|
3
|
-
class Satellite
|
4
|
-
module Actions
|
5
|
-
|
6
|
-
def add_engine(name, options={})
|
7
|
-
unless @engines.key? name
|
8
|
-
@engines[name] = options
|
9
|
-
true
|
10
|
-
else
|
11
|
-
false
|
12
|
-
end
|
13
|
-
end
|
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
|
-
|
35
|
-
def update_engine(name, options={})
|
36
|
-
if @engines.key? name
|
37
|
-
@engines[name] = options
|
38
|
-
true
|
39
|
-
else
|
40
|
-
false
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def remove_engine(name)
|
45
|
-
if @engines.key? name
|
46
|
-
@engines.delete(name)
|
47
|
-
true
|
48
|
-
else
|
49
|
-
false
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|