bovem 3.0.5 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -3
  3. data/.rubocop.yml +82 -0
  4. data/.travis-gemfile +4 -5
  5. data/.travis.yml +8 -6
  6. data/CHANGELOG.md +12 -0
  7. data/Gemfile +9 -8
  8. data/README.md +1 -1
  9. data/Rakefile +22 -6
  10. data/bovem.gemspec +5 -5
  11. data/doc/Bovem.html +10 -10
  12. data/doc/Bovem/Application.html +670 -318
  13. data/doc/Bovem/Command.html +1447 -1125
  14. data/doc/Bovem/CommandMethods.html +4 -4
  15. data/doc/Bovem/CommandMethods/Children.html +173 -179
  16. data/doc/Bovem/CommandMethods/Help.html +9 -9
  17. data/doc/Bovem/Configuration.html +239 -24
  18. data/doc/Bovem/Console.html +267 -128
  19. data/doc/Bovem/ConsoleMethods.html +4 -4
  20. data/doc/Bovem/ConsoleMethods/Interactions.html +57 -70
  21. data/doc/Bovem/ConsoleMethods/Interactions/ClassMethods.html +9 -9
  22. data/doc/Bovem/ConsoleMethods/Logging.html +258 -298
  23. data/doc/Bovem/ConsoleMethods/Logging/ClassMethods.html +8 -8
  24. data/doc/Bovem/ConsoleMethods/Output.html +96 -118
  25. data/doc/Bovem/ConsoleMethods/StyleHandling.html +8 -8
  26. data/doc/Bovem/ConsoleMethods/StyleHandling/ClassMethods.html +26 -39
  27. data/doc/Bovem/Errors.html +4 -4
  28. data/doc/Bovem/Errors/Error.html +4 -4
  29. data/doc/Bovem/Errors/InvalidConfiguration.html +4 -4
  30. data/doc/Bovem/Errors/InvalidLogger.html +4 -4
  31. data/doc/Bovem/I18n.html +175 -0
  32. data/doc/Bovem/Logger.html +95 -83
  33. data/doc/Bovem/Option.html +669 -862
  34. data/doc/Bovem/Parser.html +10 -10
  35. data/doc/Bovem/ParserMethods.html +4 -4
  36. data/doc/Bovem/ParserMethods/General.html +4 -4
  37. data/doc/Bovem/ParserMethods/General/ClassMethods.html +26 -38
  38. data/doc/Bovem/Shell.html +169 -48
  39. data/doc/Bovem/ShellMethods.html +4 -4
  40. data/doc/Bovem/ShellMethods/Directories.html +46 -62
  41. data/doc/Bovem/ShellMethods/Execute.html +51 -99
  42. data/doc/Bovem/ShellMethods/General.html +4 -445
  43. data/doc/Bovem/ShellMethods/Read.html +56 -61
  44. data/doc/Bovem/ShellMethods/Write.html +22 -242
  45. data/doc/Bovem/Version.html +6 -6
  46. data/doc/_index.html +18 -18
  47. data/doc/class_list.html +6 -2
  48. data/doc/css/style.css +1 -0
  49. data/doc/file.README.html +5 -5
  50. data/doc/file_list.html +5 -1
  51. data/doc/frames.html +1 -1
  52. data/doc/index.html +5 -5
  53. data/doc/js/full_list.js +4 -1
  54. data/doc/method_list.html +161 -157
  55. data/doc/top-level-namespace.html +4 -4
  56. data/lib/bovem.rb +3 -4
  57. data/lib/bovem/application.rb +47 -39
  58. data/lib/bovem/command.rb +175 -193
  59. data/lib/bovem/configuration.rb +28 -29
  60. data/lib/bovem/console.rb +244 -171
  61. data/lib/bovem/errors.rb +1 -1
  62. data/lib/bovem/i18n.rb +18 -0
  63. data/lib/bovem/logger.rb +26 -26
  64. data/lib/bovem/option.rb +49 -58
  65. data/lib/bovem/parser.rb +174 -222
  66. data/lib/bovem/shell.rb +272 -320
  67. data/lib/bovem/version.rb +2 -2
  68. data/locales/en.yml +39 -38
  69. data/locales/it.yml +39 -38
  70. data/spec/bovem/application_spec.rb +6 -5
  71. data/spec/bovem/command_spec.rb +23 -23
  72. data/spec/bovem/console_spec.rb +101 -102
  73. data/spec/bovem/i18n_spec.rb +21 -0
  74. data/spec/bovem/logger_spec.rb +4 -4
  75. data/spec/bovem/option_spec.rb +43 -43
  76. data/spec/bovem/parser_spec.rb +13 -13
  77. data/spec/bovem/shell_spec.rb +106 -115
  78. data/spec/spec_helper.rb +19 -6
  79. metadata +14 -13
  80. data/doc/Bovem/Localizer.html +0 -376
  81. data/lib/bovem/localizer.rb +0 -27
  82. data/spec/coverage_helper.rb +0 -20
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+ #
3
+ # This file is part of the bovem gem. Copyright (C) 2013 and above Shogun <shogun@cowtech.it>.
4
+ # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
+ #
6
+
7
+ require "spec_helper"
8
+
9
+ describe Bovem::I18n do
10
+ let(:subject) { Bovem::I18n.new(:it, root: "bovem.shell", path: Bovem::Application::LOCALE_ROOT) }
11
+
12
+ describe "#method_missing" do
13
+ it "should find translation and format them" do
14
+ expect(subject.copy_move_single_to_directory("A", "B", "C")).to eq("Impossibile eseguire A del file {mark=bright}B{/mark} in {mark=bright}C{/mark} perché è attualmente una cartella.")
15
+ end
16
+
17
+ it "should complain about missing translation" do
18
+ expect { subject.foo }.to raise_error(Lazier::Exceptions::MissingTranslation, "Unable to load the translation \"bovem.shell.foo\" for the locale \"it\".")
19
+ end
20
+ end
21
+ end
@@ -20,15 +20,15 @@ describe Bovem::Logger do
20
20
  end
21
21
 
22
22
  it "should create a logger with a custom file and level" do
23
- logger = Bovem::Logger.create("/dev/null", ::Logger::WARN)
23
+ logger = Bovem::Logger.create("/dev/null", level: ::Logger::WARN)
24
24
  expect(logger.device).to eq("/dev/null")
25
25
  expect(logger.level).to eq(::Logger::WARN)
26
26
  expect(logger.formatter).to eq(Bovem::Logger.default_formatter)
27
27
  end
28
28
 
29
29
  it "should create a logger with a custom formatter" do
30
- formatter = Proc.new {|severity, datetime, progname, msg| msg }
31
- logger = Bovem::Logger.create("/dev/null", ::Logger::WARN, formatter)
30
+ formatter = Proc.new {|_, _, _, msg| msg }
31
+ logger = Bovem::Logger.create("/dev/null", level: ::Logger::WARN, formatter: formatter)
32
32
  expect(logger.device).to eq("/dev/null")
33
33
  expect(logger.level).to eq(::Logger::WARN)
34
34
  expect(logger.formatter).to eq(formatter)
@@ -41,7 +41,7 @@ describe Bovem::Logger do
41
41
 
42
42
  describe ".default_formatter" do
43
43
  let(:output) { ::StringIO.new }
44
- let(:logger) { Bovem::Logger.create(output, Logger::DEBUG) }
44
+ let(:logger) { Bovem::Logger.create(output, level: Logger::DEBUG) }
45
45
 
46
46
  def get_last_line(buffer)
47
47
  buffer.string.split("\n").last.strip.gsub(/ T\+\d+\.\d+/, "")
@@ -46,7 +46,7 @@ describe Bovem::Option do
46
46
 
47
47
  it "should set options" do
48
48
  option = Bovem::Option.new("NAME", ["O", "OPTION"], {required: true, help: "HELP", unused: "UNUSED"})
49
- expect(option.help).to be_true
49
+ expect(option.help).to be_truthy
50
50
  expect(option.help).to eq("HELP")
51
51
  end
52
52
  end
@@ -164,74 +164,74 @@ describe Bovem::Option do
164
164
 
165
165
  describe "#set" do
166
166
  it "should set the value" do
167
- expect(option.set("VALUE")).to be_true
167
+ expect(option.set("VALUE")).to be_truthy
168
168
  expect(option.value).to eq("VALUE")
169
- expect(option.provided?).to be_true
169
+ expect(option.provided?).to be_truthy
170
170
  end
171
171
 
172
172
  it "should match against a regexp validator" do
173
173
  option.validator = /^A|B$/
174
174
 
175
175
  expect{ option.set("VALUE") }.to raise_error(Bovem::Errors::Error)
176
- expect(option.value).to be_false
177
- expect(option.provided?).to be_false
176
+ expect(option.value).to be_falsey
177
+ expect(option.provided?).to be_falsey
178
178
 
179
- expect(option.set("VALUE", false)).to be_false
180
- expect(option.value).to be_false
181
- expect(option.provided?).to be_false
179
+ expect(option.set("VALUE", false)).to be_falsey
180
+ expect(option.value).to be_falsey
181
+ expect(option.provided?).to be_falsey
182
182
 
183
183
  option.set("A")
184
184
  expect(option.value).to eq("A")
185
- expect(option.provided?).to be_true
185
+ expect(option.provided?).to be_truthy
186
186
 
187
187
  option.set("B")
188
188
  expect(option.value).to eq("B")
189
- expect(option.provided?).to be_true
189
+ expect(option.provided?).to be_truthy
190
190
  end
191
191
 
192
192
  it "should match against an array validator" do
193
193
  option.validator = ["A", "B"]
194
194
 
195
195
  expect{ option.set("VALUE") }.to raise_error(Bovem::Errors::Error)
196
- expect(option.value).to be_false
197
- expect(option.provided?).to be_false
196
+ expect(option.value).to be_falsey
197
+ expect(option.provided?).to be_falsey
198
198
 
199
- expect(option.set("VALUE", false)).to be_false
200
- expect(option.value).to be_false
201
- expect(option.provided?).to be_false
199
+ expect(option.set("VALUE", false)).to be_falsey
200
+ expect(option.value).to be_falsey
201
+ expect(option.provided?).to be_falsey
202
202
 
203
203
  option.set("A")
204
204
  expect(option.value).to eq("A")
205
- expect(option.provided?).to be_true
205
+ expect(option.provided?).to be_truthy
206
206
 
207
207
  option.set("B")
208
208
  expect(option.value).to eq("B")
209
- expect(option.provided?).to be_true
209
+ expect(option.provided?).to be_truthy
210
210
 
211
211
  option.validator = [1, 2]
212
212
  expect{ option.set("VALUE") }.to raise_error(Bovem::Errors::Error)
213
- expect(option.value).to be_false
214
- expect(option.provided?).to be_false
213
+ expect(option.value).to be_falsey
214
+ expect(option.provided?).to be_falsey
215
215
 
216
216
  option.set(1)
217
217
  expect(option.value).to eq(1)
218
- expect(option.provided?).to be_true
218
+ expect(option.provided?).to be_truthy
219
219
  end
220
220
 
221
221
  it "should match against a Proc validator" do
222
222
  option.validator = ->(v) { v % 2 == 0 }
223
223
 
224
224
  expect{ option.set(1) }.to raise_error(Bovem::Errors::Error)
225
- expect(option.value).to be_false
226
- expect(option.provided?).to be_false
225
+ expect(option.value).to be_falsey
226
+ expect(option.provided?).to be_falsey
227
227
 
228
228
  option.set(2)
229
229
  expect(option.value).to eq(2)
230
- expect(option.provided?).to be_true
230
+ expect(option.provided?).to be_truthy
231
231
 
232
232
  option.set(4)
233
233
  expect(option.value).to eq(4)
234
- expect(option.provided?).to be_true
234
+ expect(option.provided?).to be_truthy
235
235
  end
236
236
  end
237
237
 
@@ -241,42 +241,42 @@ describe Bovem::Option do
241
241
  option = Bovem::Option.new("NAME") { |_, _| check = true }
242
242
  option.execute_action
243
243
 
244
- expect(check).to be_true
245
- expect(option.provided?).to be_true
244
+ expect(check).to be_truthy
245
+ expect(option.provided?).to be_truthy
246
246
  end
247
247
 
248
248
  it "should result in a no-op if the action is missing or doesn't take enough arguments" do
249
249
  option.execute_action
250
- expect(option.provided?).to be_false
250
+ expect(option.provided?).to be_falsey
251
251
 
252
252
  option = Bovem::Option.new("NAME")
253
- expect(option.provided?).to be_false
253
+ expect(option.provided?).to be_falsey
254
254
  end
255
255
  end
256
256
 
257
257
  describe "#requires_argument?" do
258
258
  it "should check if the option requires argument" do
259
- expect(Bovem::Option.new("NAME", []).requires_argument?).to be_false
260
- expect(Bovem::Option.new("NAME", [], {type: String}).requires_argument?).to be_true
261
- expect(Bovem::Option.new("NAME", [], {type: Integer}).requires_argument?).to be_true
262
- expect(Bovem::Option.new("NAME", [], {type: Float}).requires_argument?).to be_true
263
- expect(Bovem::Option.new("NAME", [], {type: Array}).requires_argument?).to be_true
264
- expect(Bovem::Option.new("NAME").requires_argument?).to be_false
259
+ expect(Bovem::Option.new("NAME", []).requires_argument?).to be_falsey
260
+ expect(Bovem::Option.new("NAME", [], {type: String}).requires_argument?).to be_truthy
261
+ expect(Bovem::Option.new("NAME", [], {type: Integer}).requires_argument?).to be_truthy
262
+ expect(Bovem::Option.new("NAME", [], {type: Float}).requires_argument?).to be_truthy
263
+ expect(Bovem::Option.new("NAME", [], {type: Array}).requires_argument?).to be_truthy
264
+ expect(Bovem::Option.new("NAME").requires_argument?).to be_falsey
265
265
  end
266
266
  end
267
267
 
268
268
  describe "#provided?" do
269
269
  it "should check if the option was provided" do
270
- expect(Bovem::Option.new("NAME").provided?).to be_false
270
+ expect(Bovem::Option.new("NAME").provided?).to be_falsey
271
271
  option.set(true)
272
- expect(option.provided?).to be_true
272
+ expect(option.provided?).to be_truthy
273
273
  end
274
274
  end
275
275
 
276
- describe "#has_help?" do
276
+ describe "#help?" do
277
277
  it "should check if the option has a help" do
278
- expect(Bovem::Option.new("NAME").has_help?).to be_false
279
- expect(Bovem::Option.new("NAME", [], help: "HELP").has_help?).to be_true
278
+ expect(Bovem::Option.new("NAME").help?).to be_falsey
279
+ expect(Bovem::Option.new("NAME", [], help: "HELP").help?).to be_truthy
280
280
  end
281
281
  end
282
282
 
@@ -286,18 +286,18 @@ describe Bovem::Option do
286
286
  expect(option.value).to eq("DEFAULT VALUE")
287
287
 
288
288
  option.default = nil
289
- expect(option.value).to be_false
289
+ expect(option.value).to be_falsey
290
290
 
291
291
  option.set(true)
292
- expect(option.value).to be_true
292
+ expect(option.value).to be_truthy
293
293
 
294
294
  option.set("VALUE")
295
295
  expect(option.value).to eq("VALUE")
296
296
  end
297
297
 
298
298
  it "should return good defaults" do
299
- expect(Bovem::Option.new("NAME").value).to be_false
300
- expect(Bovem::Option.new("NAME", [], {type: Regexp}).value).to be_false
299
+ expect(Bovem::Option.new("NAME").value).to be_falsey
300
+ expect(Bovem::Option.new("NAME", [], {type: Regexp}).value).to be_falsey
301
301
  expect(Bovem::Option.new("NAME", [], {type: String}).value).to eq("")
302
302
  expect(Bovem::Option.new("NAME", [], {type: Integer}).value).to eq(0)
303
303
  expect(Bovem::Option.new("NAME", [], {type: Float}).value).to eq(0.0)
@@ -41,13 +41,13 @@ describe Bovem::Parser do
41
41
  describe ".smart_join" do
42
42
  it "should correctly join arrays" do
43
43
  expect(Bovem::Parser.smart_join([])).to eq("")
44
- expect(Bovem::Parser.smart_join(["A"], ", ", " and ", nil)).to eq("A")
45
- expect(Bovem::Parser.smart_join(1, ", ", " and ", nil)).to eq("1")
46
- expect(Bovem::Parser.smart_join(["A", 1], ", ", " and ", nil)).to eq("A and 1")
47
- expect(Bovem::Parser.smart_join(["A", 1, true], ", ", " and ", nil)).to eq("A, 1 and true")
48
- expect(Bovem::Parser.smart_join(["A", "B", "C"], "-", " and ", nil)).to eq("A-B and C")
49
- expect(Bovem::Parser.smart_join(["A", "B", "C"], "-", "@", nil)).to eq("A-B@C")
50
- expect(Bovem::Parser.smart_join(["A", "B", "C"], ", ", " and ", "@")).to eq("@A@, @B@ and @C@")
44
+ expect(Bovem::Parser.smart_join(["A"], quote: nil)).to eq("A")
45
+ expect(Bovem::Parser.smart_join(1, quote: nil)).to eq("1")
46
+ expect(Bovem::Parser.smart_join(["A", 1], quote: nil)).to eq("A and 1")
47
+ expect(Bovem::Parser.smart_join(["A", 1, true], quote: nil)).to eq("A, 1 and true")
48
+ expect(Bovem::Parser.smart_join(["A", "B", "C"], separator: "-", last_separator: " and ", quote: nil)).to eq("A-B and C")
49
+ expect(Bovem::Parser.smart_join(["A", "B", "C"], separator: "-", last_separator: "@", quote: nil)).to eq("A-B@C")
50
+ expect(Bovem::Parser.smart_join(["A", "B", "C"], quote: "@")).to eq("@A@, @B@ and @C@")
51
51
  end
52
52
  end
53
53
 
@@ -58,12 +58,12 @@ describe Bovem::Parser do
58
58
  s2 = command.command("abd")
59
59
  s1.command("def")
60
60
 
61
- expect(Bovem::Parser.find_command("abc", command, args)).to eq({name: "abc", args: args})
62
- expect(Bovem::Parser.find_command("abc:def", command, args)).to eq({name: "abc", args: ["def"] + args})
63
- expect(Bovem::Parser.find_command("abc def", command, args, " ")).to eq({name: "abc", args: ["def"] + args})
64
- expect(Bovem::Parser.find_command("d", s1, args)).to eq({name: "def", args: args})
65
- expect{ Bovem::Parser.find_command("ab", command, args) }.to raise_error(Bovem::Errors::Error)
66
- expect(Bovem::Parser.find_command("abc", s2, args)).to be_nil
61
+ expect(Bovem::Parser.find_command("abc", command, args: args)).to eq({name: "abc", args: args})
62
+ expect(Bovem::Parser.find_command("abc:def", command, args: args)).to eq({name: "abc", args: ["def"] + args})
63
+ expect(Bovem::Parser.find_command("abc def", command, args: args, separator: " ")).to eq({name: "abc", args: ["def"] + args})
64
+ expect(Bovem::Parser.find_command("d", s1, args: args)).to eq({name: "def", args: args})
65
+ expect{ Bovem::Parser.find_command("ab", command, args: args) }.to raise_error(Bovem::Errors::Error)
66
+ expect(Bovem::Parser.find_command("abc", s2, args: args)).to be_nil
67
67
  end
68
68
  end
69
69
 
@@ -7,11 +7,7 @@
7
7
  require "spec_helper"
8
8
 
9
9
  describe Bovem::Shell do
10
- let(:shell) {
11
- s = Bovem::Shell.new
12
- s.i18n = :en
13
- s
14
- }
10
+ let(:shell) { Bovem::Shell.new }
15
11
  let(:temp_file_1) { "/tmp/bovem-test-1-#{Time.now.strftime("%Y%m%d-%H%M%S")}" }
16
12
  let(:temp_file_2) { "/tmp/bovem-test-2-#{Time.now.strftime("%Y%m%d-%H%M%S")}" }
17
13
  let(:temp_file_3) { "/tmp/bovem-test-3-#{Time.now.strftime("%Y%m%d-%H%M%S")}" }
@@ -42,25 +38,20 @@ describe Bovem::Shell do
42
38
 
43
39
  it "should show a message" do
44
40
  expect(shell.console).to receive("begin").with("MESSAGE")
45
- shell.run("echo OK", "MESSAGE", true, false)
41
+ shell.run("echo OK", "MESSAGE", show_exit: false)
46
42
  expect(shell.console).not_to receive("begin").with("MESSAGE")
47
- shell.run("echo OK", nil, true, false)
43
+ shell.run("echo OK", show_exit: false)
48
44
  end
49
45
 
50
46
  it "should print the command line" do
51
47
  expect(shell.console).to receive("info").with("Running command: {mark=bright}\"echo OK\"{/mark}...")
52
- shell.run("echo OK", nil, true, false, false, true)
48
+ shell.run("echo OK", show_exit: true, show_command: true)
53
49
  end
54
50
 
55
51
  it "should only print the command if requested to" do
56
52
  expect(shell.console).to receive("warn").with("Will run command: {mark=bright}\"echo OK\"{/mark}...")
57
53
  expect(::Open4).not_to receive("popen4")
58
- shell.run("echo OK", nil, false, false)
59
- end
60
-
61
- it "should only execute a command" do
62
- expect(shell.console).not_to receive("warn").with("Will run command: {mark=bright}\"echo OK\"{/mark}...")
63
- shell.run("echo OK", nil, true, false)
54
+ shell.run("echo OK", run: false)
64
55
  end
65
56
 
66
57
  it "should show a exit message" do
@@ -71,9 +62,9 @@ describe Bovem::Shell do
71
62
  end
72
63
 
73
64
  expect(shell.console).to receive(:status).with(:ok)
74
- shell.run("echo OK", nil, true, true)
65
+ shell.run("echo OK", show_exit: true, fatal_errors: false)
75
66
  expect(shell.console).to receive(:status).with(:fail)
76
- shell.run("echo1 OK", nil, true, true, false, false, false)
67
+ shell.run("echo1 OK", show_exit: true, fatal_errors: false)
77
68
  end
78
69
 
79
70
  it "should print output" do
@@ -83,27 +74,27 @@ describe Bovem::Shell do
83
74
  allow(stdout).to receive(:each_line).and_yield("OK\n")
84
75
  allow(::Open4).to receive(:popen4).and_yield(nil, nil, stdout, nil).and_return(OpenStruct.new(exitstatus: 0))
85
76
 
86
- shell.run("echo OK", nil, true, false, true)
77
+ shell.run("echo OK", show_output: true)
87
78
  end
88
79
 
89
80
  it "should raise a exception for failures" do
90
81
  allow(::Open4).to receive(:popen4) {|_, _, _, _| OpenStruct.new(exitstatus: 1) }
91
- expect { shell.run("echo1 OK", nil, true, false, false, false, false) }.not_to raise_error
92
- expect { shell.run("echo1 OK", nil, true, false, false) }.to raise_error(SystemExit)
82
+ expect { shell.run("echo1 OK", fatal_errors: false) }.not_to raise_error
83
+ expect { shell.run("echo1 OK") }.to raise_error(SystemExit)
93
84
  end
94
85
  end
95
86
 
96
87
  describe "#check" do
97
88
  it "executes all tests" do
98
- expect(shell.check("/", [:read, :dir])).to be_true
99
- expect(shell.check("/dev/null", :write)).to be_true
100
- expect(shell.check("/bin/sh", [:execute, :exec])).to be_true
101
- expect(shell.check("/", [:read, :directory])).to be_true
102
- expect(shell.check("/", [:writable?, :directory?])).to be_false
89
+ expect(shell.check("/", :read, :dir)).to be_truthy
90
+ expect(shell.check("/dev/null", :write)).to be_truthy
91
+ expect(shell.check("/bin/sh", :execute, :exec)).to be_truthy
92
+ expect(shell.check("/", :read, :directory)).to be_truthy
93
+ expect(shell.check("/", :writable?, :directory?)).to be_falsey
103
94
  end
104
95
 
105
96
  it "returns false when some tests are invalid" do
106
- expect(shell.check("/", [:read, :none])).to be_false
97
+ expect(shell.check("/", :read, :none)).to be_falsey
107
98
  end
108
99
  end
109
100
 
@@ -112,45 +103,45 @@ describe Bovem::Shell do
112
103
  File.unlink(temp_file_1) if File.exists?(temp_file_1)
113
104
  File.open(temp_file_1, "w") {|f| f.write("OK") }
114
105
 
115
- expect(File.exists?(temp_file_1)).to be_true
116
- expect(shell.delete(temp_file_1, true, false)).to be_true
117
- expect(File.exists?(temp_file_1)).to be_false
106
+ expect(File.exists?(temp_file_1)).to be_truthy
107
+ expect(shell.delete(temp_file_1, show_errors: false)).to be_truthy
108
+ expect(File.exists?(temp_file_1)).to be_falsey
118
109
  File.unlink(temp_file_1) if File.exists?(temp_file_1)
119
110
  end
120
111
 
121
112
  it "should only print the list of files" do
122
113
  expect(shell.console).to receive(:warn).with("Will remove file(s):")
123
114
  expect(FileUtils).not_to receive(:rm_r)
124
- expect(shell.delete(temp_file_1, false)).to be_true
115
+ expect(shell.delete(temp_file_1, run: false)).to be_truthy
125
116
  end
126
117
 
127
118
  it "should complain about non existing files" do
128
119
  expect(shell.console).to receive(:error).with("Cannot remove following non existent file: {mark=bright}#{temp_file_1}{/mark}")
129
- expect(shell.delete(temp_file_1, true, true, false)).to be_false
120
+ expect(shell.delete(temp_file_1, fatal_errors: false)).to be_falsey
130
121
  end
131
122
 
132
123
  it "should complain about non writeable files" do
133
124
  expect(shell.console).to receive(:error).with("Cannot remove following non writable file: {mark=bright}/dev/null{/mark}")
134
- expect(shell.delete("/dev/null", true, true, false)).to be_false
125
+ expect(shell.delete("/dev/null", fatal_errors: false)).to be_falsey
135
126
  end
136
127
 
137
128
  it "should complain about other exceptions" do
138
129
  allow(FileUtils).to receive(:rm_r).and_raise(ArgumentError.new("ERROR"))
139
130
  expect(shell.console).to receive(:error).with("Cannot remove following file(s):")
140
131
  expect(shell.console).to receive(:write).at_least(2)
141
- expect(shell.delete("/dev/null", true, true, false)).to be_false
132
+ expect(shell.delete("/dev/null", show_errors: true, fatal_errors: false)).to be_falsey
142
133
  end
143
134
 
144
135
  describe "should exit when requested to" do
145
136
  it "by calling :fatal" do
146
137
  expect(shell.console).to receive(:fatal).with("Cannot remove following non writable file: {mark=bright}/dev/null{/mark}")
147
- expect(shell.delete("/dev/null")).to be_false
138
+ expect(shell.delete("/dev/null")).to be_falsey
148
139
  end
149
140
 
150
141
  it "by calling Kernel#exit" do
151
142
  allow(FileUtils).to receive(:rm_r).and_raise(ArgumentError.new("ERROR"))
152
143
  expect(Kernel).to receive(:exit).with(-1)
153
- expect(shell.delete("/dev/null", true, true)).to be_false
144
+ expect(shell.delete("/dev/null", show_errors: true, fatal_errors: true)).to be_falsey
154
145
  end
155
146
  end
156
147
  end
@@ -174,16 +165,16 @@ describe Bovem::Shell do
174
165
 
175
166
  it "should copy a file" do
176
167
  File.open(temp_file_1, "w") {|f| f.write("OK") }
177
- expect(shell.copy_or_move(temp_file_1, temp_file_2, :copy)).to eq(true)
178
- expect(File.exists?(temp_file_1)).to be_true
179
- expect(File.exists?(temp_file_2)).to be_true
168
+ expect(shell.send(:copy_or_move, temp_file_1, temp_file_2, :copy)).to eq(true)
169
+ expect(File.exists?(temp_file_1)).to be_truthy
170
+ expect(File.exists?(temp_file_2)).to be_truthy
180
171
  end
181
172
 
182
173
  it "should move a file" do
183
174
  File.open(temp_file_1, "w") {|f| f.write("OK") }
184
- expect(shell.copy_or_move(temp_file_1, temp_file_2, :move, true)).to eq(true)
185
- expect(File.exists?(temp_file_1)).to be_false
186
- expect(File.exists?(temp_file_2)).to be_true
175
+ expect(shell.send(:copy_or_move, temp_file_1, temp_file_2, :move, true)).to eq(true)
176
+ expect(File.exists?(temp_file_1)).to be_falsey
177
+ expect(File.exists?(temp_file_2)).to be_truthy
187
178
  end
188
179
 
189
180
  it "should copy multiple entries" do
@@ -192,11 +183,11 @@ describe Bovem::Shell do
192
183
  shell.create_directories(temp_dir_1)
193
184
  File.open(temp_dir_1 + "/temp", "w") {|f| f.write("OK") }
194
185
 
195
- expect(shell.copy_or_move([temp_file_1, temp_file_2, temp_dir_1], temp_dir_2, :copy)).to be_true
196
- expect(File.exists?(temp_dir_2 + "/" + File.basename(temp_file_1))).to be_true
197
- expect(File.exists?(temp_dir_2 + "/" + File.basename(temp_file_2))).to be_true
198
- expect(File.exists?(temp_dir_2 + "/" + File.basename(temp_dir_1))).to be_true
199
- expect(File.exists?(temp_dir_2 + "/" + File.basename(temp_dir_1) + "/temp")).to be_true
186
+ expect(shell.send(:copy_or_move, [temp_file_1, temp_file_2, temp_dir_1], temp_dir_2, :copy)).to be_truthy
187
+ expect(File.exists?(temp_dir_2 + "/" + File.basename(temp_file_1))).to be_truthy
188
+ expect(File.exists?(temp_dir_2 + "/" + File.basename(temp_file_2))).to be_truthy
189
+ expect(File.exists?(temp_dir_2 + "/" + File.basename(temp_dir_1))).to be_truthy
190
+ expect(File.exists?(temp_dir_2 + "/" + File.basename(temp_dir_1) + "/temp")).to be_truthy
200
191
  end
201
192
 
202
193
  it "should move multiple entries" do
@@ -205,23 +196,23 @@ describe Bovem::Shell do
205
196
  shell.create_directories(temp_dir_1)
206
197
  File.open(temp_dir_1 + "/temp", "w") {|f| f.write("OK") }
207
198
 
208
- expect(shell.copy_or_move([temp_file_1, temp_file_2, temp_dir_1], temp_dir_2, :move, true)).to be_true
209
- expect(File.exists?(temp_dir_2 + "/" + File.basename(temp_file_1))).to be_true
210
- expect(File.exists?(temp_dir_2 + "/" + File.basename(temp_file_2))).to be_true
211
- expect(File.exists?(temp_dir_2 + "/" + File.basename(temp_dir_1))).to be_true
212
- expect(File.exists?(temp_dir_2 + "/" + File.basename(temp_dir_1) + "/temp")).to be_true
213
- expect(File.exists?(temp_file_1)).to be_false
214
- expect(File.exists?(temp_file_2)).to be_false
215
- expect(File.exists?(temp_dir_1)).to be_false
216
- expect(File.exists?(temp_dir_1 + "/temp")).to be_false
199
+ expect(shell.send(:copy_or_move, [temp_file_1, temp_file_2, temp_dir_1], temp_dir_2, :move, true)).to be_truthy
200
+ expect(File.exists?(temp_dir_2 + "/" + File.basename(temp_file_1))).to be_truthy
201
+ expect(File.exists?(temp_dir_2 + "/" + File.basename(temp_file_2))).to be_truthy
202
+ expect(File.exists?(temp_dir_2 + "/" + File.basename(temp_dir_1))).to be_truthy
203
+ expect(File.exists?(temp_dir_2 + "/" + File.basename(temp_dir_1) + "/temp")).to be_truthy
204
+ expect(File.exists?(temp_file_1)).to be_falsey
205
+ expect(File.exists?(temp_file_2)).to be_falsey
206
+ expect(File.exists?(temp_dir_1)).to be_falsey
207
+ expect(File.exists?(temp_dir_1 + "/temp")).to be_falsey
217
208
  end
218
209
 
219
210
  it "should complain about non existing source" do
220
211
  expect(shell.console).to receive(:error).with("Cannot copy non existent file {mark=bright}#{temp_file_1}{/mark}.")
221
- expect(shell.copy_or_move(temp_file_1, temp_file_2, :copy, true, false, false)).to be_false
212
+ expect(shell.send(:copy_or_move, temp_file_1, temp_file_2, :copy, true, false, false)).to be_falsey
222
213
 
223
214
  expect(shell.console).to receive(:error).with("Cannot move non existent file {mark=bright}#{temp_file_1}{/mark}.")
224
- expect(shell.copy_or_move(temp_file_1, temp_file_2, :move, true, false, false)).to be_false
215
+ expect(shell.send(:copy_or_move, temp_file_1, temp_file_2, :move, true, false, false)).to be_falsey
225
216
  end
226
217
 
227
218
  it "should not copy a file to a path which is currently a directory" do
@@ -229,18 +220,18 @@ describe Bovem::Shell do
229
220
  shell.create_directories(temp_file_2)
230
221
 
231
222
  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
- expect(shell.copy_or_move(temp_file_1, temp_file_2, :copy, true, false, false)).to be_false
223
+ expect(shell.send(:copy_or_move, temp_file_1, temp_file_2, :copy, true, false, false)).to be_falsey
233
224
 
234
225
  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
- expect(shell.copy_or_move(temp_file_1, temp_file_2, :move, true, false, false)).to be_false
226
+ expect(shell.send(:copy_or_move, temp_file_1, temp_file_2, :move, true, false, false)).to be_falsey
236
227
  end
237
228
 
238
229
  it "should create the parent directory if needed" do
239
- expect(shell.check(temp_dir_1, :dir)).to be_false
230
+ expect(shell.check(temp_dir_1, :dir)).to be_falsey
240
231
 
241
232
  expect(shell).to receive(:create_directories).exactly(2)
242
- expect(shell.copy_or_move(temp_file_1, temp_dir_1 + "/test-1", :copy)).to be_false
243
- expect(shell.copy_or_move(temp_file_1, temp_dir_1 + "/test-1", :move)).to be_false
233
+ expect(shell.send(:copy_or_move, temp_file_1, temp_dir_1 + "/test-1", :copy)).to be_falsey
234
+ expect(shell.send(:copy_or_move, temp_file_1, temp_dir_1 + "/test-1", :move)).to be_falsey
244
235
  end
245
236
 
246
237
  it "should only print the list of files" do
@@ -248,24 +239,24 @@ describe Bovem::Shell do
248
239
  expect(FileUtils).not_to receive(:mv)
249
240
 
250
241
  expect(shell.console).to receive(:warn).with("Will copy a file:")
251
- expect(shell.copy_or_move(temp_file_1, temp_file_2, :copy, false)).to be_true
242
+ expect(shell.send(:copy_or_move, temp_file_1, temp_file_2, :copy, false)).to be_truthy
252
243
  expect(shell.console).to receive(:warn).with("Will copy following entries:")
253
- expect(shell.copy_or_move([temp_file_1, temp_file_2], temp_dir_1, :copy, false)).to be_true
244
+ expect(shell.send(:copy_or_move, [temp_file_1, temp_file_2], temp_dir_1, :copy, false)).to be_truthy
254
245
 
255
246
  expect(shell.console).to receive(:warn).with("Will move a file:")
256
- expect(shell.copy_or_move(temp_file_1, temp_file_2, :move, false)).to be_true
247
+ expect(shell.send(:copy_or_move, temp_file_1, temp_file_2, :move, false)).to be_truthy
257
248
  expect(shell.console).to receive(:warn).with("Will move following entries:")
258
- expect(shell.copy_or_move([temp_file_1, temp_file_2], temp_dir_1, :move, false)).to be_true
249
+ expect(shell.send(:copy_or_move, [temp_file_1, temp_file_2], temp_dir_1, :move, false)).to be_truthy
259
250
  end
260
251
 
261
252
  it "should complain about non writeable parent directory" do
262
253
  File.open(temp_file_1, "w") {|f| f.write("OK") }
263
254
 
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
- expect(shell.copy_or_move(temp_file_1, "/dev/bovem", :copy, true, true, false)).to be_false
255
+ expect(shell.console).to receive(:error).with("Cannot copy file {mark=bright}#{temp_file_1}{/mark} to non writable directory {mark=bright}/dev{/mark}.", suffix: "\n", indented: 5)
256
+ expect(shell.send(:copy_or_move, temp_file_1, "/dev/bovem", :copy, true, true, false)).to be_falsey
266
257
 
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
- expect(shell.copy_or_move(temp_file_1, "/dev/bovem", :move, true, true, false)).to be_false
258
+ expect(shell.console).to receive(:error).with("Cannot move file {mark=bright}#{temp_file_1}{/mark} to non writable directory {mark=bright}/dev{/mark}.", suffix: "\n", indented: 5)
259
+ expect(shell.send(:copy_or_move, temp_file_1, "/dev/bovem", :move, true, true, false)).to be_falsey
269
260
  end
270
261
 
271
262
  it "should complain about other exceptions" do
@@ -273,33 +264,33 @@ describe Bovem::Shell do
273
264
  allow(FileUtils).to receive(:mv).and_raise(ArgumentError.new("ERROR"))
274
265
  File.open(temp_file_1, "w") {|f| f.write("OK") }
275
266
 
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
- expect(shell.copy_or_move(temp_file_1, temp_file_2, :copy, true, true, false)).to be_false
267
+ 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.", suffix: "\n", indented: 5)
268
+ expect(shell.send(:copy_or_move, temp_file_1, temp_file_2, :copy, true, true, false)).to be_falsey
278
269
 
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
- expect(shell.copy_or_move(temp_file_1, temp_file_2, :move, true, true, false)).to be_false
270
+ 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.", suffix: "\n", indented: 5)
271
+ expect(shell.send(:copy_or_move, temp_file_1, temp_file_2, :move, true, true, false)).to be_falsey
281
272
  end
282
273
 
283
274
  describe "should exit when requested to" do
284
275
  it "by calling :fatal" do
285
276
  allow(FileUtils).to receive(:cp_r).and_raise(ArgumentError.new("ERROR"))
286
277
  allow(FileUtils).to receive(:mv).and_raise(ArgumentError.new("ERROR"))
278
+ allow(Kernel).to receive(:exit).and_return(true)
287
279
 
288
280
  File.open(temp_file_1, "w") {|f| f.write("OK") }
289
281
  File.open(temp_file_2, "w") {|f| f.write("OK") }
290
282
 
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
- expect(shell.copy_or_move(temp_file_1, "/dev/bovem", :copy, true, true, true)).to be_false
283
+ 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.", suffix: "\n", indented: 5)
284
+ expect(shell.send(:copy_or_move, temp_file_1, "/dev/bovem", :copy, true, true, true)).to be_falsey
293
285
 
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
- expect(shell.copy_or_move(temp_file_1, "/dev/bovem", :move, true, true, true)).to be_false
286
+ 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.", suffix: "\n", indented: 5)
287
+ expect(shell.send(:copy_or_move, temp_file_1, "/dev/bovem", :move, true, true, true)).to be_falsey
296
288
 
297
- allow(Kernel).to receive(:exit).and_return(true)
298
289
  expect(shell.console).to receive(:error).with("Cannot copy following entries to {mark=bright}/dev{/mark}:")
299
- expect(shell.copy_or_move([temp_file_1, temp_file_2], "/dev", :copy, true, true, true)).to be_false
290
+ expect(shell.send(:copy_or_move, [temp_file_1, temp_file_2], "/dev", :copy, true, true, true)).to be_falsey
300
291
 
301
292
  expect(shell.console).to receive(:error).with("Cannot move following entries to {mark=bright}/dev{/mark}:")
302
- expect(shell.copy_or_move([temp_file_1, temp_file_2], "/dev", :move, true, true, true)).to be_false
293
+ expect(shell.send(:copy_or_move, [temp_file_1, temp_file_2], "/dev", :move, true, true, true)).to be_falsey
303
294
  end
304
295
 
305
296
  it "by calling Kernel#exit" do
@@ -307,25 +298,25 @@ describe Bovem::Shell do
307
298
  File.open(temp_file_2, "w") {|f| f.write("OK") }
308
299
 
309
300
  expect(Kernel).to receive(:exit).with(-1).exactly(4).and_return(true)
310
- expect(shell.copy_or_move(temp_file_1, "/dev/bovem", :copy, true, false, true)).to be_false
311
- expect(shell.copy_or_move([temp_file_1, temp_file_2], "/dev", :copy, true, false, true)).to be_false
312
- expect(shell.copy_or_move(temp_file_1, "/dev/bovem", :move, true, false, true)).to be_false
313
- expect(shell.copy_or_move([temp_file_1, temp_file_2], "/dev", :move, true, false, true)).to be_false
301
+ expect(shell.send(:copy_or_move, temp_file_1, "/dev/bovem", :copy, true, false, true)).to be_falsey
302
+ expect(shell.send(:copy_or_move, [temp_file_1, temp_file_2], "/dev", :copy, true, false, true)).to be_falsey
303
+ expect(shell.send(:copy_or_move, temp_file_1, "/dev/bovem", :move, true, false, true)).to be_falsey
304
+ expect(shell.send(:copy_or_move, [temp_file_1, temp_file_2], "/dev", :move, true, false, true)).to be_falsey
314
305
  end
315
306
  end
316
307
  end
317
308
 
318
309
  describe "#copy" do
319
310
  it "should forward everything to #copy_or_move" do
320
- expect(shell).to receive(:copy_or_move).with("A", "B", :copy, "C", "D", "E")
321
- shell.copy("A", "B", "C", "D", "E")
311
+ expect(shell).to receive(:copy_or_move).with("A", "B", operation: :copy, run: "C", show_errors: "D", fatal_errors: "E")
312
+ shell.copy("A", "B", run: "C", show_errors: "D", fatal_errors: "E")
322
313
  end
323
314
  end
324
315
 
325
316
  describe "#move" do
326
317
  it "should forward everything to #copy_or_move" do
327
- expect(shell).to receive(:copy_or_move).with("A", "B", :move, "C", "D", "E")
328
- shell.move("A", "B", "C", "D", "E")
318
+ expect(shell).to receive(:copy_or_move).with("A", "B", operation: :move, run: "C", show_errors: "D", fatal_errors: "E")
319
+ shell.move("A", "B", run: "C", show_errors: "D", fatal_errors: "E")
329
320
  end
330
321
  end
331
322
 
@@ -356,7 +347,7 @@ describe Bovem::Shell do
356
347
  it "should change but not restore directory" do
357
348
  owd = Dir.pwd
358
349
 
359
- shell.within_directory(target, false) do
350
+ shell.within_directory(target, restore: false) do
360
351
  expect(Dir.pwd).to eq(target)
361
352
  end
362
353
 
@@ -365,21 +356,21 @@ describe Bovem::Shell do
365
356
 
366
357
  it "should show messages" do
367
358
  expect(shell.console).to receive(:info).with(/Moving (.*)into directory \{mark=bright\}(.+)\{\/mark\}/).exactly(2)
368
- shell.within_directory(target, true, true) { "OK" }
359
+ shell.within_directory(target, show_messages: true) { "OK" }
369
360
  end
370
361
 
371
362
  it "should return false and not execute code in case of invalid directory" do
372
363
  dir = ""
373
364
 
374
- expect(shell.within_directory("/invalid") { dir = "OK" }).to be_false
365
+ expect(shell.within_directory("/invalid") { dir = "OK" }).to be_falsey
375
366
  expect(dir).to eq("")
376
367
 
377
368
  allow(Dir).to receive(:chdir).and_raise(ArgumentError)
378
- expect(shell.within_directory("/") { true }).to be_false
369
+ expect(shell.within_directory("/") { true }).to be_falsey
379
370
 
380
371
  allow(Dir).to receive(:chdir)
381
372
  allow(Dir).to receive(:pwd).and_return("/invalid")
382
- expect(shell.within_directory("/") { true }).to be_false
373
+ expect(shell.within_directory("/") { true }).to be_falsey
383
374
  end
384
375
  end
385
376
 
@@ -401,52 +392,52 @@ describe Bovem::Shell do
401
392
  end
402
393
 
403
394
  it "should create directory" do
404
- expect(shell.create_directories([temp_dir_1, temp_dir_2])).to be_true
405
- expect(shell.check(temp_dir_1, :directory)).to be_true
406
- expect(shell.check(temp_dir_2, :directory)).to be_true
395
+ expect(shell.create_directories([temp_dir_1, temp_dir_2])).to be_truthy
396
+ expect(shell.check(temp_dir_1, :directory)).to be_truthy
397
+ expect(shell.check(temp_dir_2, :directory)).to be_truthy
407
398
  end
408
399
 
409
400
  it "should only print the list of files" do
410
401
  expect(shell.console).to receive(:warn).with("Will create directories:")
411
402
  expect(FileUtils).not_to receive(:mkdir_p)
412
- expect(shell.create_directories(temp_file_1, 0755, false)).to be_true
403
+ expect(shell.create_directories(temp_file_1, run: false)).to be_truthy
413
404
  end
414
405
 
415
406
  it "should complain about directory already existing" do
416
- shell.create_directories(temp_dir_1, 0755, true, false, false)
407
+ shell.create_directories(temp_dir_1, fatal_errors: false)
417
408
  expect(shell.console).to receive(:error).with("The directory {mark=bright}#{temp_dir_1}{/mark} already exists.")
418
- expect(shell.create_directories(temp_dir_1, 0755, true, false, false)).to be_false
409
+ expect(shell.create_directories(temp_dir_1, show_errors: true, fatal_errors: false)).to be_falsey
419
410
  end
420
411
 
421
412
  it "should complain about paths already existing as a file." do
422
413
  File.open(temp_file_1, "w") {|f| f.write("OK") }
423
414
 
424
415
  expect(shell.console).to receive(:error).with("Path {mark=bright}#{temp_file_1}{/mark} is currently a file.")
425
- expect(shell.create_directories(temp_file_1, 0755, true, false, false)).to be_false
416
+ expect(shell.create_directories(temp_file_1, show_errors: true, fatal_errors: false)).to be_falsey
426
417
  end
427
418
 
428
419
  it "should complain about non writable parents" do
429
420
  expect(shell.console).to receive(:error).with("Cannot create following directory due to permission denied: {mark=bright}/dev/bovem{/mark}.")
430
- expect(shell.create_directories("/dev/bovem", 0755, true, false, false)).to be_false
421
+ expect(shell.create_directories("/dev/bovem", show_errors: true, fatal_errors: false)).to be_falsey
431
422
  end
432
423
 
433
424
  it "should complain about other exceptions" do
434
425
  allow(FileUtils).to receive(:mkdir_p).and_raise(ArgumentError.new("ERROR"))
435
426
  expect(shell.console).to receive(:error).with("Cannot create following directories:")
436
427
  expect(shell.console).to receive(:write).at_least(2)
437
- expect(shell.create_directories(temp_dir_1, 0755, true, true, false)).to be_false
428
+ expect(shell.create_directories(temp_dir_1, show_errors: true, fatal_errors: false)).to be_falsey
438
429
  end
439
430
 
440
431
  describe "should exit when requested to" do
441
432
  it "by calling :fatal" do
442
433
  expect(shell.console).to receive(:fatal).with("Path {mark=bright}/dev/null{/mark} is currently a file.")
443
- expect(shell.create_directories("/dev/null")).to be_false
434
+ expect(shell.create_directories("/dev/null")).to be_falsey
444
435
  end
445
436
 
446
437
  it "by calling Kernel#exit" do
447
438
  allow(FileUtils).to receive(:mkdir_p).and_raise(ArgumentError.new("ERROR"))
448
439
  expect(Kernel).to receive(:exit).with(-1)
449
- expect(shell.create_directories(temp_dir_1, 0755, true, true)).to be_false
440
+ expect(shell.create_directories(temp_dir_1, show_errors: true, fatal_errors: true)).to be_falsey
450
441
  end
451
442
  end
452
443
  end
@@ -455,7 +446,7 @@ describe Bovem::Shell do
455
446
  let(:root) {File.expand_path(File.dirname(__FILE__) + "/../../") }
456
447
 
457
448
  it "it should return [] for invalid or empty directories" do
458
- expect(shell.find("/invalid", /rb/)).to eq([])
449
+ expect(shell.find("/invalid", patterns: /rb/)).to eq([])
459
450
  end
460
451
 
461
452
  it "it should return every file for empty patterns" do
@@ -465,7 +456,7 @@ describe Bovem::Shell do
465
456
  files << file
466
457
  end
467
458
 
468
- expect(shell.find(root, nil)).to eq(files)
459
+ expect(shell.find(root, patterns: nil)).to eq(files)
469
460
  end
470
461
 
471
462
  it "should find files basing on pattern" do
@@ -475,10 +466,10 @@ describe Bovem::Shell do
475
466
  files << file if !File.directory?(file)
476
467
  end
477
468
 
478
- expect(shell.find(root, /lib\/bovem\/.+rb/)).to eq(files)
479
- expect(shell.find(root, /lib\/BOVEM\/.+rb/)).to eq(files)
480
- expect(shell.find(root, "lib\/bovem/")).to eq(files)
481
- expect(shell.find(root, /lib\/BOVEM\/.+rb/, false, true)).to eq([])
469
+ expect(shell.find(root, patterns: /lib\/bovem\/.+rb/)).to eq(files)
470
+ expect(shell.find(root, patterns: /lib\/BOVEM\/.+rb/)).to eq(files)
471
+ expect(shell.find(root, patterns: "lib\/bovem/")).to eq(files)
472
+ expect(shell.find(root, patterns: /lib\/BOVEM\/.+rb/, case_sensitive: true)).to eq([])
482
473
  end
483
474
 
484
475
  it "should find files basing on extension" do
@@ -488,9 +479,9 @@ describe Bovem::Shell do
488
479
  files << file if !File.directory?(file)
489
480
  end
490
481
 
491
- expect(shell.find(root + "/lib/bovem", /rb/, true)).to eq(files)
492
- expect(shell.find(root + "/lib/bovem", /bovem/, true)).to eq([])
493
- expect(shell.find(root + "/lib/bovem", "RB", true, true)).to eq([])
482
+ expect(shell.find(root + "/lib/bovem", patterns: /rb/, extension_only: true)).to eq(files)
483
+ expect(shell.find(root + "/lib/bovem", patterns: /bovem/, extension_only: true)).to eq([])
484
+ expect(shell.find(root + "/lib/bovem", patterns: "RB", extension_only: true, case_sensitive: true)).to eq([])
494
485
  end
495
486
 
496
487
  it "should filter files basing using a block" do
@@ -500,10 +491,10 @@ describe Bovem::Shell do
500
491
  files << file if !File.directory?(file)
501
492
  end
502
493
 
503
- expect(shell.find(root + "/lib/bovem", /rb/, true) { |file|
494
+ expect(shell.find(root + "/lib/bovem", patterns: /rb/, extension_only: true) { |file|
504
495
  !File.directory?(file)
505
496
  }).to eq(files)
506
- expect(shell.find(root + "/lib/bovem", /bovem/, true) { |file|
497
+ expect(shell.find(root + "/lib/bovem", patterns: /bovem/, extension_only: true) { |file|
507
498
  false
508
499
  }).to eq([])
509
500
  end