reciper 0.0.2 → 0.0.3
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/Gemfile.lock +1 -1
- data/lib/reciper/helpers.rb +20 -2
- data/lib/reciper/version.rb +1 -1
- data/spec/reciper/helpers_spec.rb +25 -0
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/lib/reciper/helpers.rb
CHANGED
@@ -21,7 +21,7 @@ module Reciper
|
|
21
21
|
Dir.chdir(@ruby_app_path) do
|
22
22
|
response = `bundle exec rspec spec`
|
23
23
|
|
24
|
-
if response =~ /([.FE]+)/
|
24
|
+
if response =~ /([.FE*]+)/
|
25
25
|
$1.split("").reject { |char| char == "." }.size
|
26
26
|
else
|
27
27
|
puts "Can't get any test output"
|
@@ -61,15 +61,33 @@ module Reciper
|
|
61
61
|
@operations << [:copy_range, to, original_output.join("\n")]
|
62
62
|
end
|
63
63
|
|
64
|
-
|
65
64
|
def rollback
|
66
65
|
@operations.reverse.each do |operation|
|
67
66
|
if operation[0] == :copy
|
68
67
|
FileUtils.rm(@ruby_app_path + "/" + operation[1])
|
69
68
|
elsif operation[0] == :copy_range
|
70
69
|
File.open(@ruby_app_path + "/" + operation[1], "w") { |file| file.write(operation[2]) }
|
70
|
+
elsif operation[0] == :run_command
|
71
|
+
spawn(operation[1]) if operation[1]
|
72
|
+
|
73
|
+
Process.wait
|
71
74
|
end
|
72
75
|
end
|
73
76
|
end
|
77
|
+
|
78
|
+
def run_command(command, rollback_command=nil)
|
79
|
+
Dir.chdir(@ruby_app_path) do
|
80
|
+
spawn("bundle exec #{command}", :out => "/dev/null", :err => "/dev/null")
|
81
|
+
|
82
|
+
Process.wait
|
83
|
+
end
|
84
|
+
|
85
|
+
if $?.exitstatus == 0
|
86
|
+
@operations << [:run_command, rollback_command || nil]
|
87
|
+
true
|
88
|
+
else
|
89
|
+
false
|
90
|
+
end
|
91
|
+
end
|
74
92
|
end
|
75
93
|
end
|
data/lib/reciper/version.rb
CHANGED
@@ -132,6 +132,22 @@ EOF
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
+
describe ".run_command" do
|
136
|
+
it "runs a command on projects folder and returns true when successful" do
|
137
|
+
run_command("ls").should be
|
138
|
+
end
|
139
|
+
|
140
|
+
it "runs a command on projects folder and returns not true when failure" do
|
141
|
+
run_command("cp").should_not be
|
142
|
+
end
|
143
|
+
|
144
|
+
it "receives the rollback command together with the command and store it on @operations array" do
|
145
|
+
run_command("ls", "ls -a")
|
146
|
+
|
147
|
+
@operations.should include([:run_command, "ls -a"])
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
135
151
|
describe ".rollback" do
|
136
152
|
it "removes the file when the operation is copy" do
|
137
153
|
File.open(@ruby_app_path + "/an_added_file.rb", "w") {
|
@@ -162,5 +178,14 @@ EOF
|
|
162
178
|
|
163
179
|
FileUtils.rm("spec/fixtures/ruby_app/an_added_file.rb")
|
164
180
|
end
|
181
|
+
|
182
|
+
it "runs the rollback command when the operation is run_command and we have a rollback command" do
|
183
|
+
@operations = [[:run_command, "ls"]]
|
184
|
+
|
185
|
+
self.should_receive(:spawn).with("ls")
|
186
|
+
Process.stub!(:wait)
|
187
|
+
|
188
|
+
rollback
|
189
|
+
end
|
165
190
|
end
|
166
191
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reciper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: An awesome way to write recipes for a book chapter
|
15
15
|
email:
|