reservoir 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,9 @@
1
- version: 0.0.1
2
- remote:
3
- user: deployer
4
- server: a4word.com
1
+ version: 0.0.2
2
+ remotes:
3
+ - user: deployer
4
+ server: a4word.com
5
+ - user:
6
+ server:
5
7
  scripts:
6
8
  - name: ruby
7
9
  - name: rvm
@@ -14,8 +14,8 @@ module Reservoir
14
14
  "ERROR: #{error.message}\n\n #{error.backtrace.join('\n ')}"
15
15
  end
16
16
 
17
- def project_message(filename)
18
- "\n===\nLoading Project: #{filename}\n===\n"
17
+ def project_message(project)
18
+ "\n===\nLoading Project: #{project.name} [#{project.file}]\n===\n"
19
19
  end
20
20
 
21
21
  def which_script_message(which_script)
@@ -43,19 +43,19 @@ module Reservoir
43
43
 
44
44
  args.each do |filename|
45
45
  begin
46
- p = Project.new(file: filename)
46
+ all_projects = Project.load_from_file(filename)
47
47
  Application.print project_message(filename)
48
- which_script = p.which_script_template
49
- p.scripts.each do |script|
50
- which_script.go(script)
51
- Application.print which_script_message(which_script)
48
+ all_projects.each do |p|
49
+ which_script = p.which_script_template
50
+ p.scripts.each do |script|
51
+ which_script.go(script)
52
+ Application.print which_script_message(which_script)
53
+ end
52
54
  end
53
55
  rescue
54
56
  Application.print exception_message($!)
55
57
  end
56
58
  end
57
-
58
-
59
59
  Application.print ""
60
60
  end
61
61
 
@@ -6,26 +6,37 @@ module Reservoir
6
6
 
7
7
  def initialize(data = {})
8
8
  @file = data[:file]
9
+ @remote_user = data[:remote_user]
10
+ @remote_server = data[:remote_server]
11
+ @scripts = data[:scripts] || []
12
+ end
13
+
14
+ def self.load_from_file(file)
15
+ options = YAML::load( File.open( file ) )
16
+ default_args = { file: file, scripts: options["scripts"].each.collect { |script| script["name"] } }
9
17
 
10
- if @file.nil?
11
- @scripts = []
12
- return
13
- end
14
-
15
- options = YAML::load( File.open( @file ) )
16
- @scripts = options["scripts"].each.collect { |script| script["name"] }
17
-
18
- unless options["remote"].nil?
19
- @remote_user = options["remote"]["user"]
20
- @remote_server = options["remote"]["server"]
18
+ all_projects = []
19
+ all_servers = options["remotes"]
20
+ if all_servers.nil?
21
+ all_projects << Project.new(default_args)
22
+ else
23
+ all_servers.each do |remote|
24
+ all_projects << Project.new(default_args.merge( remote_user: remote["user"], remote_server: remote["server"]))
25
+ end
21
26
  end
22
-
27
+ all_projects
23
28
  end
24
29
 
25
30
  def which_script_template
26
31
  WhichScript.new(remote_user: @remote_user, remote_server: @remote_server)
27
32
  end
28
33
 
34
+ def name
35
+ return "local" if @remote_server.nil?
36
+ return @remote_server if @remote_user.nil?
37
+ "#{@remote_user}@#{@remote_server}"
38
+ end
39
+
29
40
  end
30
41
 
31
42
  end
@@ -1,6 +1,6 @@
1
1
  module Reservoir
2
2
 
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
 
5
5
  class Version
6
6
 
@@ -65,19 +65,20 @@ module Reservoir
65
65
 
66
66
  it "should handle one file" do
67
67
  @application.should_receive(:welcome_message)
68
- @application.should_receive(:project_message).with(@project_file)
68
+ @application.should_receive(:project_message)
69
69
  @application.should_receive(:which_script_message).exactly(3).times
70
70
  @application.run([@project_file])
71
71
  end
72
72
 
73
73
  it "should handle multiple file" do
74
+ @mock = Caller.new
75
+ @mock.stub!(:go).and_return(true)
76
+ Caller.stub!(:new).and_return(@mock)
74
77
  @application.should_receive(:welcome_message)
75
- @application.should_receive(:project_message).with(@project_file)
76
- @application.should_receive(:project_message).with(@project_file2)
78
+ @application.should_receive(:project_message).exactly(2).times
77
79
  @application.should_receive(:which_script_message).exactly(4).times
78
80
  @application.run([@project_file,@project_file2])
79
81
  end
80
-
81
82
 
82
83
  end
83
84
 
@@ -101,7 +102,7 @@ module Reservoir
101
102
  describe "#messages" do
102
103
 
103
104
  it "should welcome_message" do
104
- @application.welcome_message.should == "reservoir, version 0.0.1\n"
105
+ @application.welcome_message.should == "reservoir, version 0.0.2\n"
105
106
  end
106
107
 
107
108
  it "should usage_message" do
@@ -109,7 +110,8 @@ module Reservoir
109
110
  end
110
111
 
111
112
  it "should project_message" do
112
- @application.project_message("blah.txt").should == "\n===\nLoading Project: blah.txt\n===\n"
113
+ p = Project.new(file: "blah.txt")
114
+ @application.project_message(p).should == "\n===\nLoading Project: local [blah.txt]\n===\n"
113
115
  end
114
116
 
115
117
  it "should exception_message" do
data/spec/project_spec.rb CHANGED
@@ -4,36 +4,61 @@ module Reservoir
4
4
 
5
5
  describe Project do
6
6
 
7
- before (:each) do
8
- @project = Project.new
9
- end
10
-
11
- describe "#scripts" do
7
+
8
+ describe "#name" do
9
+
10
+ it "should be local for non remote projects" do
11
+ Project.new.name.should == "local"
12
+ end
13
+
14
+ it "should be remote_server if no user" do
15
+ Project.new(remote_server: "a4word.com").name.should == "a4word.com"
16
+ end
12
17
 
13
- it "should load from project file" do
14
- @project = Project.new(file: File.dirname(__FILE__) + '/sample_project.yml')
15
- @project.scripts.should == [ "ruby", "rvm", "node"]
18
+ it "should be remote_user@remote_server if info available" do
19
+ Project.new(remote_server: "a4word.com", remote_user: "deployer").name.should == "deployer@a4word.com"
16
20
  end
17
21
 
18
22
  end
19
23
 
20
- describe "#which_script_template" do
24
+ describe "#load_from_file" do
21
25
 
22
- it "should set the remote_user and remote_server" do
23
- @project = Project.new(file: File.dirname(__FILE__) + '/sample_project2.yml')
24
- which_script = @project.which_script_template
25
- which_script.remote_user.should == 'aforward'
26
- which_script.remote_server.should == 'a4word.com'
26
+ describe "#scripts" do
27
+
28
+ it "should load from project file" do
29
+ all = Project.load_from_file(File.dirname(__FILE__) + '/sample_project.yml')
30
+ all.size.should == 1
31
+ project = all.first
32
+ project.scripts.should == [ "ruby", "rvm", "node"]
33
+ end
34
+
27
35
  end
28
36
 
29
- it "should ignore remote data if not set" do
30
- @project = Project.new(file: File.dirname(__FILE__) + '/sample_project.yml')
31
- which_script = @project.which_script_template
32
- which_script.remote_user.should == nil
33
- which_script.remote_server.should == nil
37
+ describe "#which_script_template" do
38
+
39
+ it "should set the remote_user and remote_server" do
40
+ all = Project.load_from_file(File.dirname(__FILE__) + '/sample_project2.yml')
41
+ all.size.should == 1
42
+ project = all.first
43
+
44
+ which_script = project.which_script_template
45
+ which_script.remote_user.should == 'aforward'
46
+ which_script.remote_server.should == 'a4word.com'
47
+ end
48
+
49
+ it "should ignore remote data if not set" do
50
+ all = Project.load_from_file(File.dirname(__FILE__) + '/sample_project.yml')
51
+ all.size.should == 1
52
+ project = all.first
53
+
54
+ which_script = project.which_script_template
55
+ which_script.remote_user.should == nil
56
+ which_script.remote_server.should == nil
57
+ end
58
+
59
+
34
60
  end
35
61
 
36
-
37
62
  end
38
63
 
39
64
  end
@@ -1,4 +1,4 @@
1
- version: 0.0.1
1
+ version: 0.0.2
2
2
  scripts:
3
3
  - name: ruby
4
4
  - name: rvm
@@ -1,6 +1,6 @@
1
- version: 0.0.1
2
- remote:
3
- user: aforward
4
- server: a4word.com
1
+ version: 0.0.2
2
+ remotes:
3
+ - user: aforward
4
+ server: a4word.com
5
5
  scripts:
6
6
  - name: ruby
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reservoir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-08-30 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70102825983140 !ruby/object:Gem::Requirement
16
+ requirement: &70217578438280 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70102825983140
24
+ version_requirements: *70217578438280
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: autotest
27
- requirement: &70102825982720 !ruby/object:Gem::Requirement
27
+ requirement: &70217578437860 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70102825982720
35
+ version_requirements: *70217578437860
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: autotest-fsevent
38
- requirement: &70102825982260 !ruby/object:Gem::Requirement
38
+ requirement: &70217578437400 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70102825982260
46
+ version_requirements: *70217578437400
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rb-fsevent
49
- requirement: &70102825981840 !ruby/object:Gem::Requirement
49
+ requirement: &70217578436980 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70102825981840
57
+ version_requirements: *70217578436980
58
58
  description: Helps manage cloud-based server instances by enumerating, comparing and
59
59
  diff'ing application configurations
60
60
  email: