reservoir 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/README +11 -0
- data/Rakefile +1 -0
- data/autotest/discover.rb +2 -0
- data/bin/reservoir +10 -0
- data/examples/rails_server.yml +8 -0
- data/lib/reservoir/application.rb +84 -0
- data/lib/reservoir/caller.rb +49 -0
- data/lib/reservoir/project.rb +31 -0
- data/lib/reservoir/version.rb +34 -0
- data/lib/reservoir/which_script.rb +46 -0
- data/lib/reservoir.rb +7 -0
- data/reservoir.gemspec +28 -0
- data/spec/application_spec.rb +143 -0
- data/spec/caller_spec.rb +121 -0
- data/spec/project_spec.rb +41 -0
- data/spec/sample_project.yml +6 -0
- data/spec/sample_project2.yml +6 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/version_spec.rb +55 -0
- data/spec/which_script_spec.rb +65 -0
- metadata +121 -0
data/Gemfile
ADDED
data/README
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
A simple application assets in your public and private cloud.
|
2
|
+
|
3
|
+
== Usage ==
|
4
|
+
|
5
|
+
USAGE: reservoir <project_file1> <project_file2> ...
|
6
|
+
or reservoir help to see this message
|
7
|
+
or reservoir version to see the version
|
8
|
+
|
9
|
+
== Learn More ==
|
10
|
+
|
11
|
+
Contact Andrew Forward at aforward@gmail.com for more details and project direction
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/reservoir
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
module Reservoir
|
2
|
+
|
3
|
+
class Application
|
4
|
+
|
5
|
+
def welcome_message
|
6
|
+
"reservoir, version #{Reservoir::VERSION}\n"
|
7
|
+
end
|
8
|
+
|
9
|
+
def usage_message
|
10
|
+
"USAGE: reservoir <project_file1> <project_file2> ...\n or reservoir help to see this message\n"
|
11
|
+
end
|
12
|
+
|
13
|
+
def exception_message(error)
|
14
|
+
"ERROR: #{error.message}\n\n #{error.backtrace.join('\n ')}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def project_message(filename)
|
18
|
+
"\n===\nLoading Project: #{filename}\n===\n"
|
19
|
+
end
|
20
|
+
|
21
|
+
def which_script_message(which_script)
|
22
|
+
which_script.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def run(args)
|
27
|
+
|
28
|
+
if args.nil? || args.empty?
|
29
|
+
Application.print usage_message
|
30
|
+
return
|
31
|
+
end
|
32
|
+
|
33
|
+
Application.print welcome_message
|
34
|
+
|
35
|
+
if ["--version","-version","-v","--v","version"].include?(args[0])
|
36
|
+
return
|
37
|
+
end
|
38
|
+
|
39
|
+
if ["--help","-help","-h","--h","help"].include?(args[0])
|
40
|
+
Application.print usage_message
|
41
|
+
return
|
42
|
+
end
|
43
|
+
|
44
|
+
args.each do |filename|
|
45
|
+
begin
|
46
|
+
p = Project.new(file: filename)
|
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)
|
52
|
+
end
|
53
|
+
rescue
|
54
|
+
Application.print exception_message($!)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
Application.print ""
|
60
|
+
end
|
61
|
+
|
62
|
+
# Provide the ability to direct the stdio with a print_mode switch
|
63
|
+
@@print_mode = :stdio
|
64
|
+
def self.print_mode=(val)
|
65
|
+
@@print_mode = val
|
66
|
+
end
|
67
|
+
def self.print_mode
|
68
|
+
@@print_mode
|
69
|
+
end
|
70
|
+
def self.reset_print_mode
|
71
|
+
@@print_mode = :stdio
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.print(output)
|
75
|
+
if @@print_mode == :stdio
|
76
|
+
STDOUT.puts output
|
77
|
+
else
|
78
|
+
output
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Reservoir
|
2
|
+
|
3
|
+
class Caller
|
4
|
+
|
5
|
+
attr_accessor :remote_user, :remote_server, :command, :response
|
6
|
+
|
7
|
+
def initialize(data = {})
|
8
|
+
@remote_user = data[:remote_user]
|
9
|
+
@remote_server = data[:remote_server]
|
10
|
+
@command = data[:command]
|
11
|
+
@success = false
|
12
|
+
end
|
13
|
+
|
14
|
+
def success?
|
15
|
+
@success
|
16
|
+
end
|
17
|
+
|
18
|
+
def go(command = nil)
|
19
|
+
begin
|
20
|
+
@command = command unless command.nil?
|
21
|
+
@response = `#{full_command}`
|
22
|
+
@success = true
|
23
|
+
rescue
|
24
|
+
@response = "#{$!}"
|
25
|
+
@success = false
|
26
|
+
end
|
27
|
+
@success
|
28
|
+
end
|
29
|
+
|
30
|
+
def go_with_response(command = nil)
|
31
|
+
go(command)
|
32
|
+
@response
|
33
|
+
end
|
34
|
+
|
35
|
+
def ssh
|
36
|
+
return nil if @remote_server.nil?
|
37
|
+
return "ssh #{@remote_server}" if @remote_user.nil?
|
38
|
+
"ssh #{@remote_user}@#{@remote_server}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def full_command
|
42
|
+
return nil if @command.nil?
|
43
|
+
return @command if @remote_server.nil?
|
44
|
+
"#{ssh} '#{@command}'"
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Reservoir
|
2
|
+
|
3
|
+
class Project
|
4
|
+
|
5
|
+
attr_accessor :scripts, :file, :remote_user, :remote_server
|
6
|
+
|
7
|
+
def initialize(data = {})
|
8
|
+
@file = data[:file]
|
9
|
+
|
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"]
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def which_script_template
|
26
|
+
WhichScript.new(remote_user: @remote_user, remote_server: @remote_server)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Reservoir
|
2
|
+
|
3
|
+
VERSION = "0.0.1"
|
4
|
+
|
5
|
+
class Version
|
6
|
+
|
7
|
+
attr_accessor :version_info, :version, :version_parts
|
8
|
+
|
9
|
+
def read(version_info)
|
10
|
+
@version_info = version_info
|
11
|
+
|
12
|
+
major_minor_revision_match = /(\d*)\.(\d*)\.(\d*)/
|
13
|
+
mmr_patchlevel_match = /(\d*)\.(\d*)\.(\d*).*(patchlevel)\s*(\d*)/
|
14
|
+
|
15
|
+
|
16
|
+
m = version_info.match(mmr_patchlevel_match)
|
17
|
+
unless m.nil?
|
18
|
+
@version_parts = [ m[1], m[2], m[3], m[5] ]
|
19
|
+
@version = @version_parts[0..2].join(".") + "-p" + m[5]
|
20
|
+
return
|
21
|
+
end
|
22
|
+
|
23
|
+
m = version_info.match(major_minor_revision_match)
|
24
|
+
unless m.nil?
|
25
|
+
@version_parts = [ m[1], m[2], m[3] ]
|
26
|
+
@version = @version_parts.join(".")
|
27
|
+
return
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Reservoir
|
2
|
+
|
3
|
+
class WhichScript
|
4
|
+
|
5
|
+
attr_accessor :script, :path, :response
|
6
|
+
|
7
|
+
def initialize(data = {})
|
8
|
+
@caller = Caller.new(:remote_server => data[:remote_server], :remote_user => data[:remote_user])
|
9
|
+
@success = false
|
10
|
+
end
|
11
|
+
|
12
|
+
def remote_user
|
13
|
+
@caller.remote_user
|
14
|
+
end
|
15
|
+
|
16
|
+
def remote_server
|
17
|
+
@caller.remote_server
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
return "WhichScript called before any #go(script) was performed" if @script.nil?
|
22
|
+
"#{@script} : #{@response}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def go(app_name)
|
26
|
+
@script = app_name
|
27
|
+
@path = @caller.go_with_response("which #{app_name}")
|
28
|
+
|
29
|
+
if @path == ''
|
30
|
+
@path = nil
|
31
|
+
@success = false
|
32
|
+
@response = 'script not installed'
|
33
|
+
else
|
34
|
+
@success = true
|
35
|
+
@response = @path
|
36
|
+
end
|
37
|
+
@success
|
38
|
+
end
|
39
|
+
|
40
|
+
def success?
|
41
|
+
@success
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
data/lib/reservoir.rb
ADDED
data/reservoir.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "reservoir/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "reservoir"
|
7
|
+
s.version = Reservoir::VERSION
|
8
|
+
s.authors = ["Andrew Forward"]
|
9
|
+
s.email = ["aforward@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{What apps, versions and configurations to you have setup on your server}
|
12
|
+
s.description = %q{Helps manage cloud-based server instances by enumerating, comparing and diff'ing application configurations}
|
13
|
+
|
14
|
+
s.rubyforge_project = "reservoir"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.default_executable = 'bin/reservoir'
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_development_dependency('rspec')
|
23
|
+
s.add_development_dependency('autotest')
|
24
|
+
s.add_development_dependency('autotest-fsevent') if RUBY_PLATFORM =~ /darwin/i
|
25
|
+
s.add_development_dependency('rb-fsevent') if RUBY_PLATFORM =~ /darwin/i
|
26
|
+
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Reservoir
|
4
|
+
|
5
|
+
describe Application do
|
6
|
+
|
7
|
+
before (:each) do
|
8
|
+
@project_file = File.dirname(__FILE__) + '/sample_project.yml'
|
9
|
+
@project_file2 = File.dirname(__FILE__) + '/sample_project2.yml'
|
10
|
+
@application = Application.new
|
11
|
+
Application.print_mode = :string
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#run" do
|
15
|
+
|
16
|
+
describe "no args" do
|
17
|
+
|
18
|
+
it "should handle nil args" do
|
19
|
+
@application.should_receive(:usage_message)
|
20
|
+
@application.run(nil)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should handle empty args" do
|
24
|
+
@application.should_receive(:usage_message)
|
25
|
+
@application.run([])
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "help" do
|
31
|
+
|
32
|
+
["--help","-help","-h","--h","help"].each do |help_name|
|
33
|
+
it "should support --help" do
|
34
|
+
@application.should_receive(:welcome_message)
|
35
|
+
@application.should_receive(:usage_message)
|
36
|
+
@application.run([help_name])
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "version" do
|
43
|
+
|
44
|
+
["--version","-version","-v","--v","version"].each do |help_name|
|
45
|
+
it "should support --help" do
|
46
|
+
@application.should_receive(:welcome_message)
|
47
|
+
@application.should_not_receive(:exception_message)
|
48
|
+
@application.run([help_name])
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "invalid project file" do
|
55
|
+
|
56
|
+
it "should fail gracefully" do
|
57
|
+
@application.should_receive(:welcome_message)
|
58
|
+
@application.should_receive(:exception_message)
|
59
|
+
@application.run(["blah.yml"])
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "valid project files" do
|
65
|
+
|
66
|
+
it "should handle one file" do
|
67
|
+
@application.should_receive(:welcome_message)
|
68
|
+
@application.should_receive(:project_message).with(@project_file)
|
69
|
+
@application.should_receive(:which_script_message).exactly(3).times
|
70
|
+
@application.run([@project_file])
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should handle multiple file" do
|
74
|
+
@application.should_receive(:welcome_message)
|
75
|
+
@application.should_receive(:project_message).with(@project_file)
|
76
|
+
@application.should_receive(:project_message).with(@project_file2)
|
77
|
+
@application.should_receive(:which_script_message).exactly(4).times
|
78
|
+
@application.run([@project_file,@project_file2])
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#print_mode" do
|
87
|
+
|
88
|
+
it "should be settable" do
|
89
|
+
Application.print_mode = :a
|
90
|
+
Application.print_mode.should == :a
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should be resetable" do
|
94
|
+
Application.print_mode = :a
|
95
|
+
Application.reset_print_mode
|
96
|
+
Application.print_mode.should == :stdio
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "#messages" do
|
102
|
+
|
103
|
+
it "should welcome_message" do
|
104
|
+
@application.welcome_message.should == "reservoir, version 0.0.1\n"
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should usage_message" do
|
108
|
+
@application.usage_message.should == "USAGE: reservoir <project_file1> <project_file2> ...\n or reservoir help to see this message\n"
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should project_message" do
|
112
|
+
@application.project_message("blah.txt").should == "\n===\nLoading Project: blah.txt\n===\n"
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should exception_message" do
|
116
|
+
begin
|
117
|
+
File.open("garble.txt")
|
118
|
+
rescue
|
119
|
+
@application.exception_message($!).split("\n")[0].should == "ERROR: No such file or directory - garble.txt"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
describe "#print" do
|
127
|
+
|
128
|
+
it "should return a string if print_mode :string" do
|
129
|
+
Application.print_mode = :string
|
130
|
+
Application.print("x").should == "x"
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should write to output if print_mode :stdio" do
|
134
|
+
STDOUT.should_receive(:puts).with("x")
|
135
|
+
Application.print_mode = :stdio
|
136
|
+
Application.print("x")
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
data/spec/caller_spec.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Reservoir
|
4
|
+
|
5
|
+
describe Caller do
|
6
|
+
|
7
|
+
before (:each) do
|
8
|
+
@caller = Caller.new
|
9
|
+
end
|
10
|
+
|
11
|
+
before(:all) do
|
12
|
+
File.open("findme.txt", 'w') {|f| f.write("test123") }
|
13
|
+
end
|
14
|
+
|
15
|
+
after(:all) do
|
16
|
+
File.delete("findme.txt")
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#initialize" do
|
20
|
+
|
21
|
+
it "should set command, remote_server, remote_user" do
|
22
|
+
caller = Caller.new(:command => "a", :remote_server => "b", :remote_user => "c")
|
23
|
+
caller.command.should == "a"
|
24
|
+
caller.remote_server.should == "b"
|
25
|
+
caller.remote_user.should == "c"
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#go" do
|
31
|
+
|
32
|
+
it "should capture command as string" do
|
33
|
+
@caller.command = "cat findme.txt"
|
34
|
+
@caller.go.should == true
|
35
|
+
@caller.success?.should == true
|
36
|
+
@caller.response.should == "test123"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should allow command as parameter" do
|
40
|
+
@caller.command = "cat blah.txt"
|
41
|
+
@caller.go("cat findme.txt").should == true
|
42
|
+
@caller.success?.should == true
|
43
|
+
@caller.response.should == "test123"
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
it "should report errors" do
|
48
|
+
@caller.command = "garbligook"
|
49
|
+
@caller.go.should == false
|
50
|
+
@caller.success?.should == false
|
51
|
+
@caller.response.should == "No such file or directory - garbligook"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
describe "#go_with_response" do
|
58
|
+
|
59
|
+
it "should capture command as string" do
|
60
|
+
@caller.command = "cat findme.txt"
|
61
|
+
@caller.go_with_response.should == "test123"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should allow command as parameter" do
|
65
|
+
@caller.command = "cat blah.txt"
|
66
|
+
@caller.go_with_response("cat findme.txt").should == "test123"
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
describe "#ssh" do
|
74
|
+
|
75
|
+
it "should default ot nil" do
|
76
|
+
@caller.ssh.should == nil
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should accept remote_server" do
|
80
|
+
@caller.remote_server = "remote.server.com"
|
81
|
+
@caller.ssh.should == "ssh remote.server.com"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should accept user and remote_server" do
|
85
|
+
@caller.remote_user = "deployer"
|
86
|
+
@caller.remote_server = "remote.server.com"
|
87
|
+
@caller.ssh.should == "ssh deployer@remote.server.com"
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
describe "#full_command" do
|
94
|
+
|
95
|
+
it "should default to nil" do
|
96
|
+
@caller.full_command.should == nil
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should accept command" do
|
100
|
+
@caller.command = "ls -la"
|
101
|
+
@caller.full_command.should == "ls -la"
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should accept command with remote_server" do
|
105
|
+
@caller.remote_server = "remote.server.com"
|
106
|
+
@caller.command = "mkdir blah"
|
107
|
+
@caller.full_command.should == "ssh remote.server.com 'mkdir blah'"
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should accept command with user and remote_server" do
|
111
|
+
@caller.remote_user = "deployer"
|
112
|
+
@caller.remote_server = "remote.server.com"
|
113
|
+
@caller.command = "ls -la"
|
114
|
+
@caller.full_command.should == "ssh deployer@remote.server.com 'ls -la'"
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Reservoir
|
4
|
+
|
5
|
+
describe Project do
|
6
|
+
|
7
|
+
before (:each) do
|
8
|
+
@project = Project.new
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#scripts" do
|
12
|
+
|
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"]
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#which_script_template" do
|
21
|
+
|
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'
|
27
|
+
end
|
28
|
+
|
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
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rspec'
|
4
|
+
require File.dirname(__FILE__) + '/../lib/reservoir'
|
5
|
+
|
6
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
7
|
+
# in spec/support/ and its subdirectories.
|
8
|
+
# Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
# == Mock Framework
|
13
|
+
#
|
14
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
15
|
+
#
|
16
|
+
# config.mock_with :mocha
|
17
|
+
# config.mock_with :flexmock
|
18
|
+
# config.mock_with :rr
|
19
|
+
config.mock_with :rspec
|
20
|
+
# config.before(:each) { Machinist.reset_before_test }
|
21
|
+
|
22
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
23
|
+
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
24
|
+
|
25
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
26
|
+
# examples within a transaction, remove the following line or assign false
|
27
|
+
# instead of true.
|
28
|
+
# config.use_transactional_fixtures = true
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Reservoir
|
4
|
+
|
5
|
+
describe Version do
|
6
|
+
|
7
|
+
before (:each) do
|
8
|
+
@analyzer = Version.new
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#analyze" do
|
12
|
+
|
13
|
+
it "should store version_info" do
|
14
|
+
@analyzer.read("blah")
|
15
|
+
@analyzer.version_info.should == "blah"
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "#version" do
|
19
|
+
|
20
|
+
it "should understand RVM" do
|
21
|
+
@analyzer.read("rvm 1.2.3 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]")
|
22
|
+
@analyzer.version_parts.should == ["1","2","3"]
|
23
|
+
@analyzer.version.should == "1.2.3"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should understand node.js" do
|
27
|
+
@analyzer.read("v0.4.8")
|
28
|
+
@analyzer.version_parts.should == ["0","4","8"]
|
29
|
+
@analyzer.version.should == "0.4.8"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should understand ruby" do
|
33
|
+
@analyzer.read("ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux]")
|
34
|
+
@analyzer.version_parts.should == ["1","8","7","72"]
|
35
|
+
@analyzer.version.should == "1.8.7-p72"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should understand nginx" do
|
39
|
+
@analyzer.read("nginx: nginx version: nginx/1.4.5")
|
40
|
+
@analyzer.version_parts.should == ["1","4","5"]
|
41
|
+
@analyzer.version.should == "1.4.5"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should understand passenger" do
|
45
|
+
@analyzer.read("Phusion Passenger version 3.0.7")
|
46
|
+
@analyzer.version_parts.should == ["3","0","7"]
|
47
|
+
@analyzer.version.should == "3.0.7"
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Reservoir
|
4
|
+
|
5
|
+
describe WhichScript do
|
6
|
+
|
7
|
+
before (:each) do
|
8
|
+
@which_script = WhichScript.new
|
9
|
+
@caller = Caller.new
|
10
|
+
Caller.stub!(:new).and_return(@caller)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#initialize" do
|
14
|
+
|
15
|
+
it "should support remote" do
|
16
|
+
Caller.should_receive(:new).with(remote_user: "a", remote_server: "b")
|
17
|
+
which_script = WhichScript.new(remote_user: "a", remote_server: "b")
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#go" do
|
23
|
+
|
24
|
+
it "should set the path" do
|
25
|
+
@which_script.go('ruby').should == true
|
26
|
+
@which_script.success?.should == true
|
27
|
+
@which_script.path.should == `which ruby`
|
28
|
+
@which_script.response.should == @which_script.path
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should set path to nil if unknown" do
|
32
|
+
@which_script.go('garble_gook_gook').should == false
|
33
|
+
@which_script.success?.should == false
|
34
|
+
@which_script.path.should == nil
|
35
|
+
@which_script.response.should == 'script not installed'
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should analyze on remote server if set in constructor" do
|
39
|
+
Caller.should_receive(:new).with(remote_server: 'a', remote_user: 'b')
|
40
|
+
@caller.should_receive(:go_with_response).with("which ruby").and_return("blah")
|
41
|
+
@which_script = WhichScript.new(remote_server: 'a', remote_user: 'b')
|
42
|
+
@which_script.go('ruby').should == true
|
43
|
+
@which_script.success?.should == true
|
44
|
+
@which_script.path.should == "blah"
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#to_s" do
|
50
|
+
|
51
|
+
it "should say unknown if not known" do
|
52
|
+
@which_script.to_s.should == "WhichScript called before any #go(script) was performed"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should say where the script went" do
|
56
|
+
@which_script.script = "a"
|
57
|
+
@which_script.response = "b"
|
58
|
+
@which_script.to_s.should == "a : b"
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: reservoir
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andrew Forward
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-08-30 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70102825983140 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70102825983140
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: autotest
|
27
|
+
requirement: &70102825982720 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70102825982720
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: autotest-fsevent
|
38
|
+
requirement: &70102825982260 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70102825982260
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rb-fsevent
|
49
|
+
requirement: &70102825981840 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70102825981840
|
58
|
+
description: Helps manage cloud-based server instances by enumerating, comparing and
|
59
|
+
diff'ing application configurations
|
60
|
+
email:
|
61
|
+
- aforward@gmail.com
|
62
|
+
executables:
|
63
|
+
- reservoir
|
64
|
+
extensions: []
|
65
|
+
extra_rdoc_files: []
|
66
|
+
files:
|
67
|
+
- .gitignore
|
68
|
+
- Gemfile
|
69
|
+
- README
|
70
|
+
- Rakefile
|
71
|
+
- autotest/discover.rb
|
72
|
+
- bin/reservoir
|
73
|
+
- examples/rails_server.yml
|
74
|
+
- lib/reservoir.rb
|
75
|
+
- lib/reservoir/application.rb
|
76
|
+
- lib/reservoir/caller.rb
|
77
|
+
- lib/reservoir/project.rb
|
78
|
+
- lib/reservoir/version.rb
|
79
|
+
- lib/reservoir/which_script.rb
|
80
|
+
- reservoir.gemspec
|
81
|
+
- spec/application_spec.rb
|
82
|
+
- spec/caller_spec.rb
|
83
|
+
- spec/project_spec.rb
|
84
|
+
- spec/sample_project.yml
|
85
|
+
- spec/sample_project2.yml
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
- spec/version_spec.rb
|
88
|
+
- spec/which_script_spec.rb
|
89
|
+
homepage: ''
|
90
|
+
licenses: []
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ! '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project: reservoir
|
109
|
+
rubygems_version: 1.8.6
|
110
|
+
signing_key:
|
111
|
+
specification_version: 3
|
112
|
+
summary: What apps, versions and configurations to you have setup on your server
|
113
|
+
test_files:
|
114
|
+
- spec/application_spec.rb
|
115
|
+
- spec/caller_spec.rb
|
116
|
+
- spec/project_spec.rb
|
117
|
+
- spec/sample_project.yml
|
118
|
+
- spec/sample_project2.yml
|
119
|
+
- spec/spec_helper.rb
|
120
|
+
- spec/version_spec.rb
|
121
|
+
- spec/which_script_spec.rb
|