bovem 2.3.6 → 2.3.7
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/.travis.yml +1 -1
- data/Rakefile +18 -0
- data/bovem.gemspec +1 -1
- data/doc/Bovem.html +1 -1
- data/doc/Bovem/Configuration.html +1 -1
- data/doc/Bovem/Console.html +1 -1
- data/doc/Bovem/ConsoleMethods.html +1 -1
- data/doc/Bovem/ConsoleMethods/Interactions.html +1 -1
- data/doc/Bovem/ConsoleMethods/Interactions/ClassMethods.html +1 -1
- data/doc/Bovem/ConsoleMethods/Logging.html +1 -1
- data/doc/Bovem/ConsoleMethods/Logging/ClassMethods.html +1 -1
- data/doc/Bovem/ConsoleMethods/Output.html +1 -1
- data/doc/Bovem/ConsoleMethods/StyleHandling.html +1 -1
- data/doc/Bovem/ConsoleMethods/StyleHandling/ClassMethods.html +1 -1
- data/doc/Bovem/Errors.html +1 -1
- data/doc/Bovem/Errors/InvalidConfiguration.html +1 -1
- data/doc/Bovem/Errors/InvalidLogger.html +1 -1
- data/doc/Bovem/Logger.html +1 -1
- data/doc/Bovem/Shell.html +1 -1
- data/doc/Bovem/ShellMethods.html +1 -1
- data/doc/Bovem/ShellMethods/Directories.html +1 -1
- data/doc/Bovem/ShellMethods/Execute.html +1 -1
- data/doc/Bovem/ShellMethods/General.html +1 -1
- data/doc/Bovem/ShellMethods/Read.html +1 -1
- data/doc/Bovem/ShellMethods/Write.html +1 -1
- data/doc/Bovem/Version.html +2 -2
- data/doc/_index.html +1 -1
- data/doc/file.README.html +1 -1
- data/doc/index.html +1 -1
- data/doc/top-level-namespace.html +1 -1
- data/lib/bovem/version.rb +1 -1
- data/spec/bovem/console_spec.rb +48 -48
- data/spec/bovem/logger_spec.rb +5 -5
- data/spec/bovem/shell_spec.rb +67 -67
- metadata +5 -5
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
|
@@ -9,3 +9,21 @@ require "rspec/core/rake_task"
|
|
|
9
9
|
|
|
10
10
|
RSpec::Core::RakeTask.new("spec")
|
|
11
11
|
RSpec::Core::RakeTask.new("spec:coverage") { |t| t.ruby_opts = "-r./spec/coverage_helper" }
|
|
12
|
+
|
|
13
|
+
desc "Generate the documentation"
|
|
14
|
+
task :docs do
|
|
15
|
+
system("yardoc") || raise("Failed Execution of: yardoc")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
desc "Get the current release version"
|
|
19
|
+
task :version, :with_name do |_, args|
|
|
20
|
+
gem = Bundler::GemHelper.instance.gemspec
|
|
21
|
+
puts [args[:with_name] == "true" ? gem.name : nil, gem.version].compact.join("-")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc "Prepare the release"
|
|
25
|
+
task :prerelease => ["spec:coverage", "docs"] do
|
|
26
|
+
["git add -A", "git commit -am \"Version #{Bundler::GemHelper.instance.gemspec.version}\""].each do |cmd|
|
|
27
|
+
system(cmd) || raise("Failed Execution of: #{cmd}")
|
|
28
|
+
end
|
|
29
|
+
end
|
data/bovem.gemspec
CHANGED
data/doc/Bovem.html
CHANGED
|
@@ -158,7 +158,7 @@ Licensed under the MIT license, which can be found at http://www.opensource.org/
|
|
|
158
158
|
</div>
|
|
159
159
|
|
|
160
160
|
<div id="footer">
|
|
161
|
-
Generated on
|
|
161
|
+
Generated on Sat Jul 20 11:12:22 2013 by
|
|
162
162
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
163
163
|
0.8.6.2 (ruby-1.9.3).
|
|
164
164
|
</div>
|
|
@@ -444,7 +444,7 @@ config.property = "VALUE"
|
|
|
444
444
|
</div>
|
|
445
445
|
|
|
446
446
|
<div id="footer">
|
|
447
|
-
Generated on
|
|
447
|
+
Generated on Sat Jul 20 11:12:24 2013 by
|
|
448
448
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
449
449
|
0.8.6.2 (ruby-1.9.3).
|
|
450
450
|
</div>
|
data/doc/Bovem/Console.html
CHANGED
|
@@ -760,7 +760,7 @@
|
|
|
760
760
|
</div>
|
|
761
761
|
|
|
762
762
|
<div id="footer">
|
|
763
|
-
Generated on
|
|
763
|
+
Generated on Sat Jul 20 11:12:23 2013 by
|
|
764
764
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
765
765
|
0.8.6.2 (ruby-1.9.3).
|
|
766
766
|
</div>
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
</div>
|
|
117
117
|
|
|
118
118
|
<div id="footer">
|
|
119
|
-
Generated on
|
|
119
|
+
Generated on Sat Jul 20 11:12:22 2013 by
|
|
120
120
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
121
121
|
0.8.6.2 (ruby-1.9.3).
|
|
122
122
|
</div>
|
|
@@ -558,7 +558,7 @@
|
|
|
558
558
|
</div>
|
|
559
559
|
|
|
560
560
|
<div id="footer">
|
|
561
|
-
Generated on
|
|
561
|
+
Generated on Sat Jul 20 11:12:23 2013 by
|
|
562
562
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
563
563
|
0.8.6.2 (ruby-1.9.3).
|
|
564
564
|
</div>
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
</div>
|
|
223
223
|
|
|
224
224
|
<div id="footer">
|
|
225
|
-
Generated on
|
|
225
|
+
Generated on Sat Jul 20 11:12:23 2013 by
|
|
226
226
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
227
227
|
0.8.6.2 (ruby-1.9.3).
|
|
228
228
|
</div>
|
|
@@ -2209,7 +2209,7 @@
|
|
|
2209
2209
|
</div>
|
|
2210
2210
|
|
|
2211
2211
|
<div id="footer">
|
|
2212
|
-
Generated on
|
|
2212
|
+
Generated on Sat Jul 20 11:12:23 2013 by
|
|
2213
2213
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
2214
2214
|
0.8.6.2 (ruby-1.9.3).
|
|
2215
2215
|
</div>
|
|
@@ -203,7 +203,7 @@
|
|
|
203
203
|
</div>
|
|
204
204
|
|
|
205
205
|
<div id="footer">
|
|
206
|
-
Generated on
|
|
206
|
+
Generated on Sat Jul 20 11:12:23 2013 by
|
|
207
207
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
208
208
|
0.8.6.2 (ruby-1.9.3).
|
|
209
209
|
</div>
|
|
@@ -1112,7 +1112,7 @@
|
|
|
1112
1112
|
</div>
|
|
1113
1113
|
|
|
1114
1114
|
<div id="footer">
|
|
1115
|
-
Generated on
|
|
1115
|
+
Generated on Sat Jul 20 11:12:22 2013 by
|
|
1116
1116
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
1117
1117
|
0.8.6.2 (ruby-1.9.3).
|
|
1118
1118
|
</div>
|
|
@@ -265,7 +265,7 @@
|
|
|
265
265
|
</div>
|
|
266
266
|
|
|
267
267
|
<div id="footer">
|
|
268
|
-
Generated on
|
|
268
|
+
Generated on Sat Jul 20 11:12:22 2013 by
|
|
269
269
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
270
270
|
0.8.6.2 (ruby-1.9.3).
|
|
271
271
|
</div>
|
|
@@ -641,7 +641,7 @@ Bovem::Console.new.replace_markers("{mark=bright bg_red}{mark=green}Hello world!
|
|
|
641
641
|
</div>
|
|
642
642
|
|
|
643
643
|
<div id="footer">
|
|
644
|
-
Generated on
|
|
644
|
+
Generated on Sat Jul 20 11:12:22 2013 by
|
|
645
645
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
646
646
|
0.8.6.2 (ruby-1.9.3).
|
|
647
647
|
</div>
|
data/doc/Bovem/Errors.html
CHANGED
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
</div>
|
|
117
117
|
|
|
118
118
|
<div id="footer">
|
|
119
|
-
Generated on
|
|
119
|
+
Generated on Sat Jul 20 11:12:22 2013 by
|
|
120
120
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
121
121
|
0.8.6.2 (ruby-1.9.3).
|
|
122
122
|
</div>
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
</div>
|
|
125
125
|
|
|
126
126
|
<div id="footer">
|
|
127
|
-
Generated on
|
|
127
|
+
Generated on Sat Jul 20 11:12:23 2013 by
|
|
128
128
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
129
129
|
0.8.6.2 (ruby-1.9.3).
|
|
130
130
|
</div>
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
</div>
|
|
125
125
|
|
|
126
126
|
<div id="footer">
|
|
127
|
-
Generated on
|
|
127
|
+
Generated on Sat Jul 20 11:12:23 2013 by
|
|
128
128
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
129
129
|
0.8.6.2 (ruby-1.9.3).
|
|
130
130
|
</div>
|
data/doc/Bovem/Logger.html
CHANGED
|
@@ -1136,7 +1136,7 @@
|
|
|
1136
1136
|
</div>
|
|
1137
1137
|
|
|
1138
1138
|
<div id="footer">
|
|
1139
|
-
Generated on
|
|
1139
|
+
Generated on Sat Jul 20 11:12:23 2013 by
|
|
1140
1140
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
1141
1141
|
0.8.6.2 (ruby-1.9.3).
|
|
1142
1142
|
</div>
|
data/doc/Bovem/Shell.html
CHANGED
|
@@ -493,7 +493,7 @@
|
|
|
493
493
|
</div>
|
|
494
494
|
|
|
495
495
|
<div id="footer">
|
|
496
|
-
Generated on
|
|
496
|
+
Generated on Sat Jul 20 11:12:23 2013 by
|
|
497
497
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
498
498
|
0.8.6.2 (ruby-1.9.3).
|
|
499
499
|
</div>
|
data/doc/Bovem/ShellMethods.html
CHANGED
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
</div>
|
|
117
117
|
|
|
118
118
|
<div id="footer">
|
|
119
|
-
Generated on
|
|
119
|
+
Generated on Sat Jul 20 11:12:22 2013 by
|
|
120
120
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
121
121
|
0.8.6.2 (ruby-1.9.3).
|
|
122
122
|
</div>
|
|
@@ -473,7 +473,7 @@
|
|
|
473
473
|
</div>
|
|
474
474
|
|
|
475
475
|
<div id="footer">
|
|
476
|
-
Generated on
|
|
476
|
+
Generated on Sat Jul 20 11:12:22 2013 by
|
|
477
477
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
478
478
|
0.8.6.2 (ruby-1.9.3).
|
|
479
479
|
</div>
|
|
@@ -556,7 +556,7 @@
|
|
|
556
556
|
</div>
|
|
557
557
|
|
|
558
558
|
<div id="footer">
|
|
559
|
-
Generated on
|
|
559
|
+
Generated on Sat Jul 20 11:12:22 2013 by
|
|
560
560
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
561
561
|
0.8.6.2 (ruby-1.9.3).
|
|
562
562
|
</div>
|
|
@@ -551,7 +551,7 @@
|
|
|
551
551
|
</div>
|
|
552
552
|
|
|
553
553
|
<div id="footer">
|
|
554
|
-
Generated on
|
|
554
|
+
Generated on Sat Jul 20 11:12:22 2013 by
|
|
555
555
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
556
556
|
0.8.6.2 (ruby-1.9.3).
|
|
557
557
|
</div>
|
|
@@ -442,7 +442,7 @@
|
|
|
442
442
|
</div>
|
|
443
443
|
|
|
444
444
|
<div id="footer">
|
|
445
|
-
Generated on
|
|
445
|
+
Generated on Sat Jul 20 11:12:22 2013 by
|
|
446
446
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
447
447
|
0.8.6.2 (ruby-1.9.3).
|
|
448
448
|
</div>
|
|
@@ -665,7 +665,7 @@
|
|
|
665
665
|
</div>
|
|
666
666
|
|
|
667
667
|
<div id="footer">
|
|
668
|
-
Generated on
|
|
668
|
+
Generated on Sat Jul 20 11:12:22 2013 by
|
|
669
669
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
670
670
|
0.8.6.2 (ruby-1.9.3).
|
|
671
671
|
</div>
|
data/doc/Bovem/Version.html
CHANGED
|
@@ -149,7 +149,7 @@
|
|
|
149
149
|
|
|
150
150
|
</div>
|
|
151
151
|
</dt>
|
|
152
|
-
<dd><pre class="code"><span class='int'>
|
|
152
|
+
<dd><pre class="code"><span class='int'>7</span></pre></dd>
|
|
153
153
|
|
|
154
154
|
<dt id="STRING-constant" class="">STRING =
|
|
155
155
|
<div class="docstring">
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
</div>
|
|
181
181
|
|
|
182
182
|
<div id="footer">
|
|
183
|
-
Generated on
|
|
183
|
+
Generated on Sat Jul 20 11:12:23 2013 by
|
|
184
184
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
185
185
|
0.8.6.2 (ruby-1.9.3).
|
|
186
186
|
</div>
|
data/doc/_index.html
CHANGED
|
@@ -346,7 +346,7 @@
|
|
|
346
346
|
</div>
|
|
347
347
|
|
|
348
348
|
<div id="footer">
|
|
349
|
-
Generated on
|
|
349
|
+
Generated on Sat Jul 20 11:12:22 2013 by
|
|
350
350
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
351
351
|
0.8.6.2 (ruby-1.9.3).
|
|
352
352
|
</div>
|
data/doc/file.README.html
CHANGED
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
</div></div>
|
|
102
102
|
|
|
103
103
|
<div id="footer">
|
|
104
|
-
Generated on
|
|
104
|
+
Generated on Sat Jul 20 11:12:22 2013 by
|
|
105
105
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
106
106
|
0.8.6.2 (ruby-1.9.3).
|
|
107
107
|
</div>
|
data/doc/index.html
CHANGED
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
</div></div>
|
|
102
102
|
|
|
103
103
|
<div id="footer">
|
|
104
|
-
Generated on
|
|
104
|
+
Generated on Sat Jul 20 11:12:22 2013 by
|
|
105
105
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
106
106
|
0.8.6.2 (ruby-1.9.3).
|
|
107
107
|
</div>
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
</div>
|
|
104
104
|
|
|
105
105
|
<div id="footer">
|
|
106
|
-
Generated on
|
|
106
|
+
Generated on Sat Jul 20 11:12:22 2013 by
|
|
107
107
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
108
108
|
0.8.6.2 (ruby-1.9.3).
|
|
109
109
|
</div>
|
data/lib/bovem/version.rb
CHANGED
data/spec/bovem/console_spec.rb
CHANGED
|
@@ -15,7 +15,7 @@ describe Bovem::Console do
|
|
|
15
15
|
|
|
16
16
|
before(:each) do
|
|
17
17
|
ENV["TERM"] = "xterm-256color"
|
|
18
|
-
Kernel.
|
|
18
|
+
allow(Kernel).to receive(:puts).and_return(nil)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
describe ".instance" do
|
|
@@ -78,7 +78,7 @@ describe Bovem::Console do
|
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
it "should use $stdin.winsize if available" do
|
|
81
|
-
$stdin.
|
|
81
|
+
expect($stdin).to receive(:winsize)
|
|
82
82
|
console.line_width
|
|
83
83
|
end
|
|
84
84
|
end
|
|
@@ -172,7 +172,7 @@ describe Bovem::Console do
|
|
|
172
172
|
|
|
173
173
|
describe "#replace_markers" do
|
|
174
174
|
it "should just forwards to .replace_markers" do
|
|
175
|
-
::Bovem::Console.
|
|
175
|
+
expect(::Bovem::Console).to receive(:replace_markers).with("A", "B")
|
|
176
176
|
console.replace_markers("A", "B")
|
|
177
177
|
end
|
|
178
178
|
end
|
|
@@ -181,28 +181,28 @@ describe Bovem::Console do
|
|
|
181
181
|
it "should correctly align messages" do
|
|
182
182
|
message = "ABCDE"
|
|
183
183
|
extended_message = "ABC\e[AD\e[3mE"
|
|
184
|
-
console.
|
|
184
|
+
allow(console).to receive(:line_width).and_return(80)
|
|
185
185
|
|
|
186
186
|
expect(console.format_right(message)).to eq("\e[A\e[0G\e[#{75}CABCDE")
|
|
187
187
|
expect(console.format_right(message, 10)).to eq("\e[A\e[0G\e[#{-5}CABCDE")
|
|
188
188
|
expect(console.format_right(extended_message)).to eq("\e[A\e[0G\e[#{75}CABC\e[AD\e[3mE")
|
|
189
189
|
expect(console.format_right(message, nil, false)).to eq("\e[0G\e[#{75}CABCDE")
|
|
190
|
-
console.
|
|
190
|
+
allow(console).to receive(:line_width).and_return(10)
|
|
191
191
|
expect(console.format_right(message)).to eq("\e[A\e[0G\e[#{5}CABCDE")
|
|
192
192
|
end
|
|
193
193
|
end
|
|
194
194
|
|
|
195
195
|
describe "#write" do
|
|
196
196
|
it "should call #format" do
|
|
197
|
-
console.
|
|
197
|
+
expect(console).to receive(:format).with("A", "B", "C", "D", "E")
|
|
198
198
|
console.write("A", "B", "C", "D", "E")
|
|
199
199
|
end
|
|
200
200
|
end
|
|
201
201
|
|
|
202
202
|
describe "#write_banner_aligned" do
|
|
203
203
|
it "should call #min_banner_length and #format" do
|
|
204
|
-
::Bovem::Console.
|
|
205
|
-
console.
|
|
204
|
+
expect(::Bovem::Console).to receive(:min_banner_length).and_return(1)
|
|
205
|
+
expect(console).to receive(:format).with(" A", "B", "C", "D", "E")
|
|
206
206
|
console.write_banner_aligned("A", "B", "C", "D", "E")
|
|
207
207
|
end
|
|
208
208
|
end
|
|
@@ -220,69 +220,69 @@ describe Bovem::Console do
|
|
|
220
220
|
|
|
221
221
|
describe "#info" do
|
|
222
222
|
it "should forward everything to #get_banner" do
|
|
223
|
-
console.
|
|
223
|
+
expect(console).to receive(:get_banner).with("I", "bright cyan", false).at_least(1).and_return("")
|
|
224
224
|
console.info("OK", "\n", true, false, false, false, false, false)
|
|
225
|
-
console.
|
|
225
|
+
expect(console).to receive(:get_banner).with("I", "bright cyan", true).at_least(1).and_return("")
|
|
226
226
|
console.info("OK", "\n", true, false, false, false, true, false)
|
|
227
227
|
end
|
|
228
228
|
|
|
229
229
|
it "should forward everything to #write" do
|
|
230
|
-
console.
|
|
230
|
+
expect(console).to receive(:write).with(/.+/, "B", "C", "D", "E", false)
|
|
231
231
|
console.info("A", "B", "C", "D", "E", "F", "G", false)
|
|
232
232
|
end
|
|
233
233
|
end
|
|
234
234
|
|
|
235
235
|
describe "#begin" do
|
|
236
236
|
it "should forward everything to #get_banner" do
|
|
237
|
-
console.
|
|
237
|
+
expect(console).to receive(:get_banner).with("*", "bright green", false).at_least(1).and_return("")
|
|
238
238
|
console.begin("OK", "\n", true, false, false, false, false, false)
|
|
239
239
|
end
|
|
240
240
|
|
|
241
241
|
it "should forward everything to #write" do
|
|
242
|
-
console.
|
|
242
|
+
expect(console).to receive(:write).with(/.+/, "B", "C", "D", "E", false)
|
|
243
243
|
console.begin("A", "B", "C", "D", "E", "F", "G", false)
|
|
244
244
|
end
|
|
245
245
|
end
|
|
246
246
|
|
|
247
247
|
describe "#warn" do
|
|
248
248
|
it "should forward everything to #get_banner" do
|
|
249
|
-
console.
|
|
249
|
+
expect(console).to receive(:get_banner).with("W", "bright yellow", false).at_least(1).and_return("")
|
|
250
250
|
console.warn("OK", "\n", true, false, false, false, false, false)
|
|
251
|
-
console.
|
|
251
|
+
expect(console).to receive(:get_banner).with("W", "bright yellow", true).at_least(1).and_return("")
|
|
252
252
|
console.warn("OK", "\n", true, false, false, false, true, false)
|
|
253
253
|
end
|
|
254
254
|
|
|
255
255
|
it "should forward everything to #write" do
|
|
256
|
-
console.
|
|
256
|
+
expect(console).to receive(:write).with(/.+/, "B", "C", "D", "E", false)
|
|
257
257
|
console.warn("A", "B", "C", "D", "E", "F", "G", false)
|
|
258
258
|
end
|
|
259
259
|
end
|
|
260
260
|
|
|
261
261
|
describe "#error" do
|
|
262
262
|
it "should forward everything to #get_banner" do
|
|
263
|
-
console.
|
|
263
|
+
expect(console).to receive(:get_banner).with("E", "bright red", false).at_least(1).and_return("")
|
|
264
264
|
console.error("OK", "\n", true, false, false, false, false, false)
|
|
265
|
-
console.
|
|
265
|
+
expect(console).to receive(:get_banner).with("E", "bright red", true).at_least(1).and_return("")
|
|
266
266
|
console.error("OK", "\n", true, false, false, false, true, false)
|
|
267
267
|
end
|
|
268
268
|
|
|
269
269
|
it "should forward everything to #write" do
|
|
270
|
-
console.
|
|
270
|
+
expect(console).to receive(:write).with(/.+/, "B", "C", "D", "E", false)
|
|
271
271
|
console.error("A", "B", "C", "D", "E", "F", "G", false)
|
|
272
272
|
end
|
|
273
273
|
end
|
|
274
274
|
|
|
275
275
|
describe "#fatal" do
|
|
276
276
|
it "should forward anything to #error" do
|
|
277
|
-
Kernel.
|
|
278
|
-
console.
|
|
277
|
+
allow(Kernel).to receive(:exit).and_return(true)
|
|
278
|
+
expect(console).to receive(:error).with("A", "B", "C", "D", "E", "F", "G", false)
|
|
279
279
|
console.fatal("A", "B", "C", "D", "E", "F", "G", "H", false)
|
|
280
280
|
end
|
|
281
281
|
|
|
282
282
|
it "should call abort with the right error code" do
|
|
283
|
-
Kernel.
|
|
283
|
+
allow(Kernel).to receive(:exit).and_return(true)
|
|
284
284
|
|
|
285
|
-
Kernel.
|
|
285
|
+
expect(Kernel).to receive(:exit).with(-1).exactly(2)
|
|
286
286
|
console.fatal("A", "B", "C", "D", "E", "F", "G", -1, false)
|
|
287
287
|
console.fatal("A", "B", "C", "D", "E", "F", "G", "H", false)
|
|
288
288
|
end
|
|
@@ -290,14 +290,14 @@ describe Bovem::Console do
|
|
|
290
290
|
|
|
291
291
|
describe "#debug" do
|
|
292
292
|
it "should forward everything to #get_banner" do
|
|
293
|
-
console.
|
|
293
|
+
expect(console).to receive(:get_banner).with("D", "bright magenta", false).at_least(1).and_return("")
|
|
294
294
|
console.debug("OK", "\n", true, false, false, false, false, false)
|
|
295
|
-
console.
|
|
295
|
+
expect(console).to receive(:get_banner).with("D", "bright magenta", true).at_least(1).and_return("")
|
|
296
296
|
console.debug("OK", "\n", true, false, false, false, true, false)
|
|
297
297
|
end
|
|
298
298
|
|
|
299
299
|
it "should forward everything to #write" do
|
|
300
|
-
console.
|
|
300
|
+
expect(console).to receive(:write).with(/.+/, "B", "C", "D", "E", false)
|
|
301
301
|
console.debug("A", "B", "C", "D", "E", "F", "G", false)
|
|
302
302
|
end
|
|
303
303
|
end
|
|
@@ -313,47 +313,47 @@ describe Bovem::Console do
|
|
|
313
313
|
end
|
|
314
314
|
|
|
315
315
|
it "should create the banner" do
|
|
316
|
-
console.
|
|
316
|
+
expect(console).to receive(:get_banner).with(" OK ", "bright green").and_return("")
|
|
317
317
|
console.status(:ok)
|
|
318
318
|
end
|
|
319
319
|
|
|
320
320
|
it "should format correctly" do
|
|
321
|
-
console.
|
|
321
|
+
expect(console).to receive(:format_right).with(/.+/, true, true, false)
|
|
322
322
|
console.status(:ok, false, true)
|
|
323
|
-
console.
|
|
323
|
+
expect(console).to receive(:format).with(/.+/, "\n", true, true, false)
|
|
324
324
|
console.status(:ok, false, true, false)
|
|
325
325
|
end
|
|
326
326
|
end
|
|
327
327
|
|
|
328
328
|
describe "#read" do
|
|
329
329
|
it "should show a prompt" do
|
|
330
|
-
$stdin.
|
|
330
|
+
allow($stdin).to receive(:gets).and_return("VALUE\n")
|
|
331
331
|
|
|
332
332
|
prompt = "PROMPT"
|
|
333
|
-
Kernel.
|
|
333
|
+
expect(Kernel).to receive(:print).with("Please insert a value: ")
|
|
334
334
|
console.read(true)
|
|
335
|
-
Kernel.
|
|
335
|
+
expect(Kernel).to receive(:print).with(prompt + ": ")
|
|
336
336
|
console.read(prompt)
|
|
337
|
-
Kernel.
|
|
337
|
+
expect(Kernel).not_to receive("print")
|
|
338
338
|
console.read(nil)
|
|
339
339
|
end
|
|
340
340
|
|
|
341
341
|
it "should read a value or a default" do
|
|
342
|
-
$stdin.
|
|
342
|
+
allow($stdin).to receive(:gets).and_return("VALUE\n")
|
|
343
343
|
expect(console.read(nil, "DEFAULT")).to eq("VALUE")
|
|
344
|
-
$stdin.
|
|
344
|
+
allow($stdin).to receive(:gets).and_return("\n")
|
|
345
345
|
expect(console.read(nil, "DEFAULT")).to eq("DEFAULT")
|
|
346
346
|
end
|
|
347
347
|
|
|
348
348
|
it "should return the default value if the user quits" do
|
|
349
|
-
$stdin.
|
|
349
|
+
allow($stdin).to receive(:gets).and_raise(Interrupt)
|
|
350
350
|
expect(console.read(nil, "DEFAULT")).to eq("DEFAULT")
|
|
351
351
|
end
|
|
352
352
|
|
|
353
353
|
it "should validate against an object or array validator" do
|
|
354
354
|
count = 0
|
|
355
355
|
|
|
356
|
-
$stdin.
|
|
356
|
+
allow($stdin).to receive(:gets) do
|
|
357
357
|
if count == 0 then
|
|
358
358
|
count += 1
|
|
359
359
|
"2\n"
|
|
@@ -362,7 +362,7 @@ describe Bovem::Console do
|
|
|
362
362
|
end
|
|
363
363
|
end
|
|
364
364
|
|
|
365
|
-
console.
|
|
365
|
+
expect(console).to receive(:write).with("Sorry, your reply was not understood. Please try again.", false, false).exactly(4)
|
|
366
366
|
count = 0
|
|
367
367
|
console.read(nil, nil, "A")
|
|
368
368
|
count = 0
|
|
@@ -376,7 +376,7 @@ describe Bovem::Console do
|
|
|
376
376
|
it "should validate against an regexp validator" do
|
|
377
377
|
count = 0
|
|
378
378
|
|
|
379
|
-
$stdin.
|
|
379
|
+
allow($stdin).to receive(:gets) do
|
|
380
380
|
if count == 0 then
|
|
381
381
|
count += 1
|
|
382
382
|
"2\n"
|
|
@@ -385,38 +385,38 @@ describe Bovem::Console do
|
|
|
385
385
|
end
|
|
386
386
|
end
|
|
387
387
|
|
|
388
|
-
console.
|
|
388
|
+
expect(console).to receive(:write).with("Sorry, your reply was not understood. Please try again.", false, false)
|
|
389
389
|
console.read(nil, nil, /[abc]/)
|
|
390
390
|
end
|
|
391
391
|
|
|
392
392
|
it "should hide echo to the user when the terminal shows echo" do
|
|
393
|
-
$stdin.
|
|
393
|
+
expect($stdin).to receive(:noecho).and_return("VALUE")
|
|
394
394
|
console.read(nil, nil, nil, false)
|
|
395
395
|
end
|
|
396
396
|
end
|
|
397
397
|
|
|
398
398
|
describe "#task" do
|
|
399
399
|
it "should not print the message by default" do
|
|
400
|
-
console.
|
|
400
|
+
expect(console).not_to receive("begin")
|
|
401
401
|
console.task { :ok }
|
|
402
402
|
end
|
|
403
403
|
|
|
404
404
|
it "should print the message and indentate correctly" do
|
|
405
|
-
console.
|
|
406
|
-
console.
|
|
405
|
+
expect(console).to receive(:begin).with("A", "B", "C", "D", "E", "F", "G")
|
|
406
|
+
expect(console).to receive(:with_indentation).with("H", "I")
|
|
407
407
|
console.task("A", "B", "C", "D", "E", "F", "G", "H", "I") { :ok }
|
|
408
408
|
end
|
|
409
409
|
|
|
410
410
|
it "should execute the given block" do
|
|
411
|
-
::Bovem::Console.
|
|
411
|
+
expect(::Bovem::Console).to receive(:foo)
|
|
412
412
|
console.task { ::Bovem::Console.foo }
|
|
413
413
|
end
|
|
414
414
|
|
|
415
415
|
it "should write the correct status" do
|
|
416
|
-
console.
|
|
417
|
-
console.
|
|
416
|
+
allow(console).to receive(:begin)
|
|
417
|
+
expect(console).to receive(:status).with(:ok, false)
|
|
418
418
|
console.task("OK") { :ok }
|
|
419
|
-
console.
|
|
419
|
+
expect(console).to receive(:status).with(:fail, false)
|
|
420
420
|
expect { console.task("") { :fatal }}.to raise_error(SystemExit)
|
|
421
421
|
end
|
|
422
422
|
|
data/spec/bovem/logger_spec.rb
CHANGED
|
@@ -45,7 +45,7 @@ describe Bovem::Logger do
|
|
|
45
45
|
|
|
46
46
|
before(:each) do
|
|
47
47
|
now = Time.now
|
|
48
|
-
Time.
|
|
48
|
+
allow(Time).to receive(:now).and_return(now)
|
|
49
49
|
@time = now.strftime("%Y/%b/%d %H:%M:%S")
|
|
50
50
|
end
|
|
51
51
|
|
|
@@ -81,21 +81,21 @@ describe Bovem::Logger do
|
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
describe ".get_real_file" do
|
|
84
|
-
it
|
|
84
|
+
it "should return the standard ouput" do
|
|
85
85
|
expect(::Bovem::Logger.get_real_file("STDOUT")).to eq($stdout )
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
-
it
|
|
88
|
+
it "should return the standard error" do
|
|
89
89
|
expect(::Bovem::Logger.get_real_file("STDERR")).to eq($stderr )
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
-
it
|
|
92
|
+
it "should return the file" do
|
|
93
93
|
expect(::Bovem::Logger.get_real_file("/dev/null")).to eq("/dev/null" )
|
|
94
94
|
end
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
describe ".default_file" do
|
|
98
|
-
it
|
|
98
|
+
it "should return the standard output" do
|
|
99
99
|
expect(::Bovem::Logger.default_file).to eq($stdout)
|
|
100
100
|
end
|
|
101
101
|
end
|
data/spec/bovem/shell_spec.rb
CHANGED
|
@@ -19,7 +19,7 @@ describe Bovem::Shell do
|
|
|
19
19
|
let(:temp_dir_2) { "/tmp/bovem-test-dir-2-#{Time.now.strftime("%Y%m%d-%H%M%S")}" }
|
|
20
20
|
|
|
21
21
|
before(:each) do
|
|
22
|
-
Kernel.
|
|
22
|
+
allow(Kernel).to receive(:puts).and_return(nil)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
describe ".instance" do
|
|
@@ -37,57 +37,57 @@ describe Bovem::Shell do
|
|
|
37
37
|
|
|
38
38
|
describe "#run" do
|
|
39
39
|
before(:each) do
|
|
40
|
-
::Open4
|
|
40
|
+
allow(::Open4).to receive(:popen4) do |_, _, _, _| OpenStruct.new(exitstatus: 0) end
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
it "should show a message" do
|
|
44
|
-
shell.console.
|
|
44
|
+
expect(shell.console).to receive("begin").with("MESSAGE")
|
|
45
45
|
shell.run("echo OK", "MESSAGE", true, false)
|
|
46
|
-
shell.console.
|
|
46
|
+
expect(shell.console).not_to receive("begin").with("MESSAGE")
|
|
47
47
|
shell.run("echo OK", nil, true, false)
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
it "should print the command line" do
|
|
51
|
-
shell.console.
|
|
51
|
+
expect(shell.console).to receive("info").with("Running command: {mark=bright}\"echo OK\"{/mark}...")
|
|
52
52
|
shell.run("echo OK", nil, true, false, false, true)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
it "should only print the command if requested to" do
|
|
56
|
-
shell.console.
|
|
57
|
-
::Open4.
|
|
56
|
+
expect(shell.console).to receive("warn").with("Will run command: {mark=bright}\"echo OK\"{/mark}...")
|
|
57
|
+
expect(::Open4).not_to receive("popen4")
|
|
58
58
|
shell.run("echo OK", nil, false, false)
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
it "should only execute a command" do
|
|
62
|
-
shell.console.
|
|
62
|
+
expect(shell.console).not_to receive("warn").with("Will run command: {mark=bright}\"echo OK\"{/mark}...")
|
|
63
63
|
shell.run("echo OK", nil, true, false)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
it "should show a exit message" do
|
|
67
67
|
i = -1
|
|
68
|
-
::Open4
|
|
68
|
+
allow(::Open4).to receive(:popen4) do |_, _, _, _|
|
|
69
69
|
i += 1
|
|
70
70
|
OpenStruct.new(exitstatus: i)
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
shell.console.
|
|
73
|
+
expect(shell.console).to receive(:status).with(:ok)
|
|
74
74
|
shell.run("echo OK", nil, true, true)
|
|
75
|
-
shell.console.
|
|
75
|
+
expect(shell.console).to receive(:status).with(:fail)
|
|
76
76
|
shell.run("echo1 OK", nil, true, true, false, false, false)
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
it "should print output" do
|
|
80
|
-
Kernel.
|
|
80
|
+
expect(Kernel).to receive("print").with("OK\n")
|
|
81
81
|
|
|
82
82
|
stdout = Object.new
|
|
83
|
-
stdout.
|
|
84
|
-
::Open4
|
|
83
|
+
allow(stdout).to receive(:each_line).and_yield("OK\n")
|
|
84
|
+
allow(::Open4).to receive(:popen4).and_yield(nil, nil, stdout, nil).and_return(OpenStruct.new(exitstatus: 0))
|
|
85
85
|
|
|
86
86
|
shell.run("echo OK", nil, true, false, true)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
it "should raise a exception for failures" do
|
|
90
|
-
::Open4
|
|
90
|
+
allow(::Open4).to receive(:popen4) {|_, _, _, _| OpenStruct.new(exitstatus: 1) }
|
|
91
91
|
expect { shell.run("echo1 OK", nil, true, false, false, false, false) }.not_to raise_error
|
|
92
92
|
expect { shell.run("echo1 OK", nil, true, false, false) }.to raise_error(SystemExit)
|
|
93
93
|
end
|
|
@@ -119,37 +119,37 @@ describe Bovem::Shell do
|
|
|
119
119
|
end
|
|
120
120
|
|
|
121
121
|
it "should only print the list of files" do
|
|
122
|
-
shell.console.
|
|
123
|
-
FileUtils.
|
|
122
|
+
expect(shell.console).to receive(:warn).with("Will remove file(s):")
|
|
123
|
+
expect(FileUtils).not_to receive(:rm_r)
|
|
124
124
|
expect(shell.delete(temp_file_1, false)).to be_true
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
it "should complain about non existing files" do
|
|
128
|
-
shell.console.
|
|
128
|
+
expect(shell.console).to receive(:error).with("Cannot remove following non existent file: {mark=bright}#{temp_file_1}{/mark}")
|
|
129
129
|
expect(shell.delete(temp_file_1, true, true, false)).to be_false
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
it "should complain about non writeable files" do
|
|
133
|
-
shell.console.
|
|
133
|
+
expect(shell.console).to receive(:error).with("Cannot remove following non writable file: {mark=bright}/dev/null{/mark}")
|
|
134
134
|
expect(shell.delete("/dev/null", true, true, false)).to be_false
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
it "should complain about other exceptions" do
|
|
138
|
-
FileUtils.
|
|
139
|
-
shell.console.
|
|
140
|
-
shell.console.
|
|
138
|
+
allow(FileUtils).to receive(:rm_r).and_raise(ArgumentError.new("ERROR"))
|
|
139
|
+
expect(shell.console).to receive(:error).with("Cannot remove following file(s):")
|
|
140
|
+
expect(shell.console).to receive(:write).at_least(2)
|
|
141
141
|
expect(shell.delete("/dev/null", true, true, false)).to be_false
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
describe "should exit when requested to" do
|
|
145
145
|
it "by calling :fatal" do
|
|
146
|
-
shell.console.
|
|
146
|
+
expect(shell.console).to receive(:fatal).with("Cannot remove following non writable file: {mark=bright}/dev/null{/mark}")
|
|
147
147
|
expect(shell.delete("/dev/null")).to be_false
|
|
148
148
|
end
|
|
149
149
|
|
|
150
150
|
it "by calling Kernel#exit" do
|
|
151
|
-
FileUtils.
|
|
152
|
-
Kernel.
|
|
151
|
+
allow(FileUtils).to receive(:rm_r).and_raise(ArgumentError.new("ERROR"))
|
|
152
|
+
expect(Kernel).to receive(:exit).with(-1)
|
|
153
153
|
expect(shell.delete("/dev/null", true, true)).to be_false
|
|
154
154
|
end
|
|
155
155
|
end
|
|
@@ -217,10 +217,10 @@ describe Bovem::Shell do
|
|
|
217
217
|
end
|
|
218
218
|
|
|
219
219
|
it "should complain about non existing source" do
|
|
220
|
-
shell.console.
|
|
220
|
+
expect(shell.console).to receive(:error).with("Cannot copy non existent file {mark=bright}#{temp_file_1}{/mark}.")
|
|
221
221
|
expect(shell.copy_or_move(temp_file_1, temp_file_2, :copy, true, false, false)).to be_false
|
|
222
222
|
|
|
223
|
-
shell.console.
|
|
223
|
+
expect(shell.console).to receive(:error).with("Cannot move non existent file {mark=bright}#{temp_file_1}{/mark}.")
|
|
224
224
|
expect(shell.copy_or_move(temp_file_1, temp_file_2, :move, true, false, false)).to be_false
|
|
225
225
|
end
|
|
226
226
|
|
|
@@ -228,77 +228,77 @@ describe Bovem::Shell do
|
|
|
228
228
|
File.open(temp_file_1, "w") {|f| f.write("OK") }
|
|
229
229
|
shell.create_directories(temp_file_2)
|
|
230
230
|
|
|
231
|
-
shell.console.
|
|
231
|
+
expect(shell.console).to receive(:error).with("Cannot copy file {mark=bright}#{temp_file_1}{/mark} to {mark=bright}#{temp_file_2}{/mark} because it is currently a directory.")
|
|
232
232
|
expect(shell.copy_or_move(temp_file_1, temp_file_2, :copy, true, false, false)).to be_false
|
|
233
233
|
|
|
234
|
-
shell.console.
|
|
234
|
+
expect(shell.console).to receive(:error).with("Cannot move file {mark=bright}#{temp_file_1}{/mark} to {mark=bright}#{temp_file_2}{/mark} because it is currently a directory.")
|
|
235
235
|
expect(shell.copy_or_move(temp_file_1, temp_file_2, :move, true, false, false)).to be_false
|
|
236
236
|
end
|
|
237
237
|
|
|
238
238
|
it "should create the parent directory if needed" do
|
|
239
239
|
expect(shell.check(temp_dir_1, :dir)).to be_false
|
|
240
240
|
|
|
241
|
-
shell.
|
|
241
|
+
expect(shell).to receive(:create_directories).exactly(2)
|
|
242
242
|
expect(shell.copy_or_move(temp_file_1, temp_dir_1 + "/test-1", :copy)).to be_false
|
|
243
243
|
expect(shell.copy_or_move(temp_file_1, temp_dir_1 + "/test-1", :move)).to be_false
|
|
244
244
|
end
|
|
245
245
|
|
|
246
246
|
it "should only print the list of files" do
|
|
247
|
-
FileUtils.
|
|
248
|
-
FileUtils.
|
|
247
|
+
expect(FileUtils).not_to receive(:cp_r)
|
|
248
|
+
expect(FileUtils).not_to receive(:mv)
|
|
249
249
|
|
|
250
|
-
shell.console.
|
|
250
|
+
expect(shell.console).to receive(:warn).with("Will copy a file:")
|
|
251
251
|
expect(shell.copy_or_move(temp_file_1, temp_file_2, :copy, false)).to be_true
|
|
252
|
-
shell.console.
|
|
252
|
+
expect(shell.console).to receive(:warn).with("Will copy following entries:")
|
|
253
253
|
expect(shell.copy_or_move([temp_file_1, temp_file_2], temp_dir_1, :copy, false)).to be_true
|
|
254
254
|
|
|
255
|
-
shell.console.
|
|
255
|
+
expect(shell.console).to receive(:warn).with("Will move a file:")
|
|
256
256
|
expect(shell.copy_or_move(temp_file_1, temp_file_2, :move, false)).to be_true
|
|
257
|
-
shell.console.
|
|
257
|
+
expect(shell.console).to receive(:warn).with("Will move following entries:")
|
|
258
258
|
expect(shell.copy_or_move([temp_file_1, temp_file_2], temp_dir_1, :move, false)).to be_true
|
|
259
259
|
end
|
|
260
260
|
|
|
261
261
|
it "should complain about non writeable parent directory" do
|
|
262
262
|
File.open(temp_file_1, "w") {|f| f.write("OK") }
|
|
263
263
|
|
|
264
|
-
shell.console.
|
|
264
|
+
expect(shell.console).to receive(:error).with("Cannot copy file {mark=bright}#{temp_file_1}{/mark} to non writable directory {mark=bright}/dev{/mark}.", "\n", 5)
|
|
265
265
|
expect(shell.copy_or_move(temp_file_1, "/dev/bovem", :copy, true, true, false)).to be_false
|
|
266
266
|
|
|
267
|
-
shell.console.
|
|
267
|
+
expect(shell.console).to receive(:error).with("Cannot move file {mark=bright}#{temp_file_1}{/mark} to non writable directory {mark=bright}/dev{/mark}.", "\n", 5)
|
|
268
268
|
expect(shell.copy_or_move(temp_file_1, "/dev/bovem", :move, true, true, false)).to be_false
|
|
269
269
|
end
|
|
270
270
|
|
|
271
271
|
it "should complain about other exceptions" do
|
|
272
|
-
FileUtils.
|
|
273
|
-
FileUtils.
|
|
272
|
+
allow(FileUtils).to receive(:cp_r).and_raise(ArgumentError.new("ERROR"))
|
|
273
|
+
allow(FileUtils).to receive(:mv).and_raise(ArgumentError.new("ERROR"))
|
|
274
274
|
File.open(temp_file_1, "w") {|f| f.write("OK") }
|
|
275
275
|
|
|
276
|
-
shell.console.
|
|
276
|
+
expect(shell.console).to receive(:error).with("Cannot copy file {mark=bright}#{temp_file_1}{/mark} to directory {mark=bright}#{File.dirname(temp_file_2)}{/mark} due to this error: [ArgumentError] ERROR.", "\n", 5)
|
|
277
277
|
expect(shell.copy_or_move(temp_file_1, temp_file_2, :copy, true, true, false)).to be_false
|
|
278
278
|
|
|
279
|
-
shell.console.
|
|
279
|
+
expect(shell.console).to receive(:error).with("Cannot move file {mark=bright}#{temp_file_1}{/mark} to directory {mark=bright}#{File.dirname(temp_file_2)}{/mark} due to this error: [ArgumentError] ERROR.", "\n", 5)
|
|
280
280
|
expect(shell.copy_or_move(temp_file_1, temp_file_2, :move, true, true, false)).to be_false
|
|
281
281
|
end
|
|
282
282
|
|
|
283
283
|
describe "should exit when requested to" do
|
|
284
284
|
it "by calling :fatal" do
|
|
285
|
-
FileUtils.
|
|
286
|
-
FileUtils.
|
|
285
|
+
allow(FileUtils).to receive(:cp_r).and_raise(ArgumentError.new("ERROR"))
|
|
286
|
+
allow(FileUtils).to receive(:mv).and_raise(ArgumentError.new("ERROR"))
|
|
287
287
|
|
|
288
288
|
File.open(temp_file_1, "w") {|f| f.write("OK") }
|
|
289
289
|
File.open(temp_file_2, "w") {|f| f.write("OK") }
|
|
290
290
|
|
|
291
|
-
shell.console.
|
|
291
|
+
expect(shell.console).to receive(:fatal).with("Cannot copy file {mark=bright}#{temp_file_1}{/mark} to directory {mark=bright}/dev{/mark} due to this error: [ArgumentError] ERROR.", "\n", 5)
|
|
292
292
|
expect(shell.copy_or_move(temp_file_1, "/dev/bovem", :copy, true, true, true)).to be_false
|
|
293
293
|
|
|
294
|
-
shell.console.
|
|
294
|
+
expect(shell.console).to receive(:fatal).with("Cannot move file {mark=bright}#{temp_file_1}{/mark} to directory {mark=bright}/dev{/mark} due to this error: [ArgumentError] ERROR.", "\n", 5)
|
|
295
295
|
expect(shell.copy_or_move(temp_file_1, "/dev/bovem", :move, true, true, true)).to be_false
|
|
296
296
|
|
|
297
|
-
Kernel.
|
|
298
|
-
shell.console.
|
|
297
|
+
allow(Kernel).to receive(:exit).and_return(true)
|
|
298
|
+
expect(shell.console).to receive(:error).with("Cannot copy following entries to {mark=bright}/dev{/mark}:")
|
|
299
299
|
expect(shell.copy_or_move([temp_file_1, temp_file_2], "/dev", :copy, true, true, true)).to be_false
|
|
300
300
|
|
|
301
|
-
shell.console.
|
|
301
|
+
expect(shell.console).to receive(:error).with("Cannot move following entries to {mark=bright}/dev{/mark}:")
|
|
302
302
|
expect(shell.copy_or_move([temp_file_1, temp_file_2], "/dev", :move, true, true, true)).to be_false
|
|
303
303
|
end
|
|
304
304
|
|
|
@@ -306,7 +306,7 @@ describe Bovem::Shell do
|
|
|
306
306
|
File.open(temp_file_1, "w") {|f| f.write("OK") }
|
|
307
307
|
File.open(temp_file_2, "w") {|f| f.write("OK") }
|
|
308
308
|
|
|
309
|
-
Kernel.
|
|
309
|
+
expect(Kernel).to receive(:exit).with(-1).exactly(4).and_return(true)
|
|
310
310
|
expect(shell.copy_or_move(temp_file_1, "/dev/bovem", :copy, true, false, true)).to be_false
|
|
311
311
|
expect(shell.copy_or_move([temp_file_1, temp_file_2], "/dev", :copy, true, false, true)).to be_false
|
|
312
312
|
expect(shell.copy_or_move(temp_file_1, "/dev/bovem", :move, true, false, true)).to be_false
|
|
@@ -317,14 +317,14 @@ describe Bovem::Shell do
|
|
|
317
317
|
|
|
318
318
|
describe "#copy" do
|
|
319
319
|
it "should forward everything to #copy_or_move" do
|
|
320
|
-
shell.
|
|
320
|
+
expect(shell).to receive(:copy_or_move).with("A", "B", :copy, "C", "D", "E")
|
|
321
321
|
shell.copy("A", "B", "C", "D", "E")
|
|
322
322
|
end
|
|
323
323
|
end
|
|
324
324
|
|
|
325
325
|
describe "#move" do
|
|
326
326
|
it "should forward everything to #copy_or_move" do
|
|
327
|
-
shell.
|
|
327
|
+
expect(shell).to receive(:copy_or_move).with("A", "B", :move, "C", "D", "E")
|
|
328
328
|
shell.move("A", "B", "C", "D", "E")
|
|
329
329
|
end
|
|
330
330
|
end
|
|
@@ -364,7 +364,7 @@ describe Bovem::Shell do
|
|
|
364
364
|
end
|
|
365
365
|
|
|
366
366
|
it "should show messages" do
|
|
367
|
-
shell.console.
|
|
367
|
+
expect(shell.console).to receive(:info).with(/Moving (.*)into directory \{mark=bright\}(.+)\{\/mark\}/).exactly(2)
|
|
368
368
|
shell.within_directory(target, true, true) { "OK" }
|
|
369
369
|
end
|
|
370
370
|
|
|
@@ -374,11 +374,11 @@ describe Bovem::Shell do
|
|
|
374
374
|
expect(shell.within_directory("/invalid") { dir = "OK" }).to be_false
|
|
375
375
|
expect(dir).to eq("")
|
|
376
376
|
|
|
377
|
-
Dir.
|
|
377
|
+
allow(Dir).to receive(:chdir).and_raise(ArgumentError)
|
|
378
378
|
expect(shell.within_directory("/") { true }).to be_false
|
|
379
379
|
|
|
380
|
-
Dir.
|
|
381
|
-
Dir.
|
|
380
|
+
allow(Dir).to receive(:chdir)
|
|
381
|
+
allow(Dir).to receive(:pwd).and_return("/invalid")
|
|
382
382
|
expect(shell.within_directory("/") { true }).to be_false
|
|
383
383
|
end
|
|
384
384
|
end
|
|
@@ -407,45 +407,45 @@ describe Bovem::Shell do
|
|
|
407
407
|
end
|
|
408
408
|
|
|
409
409
|
it "should only print the list of files" do
|
|
410
|
-
shell.console.
|
|
411
|
-
FileUtils.
|
|
410
|
+
expect(shell.console).to receive(:warn).with("Will create directories:")
|
|
411
|
+
expect(FileUtils).not_to receive(:mkdir_p)
|
|
412
412
|
expect(shell.create_directories(temp_file_1, 0755, false)).to be_true
|
|
413
413
|
end
|
|
414
414
|
|
|
415
415
|
it "should complain about directory already existing" do
|
|
416
416
|
shell.create_directories(temp_dir_1, 0755, true, false, false)
|
|
417
|
-
shell.console.
|
|
417
|
+
expect(shell.console).to receive(:error).with("The directory {mark=bright}#{temp_dir_1}{/mark} already exists.")
|
|
418
418
|
expect(shell.create_directories(temp_dir_1, 0755, true, false, false)).to be_false
|
|
419
419
|
end
|
|
420
420
|
|
|
421
421
|
it "should complain about paths already existing as a file." do
|
|
422
422
|
File.open(temp_file_1, "w") {|f| f.write("OK") }
|
|
423
423
|
|
|
424
|
-
shell.console.
|
|
424
|
+
expect(shell.console).to receive(:error).with("Path {mark=bright}#{temp_file_1}{/mark} is currently a file.")
|
|
425
425
|
expect(shell.create_directories(temp_file_1, 0755, true, false, false)).to be_false
|
|
426
426
|
end
|
|
427
427
|
|
|
428
428
|
it "should complain about non writable parents" do
|
|
429
|
-
shell.console.
|
|
429
|
+
expect(shell.console).to receive(:error).with("Cannot create following directory due to permission denied: {mark=bright}/dev/bovem{/mark}.")
|
|
430
430
|
expect(shell.create_directories("/dev/bovem", 0755, true, false, false)).to be_false
|
|
431
431
|
end
|
|
432
432
|
|
|
433
433
|
it "should complain about other exceptions" do
|
|
434
|
-
FileUtils.
|
|
435
|
-
shell.console.
|
|
436
|
-
shell.console.
|
|
434
|
+
allow(FileUtils).to receive(:mkdir_p).and_raise(ArgumentError.new("ERROR"))
|
|
435
|
+
expect(shell.console).to receive(:error).with("Cannot create following directories:")
|
|
436
|
+
expect(shell.console).to receive(:write).at_least(2)
|
|
437
437
|
expect(shell.create_directories(temp_dir_1, 0755, true, true, false)).to be_false
|
|
438
438
|
end
|
|
439
439
|
|
|
440
440
|
describe "should exit when requested to" do
|
|
441
441
|
it "by calling :fatal" do
|
|
442
|
-
shell.console.
|
|
442
|
+
expect(shell.console).to receive(:fatal).with("Path {mark=bright}/dev/null{/mark} is currently a file.")
|
|
443
443
|
expect(shell.create_directories("/dev/null")).to be_false
|
|
444
444
|
end
|
|
445
445
|
|
|
446
446
|
it "by calling Kernel#exit" do
|
|
447
|
-
FileUtils.
|
|
448
|
-
Kernel.
|
|
447
|
+
allow(FileUtils).to receive(:mkdir_p).and_raise(ArgumentError.new("ERROR"))
|
|
448
|
+
expect(Kernel).to receive(:exit).with(-1)
|
|
449
449
|
expect(shell.create_directories(temp_dir_1, 0755, true, true)).to be_false
|
|
450
450
|
end
|
|
451
451
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bovem
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.3.
|
|
4
|
+
version: 2.3.7
|
|
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: 2013-07-
|
|
12
|
+
date: 2013-07-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: lazier
|
|
@@ -18,7 +18,7 @@ dependencies:
|
|
|
18
18
|
requirements:
|
|
19
19
|
- - ~>
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: 3.2.
|
|
21
|
+
version: 3.2.6
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -26,7 +26,7 @@ dependencies:
|
|
|
26
26
|
requirements:
|
|
27
27
|
- - ~>
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: 3.2.
|
|
29
|
+
version: 3.2.6
|
|
30
30
|
- !ruby/object:Gem::Dependency
|
|
31
31
|
name: open4
|
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
130
130
|
version: '0'
|
|
131
131
|
segments:
|
|
132
132
|
- 0
|
|
133
|
-
hash:
|
|
133
|
+
hash: 4382808554281169718
|
|
134
134
|
requirements: []
|
|
135
135
|
rubyforge_project: bovem
|
|
136
136
|
rubygems_version: 1.8.25
|