reservoir 0.1.1 → 0.1.2

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.
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ Gemfile.lock
4
4
  pkg/*
5
5
  .rvmrc
6
6
  sample.yml
7
+ *.log
@@ -1,4 +1,4 @@
1
- version: 0.1.1
1
+ version: 0.1.2
2
2
  display:
3
3
  filename: @@SERVER_NAME@@
4
4
  mode: data_only
@@ -38,6 +38,13 @@ module Reservoir
38
38
  print "#{script} : #{version} : #{path}\n"
39
39
  end
40
40
 
41
+ def interactive_message
42
+ print "Welcome to reservoir interactive shell"
43
+ end
44
+
45
+ def interactive_quit_message
46
+ print "Goodbye"
47
+ end
41
48
 
42
49
  def run(args)
43
50
 
@@ -45,6 +52,21 @@ module Reservoir
45
52
  usage_message
46
53
  return
47
54
  end
55
+
56
+ if "-i" == args[0]
57
+ interactive_message
58
+ v = Version.new
59
+ loop do
60
+ script = user_input
61
+ if script == "quit" || script == "exit"
62
+ interactive_quit_message
63
+ return
64
+ end
65
+ v.go(script)
66
+ print v.version
67
+ end
68
+ return
69
+ end
48
70
 
49
71
  if ["--version","-version","-v","--v","version"].include?(args[0])
50
72
  version_message
@@ -98,6 +120,10 @@ module Reservoir
98
120
  end
99
121
  end
100
122
 
123
+ def user_input
124
+ STDIN.gets.chomp
125
+ end
126
+
101
127
  private
102
128
 
103
129
  def is_file?
@@ -1,6 +1,6 @@
1
1
  module Reservoir
2
2
 
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
 
5
5
  class Version
6
6
 
@@ -22,9 +22,11 @@ module Reservoir
22
22
 
23
23
  def possible_commands(script_name)
24
24
  return [] if script_name.nil? || script_name == ""
25
- known_arguments = Version.arguments[script_name]
26
- return ["#{script_name} #{known_arguments}"] unless known_arguments.nil?
27
- ["--version","-version"].collect { |args| "#{script_name} #{args}"}
25
+ known_scripts = Version.known_scripts[script_name]
26
+ return [ known_scripts ] unless known_scripts.nil?
27
+ all = ["--version","-version"].collect { |args| "#{script_name} #{args}"}
28
+ all << "npm view #{script_name} | grep version:"
29
+ all
28
30
  end
29
31
 
30
32
  def go(script_name)
@@ -2,9 +2,9 @@ module Reservoir
2
2
 
3
3
  class Version
4
4
 
5
- def self.arguments
5
+ def self.known_scripts
6
6
  {
7
- "ruby" => "--version",
7
+ "ruby" => "ruby --version",
8
8
  }
9
9
  end
10
10
 
@@ -17,10 +17,9 @@ module Reservoir
17
17
  Caller.stub!(:exec).with("which node").and_return("/path/to/node")
18
18
  Caller.stub!(:exec).with("ssh aforward@a4word.com 'which ruby'").and_return("/path/to/a4word/ruby")
19
19
 
20
- Caller.stub!(:exec).with("ruby --version").and_return("v1.2.3")
21
- Caller.stub!(:exec).with("rvm --version").and_return("1.2.4")
22
- Caller.stub!(:exec).with("node --version").and_return("")
23
- Caller.stub!(:exec).with("node -version").and_return("")
20
+ stub_version("ruby","v1.2.3")
21
+ stub_version("rvm","v1.2.4")
22
+ stub_version("node")
24
23
  Caller.stub!(:exec).with("ssh aforward@a4word.com 'ruby --version'").and_return("1.2.6")
25
24
 
26
25
  cleanup
@@ -77,6 +76,30 @@ module Reservoir
77
76
 
78
77
  end
79
78
 
79
+ describe "interactive" do
80
+
81
+ it "should go until quit" do
82
+ @application.stub!(:user_input).and_return("quit")
83
+ @application.should_receive(:interactive_message)
84
+ @application.should_receive(:interactive_quit_message)
85
+ @application.run(["-i"])
86
+ end
87
+
88
+ it "should lookup version" do
89
+ @application.stub!(:user_input).and_return("ruby","rvm","quit")
90
+ @application.should_receive(:interactive_message)
91
+ @application.should_receive(:print).with("1.2.3")
92
+ @application.should_receive(:print).with("4.5.6")
93
+ v = Version.new
94
+ Version.stub!(:new).and_return(v)
95
+ v.stub(:go).and_return(true)
96
+ v.stub(:version).and_return("1.2.3","4.5.6")
97
+ @application.should_receive(:interactive_quit_message)
98
+ @application.run(["-i"])
99
+ end
100
+
101
+ end
102
+
80
103
  describe "invalid project file" do
81
104
 
82
105
  it "should fail gracefully" do
@@ -115,12 +138,12 @@ module Reservoir
115
138
  it "should clean up existing files" do
116
139
  open("a4word.com", 'a+') { |f| f.puts("garble") }
117
140
  @application.run([@project_file,@project_file2])
118
- IO.read("a4word.com").should == "reservoir, version 0.1.1\nserver: aforward@a4word.com\nfile: /Users/aforward/tp/projects/cenx/reservoir/spec/sample_project2.yml\nruby : 1.2.6 : /path/to/a4word/ruby\n"
141
+ IO.read("a4word.com").should == "reservoir, version 0.1.2\nserver: aforward@a4word.com\nfile: /Users/aforward/tp/projects/cenx/reservoir/spec/sample_project2.yml\nruby : 1.2.6 : /path/to/a4word/ruby\n"
119
142
  end
120
143
 
121
144
  it "should support mode: data_only" do
122
145
  @application.run([@project_file3])
123
- IO.read("./tmp/moretmp/a4word.com").should == "reservoir, version 0.1.1\nruby : 1.2.6 : /path/to/a4word/ruby\n"
146
+ IO.read("./tmp/moretmp/a4word.com").should == "reservoir, version 0.1.2\nruby : 1.2.6 : /path/to/a4word/ruby\n"
124
147
  end
125
148
 
126
149
  end
@@ -152,7 +175,7 @@ module Reservoir
152
175
  describe "#messages" do
153
176
 
154
177
  it "should version_message" do
155
- @application.version_message.should == "reservoir, version 0.1.1\n"
178
+ @application.version_message.should == "reservoir, version 0.1.2\n"
156
179
  end
157
180
 
158
181
  it "should usage_message" do
@@ -28,3 +28,12 @@ RSpec.configure do |config|
28
28
  # config.use_transactional_fixtures = true
29
29
 
30
30
  end
31
+
32
+
33
+ def stub_version(script_name,outputs = [])
34
+ outputs = [ outputs ] if outputs.kind_of?(String)
35
+
36
+ Reservoir::Caller.stub!(:exec).with("#{script_name} --version").and_return(outputs[0] || "")
37
+ Reservoir::Caller.stub!(:exec).with("#{script_name} -version").and_return(outputs[1] || "")
38
+ Reservoir::Caller.stub!(:exec).with("npm view #{script_name} | grep version:").and_return(outputs[2] || "")
39
+ end
@@ -11,7 +11,7 @@ module Reservoir
11
11
  describe "#go" do
12
12
 
13
13
  it "should use arguments if set" do
14
- Version.stub!(:arguments).and_return({ "garble" => "-vgarble" })
14
+ Version.stub!(:known_scripts).and_return({ "garble" => "garble -vgarble" })
15
15
  Caller.stub!(:exec).with("garble -vgarble").and_return("garble v1.2.3")
16
16
  @version.go("garble").should == true
17
17
  @version.success?.should == true
@@ -20,8 +20,8 @@ module Reservoir
20
20
  end
21
21
 
22
22
  it "should return false if unable to locate version" do
23
- Caller.stub!(:exec).with("garble --version").and_return("blah")
24
- Caller.stub!(:exec).with("garble -version").and_return("")
23
+ stub_version("garble",["blah"])
24
+
25
25
  @version.go("garble").should == false
26
26
  @version.success?.should == false
27
27
  @version.version_info.should == nil
@@ -41,6 +41,8 @@ module Reservoir
41
41
  Caller.stub!(:exec).with("garble --version").and_return("v1.2.4")
42
42
  Caller.stub!(:exec).with("marble --version").and_return("")
43
43
  Caller.stub!(:exec).with("marble -version").and_return("")
44
+ Caller.stub!(:exec).with("npm view marble | grep version:").and_return("")
45
+
44
46
 
45
47
  @version.go("garble").should == true
46
48
  @version.version_info.should == "v1.2.4"
@@ -64,12 +66,12 @@ module Reservoir
64
66
  end
65
67
 
66
68
  it "should use arguments if set" do
67
- Version.stub!(:arguments).and_return({ "garble" => "-vgarble" })
69
+ Version.stub!(:known_scripts).and_return({ "garble" => "garble -vgarble" })
68
70
  @version.possible_commands("garble").should == ["garble -vgarble"]
69
71
  end
70
72
 
71
73
  it "should provide possible answers if not in known set" do
72
- @version.possible_commands("garble").should == ["garble --version","garble -version"]
74
+ @version.possible_commands("garble").should == ["garble --version","garble -version", "npm view garble | grep version:"]
73
75
  end
74
76
 
75
77
  end
@@ -121,6 +123,12 @@ module Reservoir
121
123
  @version.version.should == "3.0.7"
122
124
  end
123
125
 
126
+ it "should understand npm package" do
127
+ @version.read("version: '0.8.4',").should == true
128
+ @version.version_parts.should == ["0","8","4"]
129
+ @version.version.should == "0.8.4"
130
+ end
131
+
124
132
  end
125
133
 
126
134
  end
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.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-16 00:00:00.000000000Z
12
+ date: 2011-09-28 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2156756840 !ruby/object:Gem::Requirement
16
+ requirement: &70243351891340 !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: *2156756840
24
+ version_requirements: *70243351891340
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: autotest
27
- requirement: &2156756420 !ruby/object:Gem::Requirement
27
+ requirement: &70243351890920 !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: *2156756420
35
+ version_requirements: *70243351890920
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: autotest-fsevent
38
- requirement: &2156755960 !ruby/object:Gem::Requirement
38
+ requirement: &70243351890460 !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: *2156755960
46
+ version_requirements: *70243351890460
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rb-fsevent
49
- requirement: &2156755540 !ruby/object:Gem::Requirement
49
+ requirement: &70243351890040 !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: *2156755540
57
+ version_requirements: *70243351890040
58
58
  description: Helps manage cloud-based server instances by enumerating, comparing and
59
59
  diff'ing application configurations
60
60
  email:
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  requirements: []
110
110
  rubyforge_project: reservoir
111
- rubygems_version: 1.8.5
111
+ rubygems_version: 1.8.6
112
112
  signing_key:
113
113
  specification_version: 3
114
114
  summary: What apps, versions and configurations to you have setup on your server