orchestra 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +11 -1
- data/examples/hello_world.rb +16 -7
- data/lib/orchestra.rb +2 -0
- data/lib/orchestra/command.rb +2 -2
- data/lib/orchestra/configuration.rb +3 -24
- data/lib/orchestra/partition.rb +51 -0
- data/lib/orchestra/version.rb +1 -1
- data/spec/lib/orchestra/cli_spec.rb +42 -0
- metadata +9 -5
data/.gitignore
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
orchestra (0.0.
|
4
|
+
orchestra (0.0.2)
|
5
5
|
mixlib-cli
|
6
6
|
|
7
7
|
GEM
|
@@ -15,8 +15,17 @@ GEM
|
|
15
15
|
debugger-linecache (1.1.2)
|
16
16
|
debugger-ruby_core_source (>= 1.1.1)
|
17
17
|
debugger-ruby_core_source (1.1.3)
|
18
|
+
diff-lcs (1.1.3)
|
18
19
|
mixlib-cli (1.2.2)
|
19
20
|
rake (0.9.2.2)
|
21
|
+
rspec (2.11.0)
|
22
|
+
rspec-core (~> 2.11.0)
|
23
|
+
rspec-expectations (~> 2.11.0)
|
24
|
+
rspec-mocks (~> 2.11.0)
|
25
|
+
rspec-core (2.11.1)
|
26
|
+
rspec-expectations (2.11.3)
|
27
|
+
diff-lcs (~> 1.1.3)
|
28
|
+
rspec-mocks (2.11.3)
|
20
29
|
|
21
30
|
PLATFORMS
|
22
31
|
ruby
|
@@ -25,3 +34,4 @@ DEPENDENCIES
|
|
25
34
|
debugger
|
26
35
|
orchestra!
|
27
36
|
rake
|
37
|
+
rspec
|
data/examples/hello_world.rb
CHANGED
@@ -1,20 +1,29 @@
|
|
1
1
|
set :hosts, ["web1", "web2"]
|
2
|
+
set :user, 'deploy'
|
2
3
|
|
3
4
|
task :helloworld do
|
4
5
|
puts "helloworld"
|
5
6
|
# run('echo hello world!')
|
6
7
|
end
|
7
8
|
|
8
|
-
task :
|
9
|
-
puts "
|
10
|
-
#
|
9
|
+
task :updatecode do
|
10
|
+
puts "git pull"
|
11
|
+
# run('git pull')
|
12
|
+
# with(:settings => {:user => 'web'}) do
|
13
|
+
# cd('folder')
|
14
|
+
# lcd('local_folder')
|
15
|
+
# with(settings: {warnonly: true, user: "deploy"}, cd: "$RAILS_ROOT") do
|
16
|
+
# helloworld
|
17
|
+
# run('mv file.text file.back')
|
18
|
+
# end
|
19
|
+
# end
|
11
20
|
end
|
12
21
|
|
13
22
|
task :all do
|
14
23
|
helloworld
|
15
|
-
|
24
|
+
updatecode
|
16
25
|
end
|
17
26
|
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
27
|
+
# $> orchestra task
|
28
|
+
# $> orchestra -P task
|
29
|
+
# $> orchestra task helloworld -H web1,web2
|
data/lib/orchestra.rb
CHANGED
data/lib/orchestra/command.rb
CHANGED
@@ -7,34 +7,13 @@ module Orchestra
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def play_partition!
|
10
|
-
|
11
|
-
|
12
|
-
run_tasks
|
13
|
-
end
|
14
|
-
|
15
|
-
def run_tasks
|
16
|
-
config[:tasks].each do |task_name|
|
17
|
-
@tasks[task_name.to_sym].call if @tasks[task_name.to_sym]
|
18
|
-
end
|
10
|
+
partition.play
|
19
11
|
end
|
20
12
|
|
21
13
|
private
|
22
14
|
|
23
|
-
def
|
24
|
-
@
|
25
|
-
@variables[variable_name] = value
|
26
|
-
end
|
27
|
-
|
28
|
-
def task(task_name, &block)
|
29
|
-
@tasks ||= {}
|
30
|
-
@tasks[task_name.to_sym] = block
|
31
|
-
end
|
32
|
-
|
33
|
-
def load_partition!
|
34
|
-
return if @loaded
|
35
|
-
|
36
|
-
instance_eval(File.read(config[:partition]))
|
37
|
-
@loaded = true
|
15
|
+
def partition
|
16
|
+
@partition ||= Partition.new(config)
|
38
17
|
end
|
39
18
|
end
|
40
19
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Orchestra
|
2
|
+
class Partition
|
3
|
+
include Command
|
4
|
+
|
5
|
+
attr_reader :config
|
6
|
+
|
7
|
+
def initialize(config)
|
8
|
+
@config = config.dup
|
9
|
+
load
|
10
|
+
add_tasks
|
11
|
+
end
|
12
|
+
|
13
|
+
def play
|
14
|
+
config[:tasks].each do |task_name|
|
15
|
+
send(task_name)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_tasks
|
20
|
+
singleton = class << self; self end
|
21
|
+
@tasks.each do |method_name, method|
|
22
|
+
singleton.send :define_method, method_name, method
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def run
|
27
|
+
Net::SSH.start(host, user, :password => "password") do |ssh|
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def set(variable_name, value)
|
35
|
+
@variables ||= {}
|
36
|
+
@variables[variable_name] = value
|
37
|
+
end
|
38
|
+
|
39
|
+
def task(task_name, &block)
|
40
|
+
@tasks ||= {}
|
41
|
+
@tasks[task_name.to_sym] = block
|
42
|
+
end
|
43
|
+
|
44
|
+
def load
|
45
|
+
return if @loaded
|
46
|
+
|
47
|
+
instance_eval(File.read(config[:partition]))
|
48
|
+
@loaded = true
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/orchestra/version.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'orchestra'
|
2
|
+
require 'orchestra/cli'
|
3
|
+
|
4
|
+
describe Orchestra::CLI do
|
5
|
+
subject { Orchestra::CLI.new }
|
6
|
+
|
7
|
+
describe "#execute" do
|
8
|
+
it "calls parse_options" do
|
9
|
+
subject.stub(:play_partition!)
|
10
|
+
subject.should_receive(:parse_options)
|
11
|
+
|
12
|
+
subject.execute
|
13
|
+
end
|
14
|
+
|
15
|
+
it "calls play_partition!" do
|
16
|
+
subject.stub(:parse_options)
|
17
|
+
subject.should_receive(:play_partition!)
|
18
|
+
|
19
|
+
subject.execute
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#set_tasks" do
|
24
|
+
it "adds tasks" do
|
25
|
+
subject.send(:set_tasks, ['method1', 'method2', 'method3'])
|
26
|
+
subject.config[:tasks].should == ['method1', 'method2', 'method3']
|
27
|
+
end
|
28
|
+
|
29
|
+
it "adds on the config" do
|
30
|
+
subject.config[:tasks] = ['previous_method']
|
31
|
+
subject.send(:set_tasks, ['method1'])
|
32
|
+
|
33
|
+
subject.config[:tasks].should == ['previous_method', 'method1']
|
34
|
+
end
|
35
|
+
|
36
|
+
it "uses the ARGV by default" do
|
37
|
+
ARGV << 'method'
|
38
|
+
subject.send(:set_tasks)
|
39
|
+
subject.config[:tasks].should == ['method']
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orchestra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-11-
|
13
|
+
date: 2012-11-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mixlib-cli
|
@@ -37,6 +37,7 @@ executables:
|
|
37
37
|
extensions: []
|
38
38
|
extra_rdoc_files: []
|
39
39
|
files:
|
40
|
+
- .gitignore
|
40
41
|
- Gemfile
|
41
42
|
- Gemfile.lock
|
42
43
|
- LICENSE.txt
|
@@ -48,8 +49,10 @@ files:
|
|
48
49
|
- lib/orchestra/cli.rb
|
49
50
|
- lib/orchestra/command.rb
|
50
51
|
- lib/orchestra/configuration.rb
|
52
|
+
- lib/orchestra/partition.rb
|
51
53
|
- lib/orchestra/version.rb
|
52
54
|
- orchestra.gemspec
|
55
|
+
- spec/lib/orchestra/cli_spec.rb
|
53
56
|
homepage: ''
|
54
57
|
licenses: []
|
55
58
|
post_install_message:
|
@@ -64,7 +67,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
67
|
version: '0'
|
65
68
|
segments:
|
66
69
|
- 0
|
67
|
-
hash:
|
70
|
+
hash: 3651560134261131973
|
68
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
72
|
none: false
|
70
73
|
requirements:
|
@@ -73,11 +76,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
76
|
version: '0'
|
74
77
|
segments:
|
75
78
|
- 0
|
76
|
-
hash:
|
79
|
+
hash: 3651560134261131973
|
77
80
|
requirements: []
|
78
81
|
rubyforge_project:
|
79
82
|
rubygems_version: 1.8.24
|
80
83
|
signing_key:
|
81
84
|
specification_version: 3
|
82
85
|
summary: Lightning fast deployment.
|
83
|
-
test_files:
|
86
|
+
test_files:
|
87
|
+
- spec/lib/orchestra/cli_spec.rb
|