bovem 3.0.5 → 4.0.0

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.
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
@@ -11,13 +11,13 @@ module Bovem
11
11
  # @see http://semver.org
12
12
  module Version
13
13
  # The major version.
14
- MAJOR = 3
14
+ MAJOR = 4
15
15
 
16
16
  # The minor version.
17
17
  MINOR = 0
18
18
 
19
19
  # The patch version.
20
- PATCH = 5
20
+ PATCH = 0
21
21
 
22
22
  # The current version number of Bovem.
23
23
  STRING = [MAJOR, MINOR, PATCH].compact.join(".")
@@ -5,55 +5,56 @@
5
5
  #
6
6
 
7
7
  ---
8
+ en:
8
9
  bovem:
9
10
  configuration:
10
- using: "Using configuration file %1."
11
- invalid: "Config file %1 is not valid."
12
- not_found: "Config file %1 is not existing or not readable."
11
+ using: "Using configuration file %s."
12
+ invalid: "Config file %s is not valid."
13
+ not_found: "Config file %s is not existing or not readable."
13
14
  console:
14
15
  prompt: "Please insert a value"
15
16
  unknown_reply: "Sorry, your reply was not understood. Please try again."
16
17
  shell:
17
- error: "due to this error: [%1] %2."
18
- run: "Running command: {mark=bright}\"%1\"{/mark}..."
19
- run_dry: "Will run command: {mark=bright}\"%1\"{/mark}..."
18
+ error: "due to this error: [%s] %s."
19
+ run: "Running command: {mark=bright}\"%s\"{/mark}..."
20
+ run_dry: "Will run command: {mark=bright}\"%s\"{/mark}..."
20
21
  remove_dry: "Will remove file(s):"
21
- remove_unwritable: "Cannot remove following non writable file: {mark=bright}%1{/mark}"
22
- remove_not_found: "Cannot remove following non existent file: {mark=bright}%1{/mark}"
22
+ remove_unwritable: "Cannot remove following non writable file: {mark=bright}%s{/mark}"
23
+ remove_not_found: "Cannot remove following non existent file: {mark=bright}%s{/mark}"
23
24
  remove_error: "Cannot remove following file(s):"
24
25
  copy: "copy"
25
26
  move: "move"
26
- copy_move_single_dry: "Will %1 a file:"
27
- copy_move_multi_dry: "Will %1 following entries:"
28
- copy_move_from: "From: {mark=bright}%1{/mark}"
29
- copy_move_to: "To: {mark=bright}%1{/mark}"
30
- copy_move_to_multi: "to directory: {mark=bright}%1{/mark}"
31
- copy_move_single_to_directory: "Cannot %1 file {mark=bright}%2{/mark} to {mark=bright}%3{/mark} because it is currently a directory."
32
- copy_move_src_not_found: "Cannot %1 non existent file {mark=bright}%2{/mark}."
33
- copy_move_dst_not_writable_single: "Cannot %1 file {mark=bright}%2{/mark} to non writable directory {mark=bright}%3{/mark}."
34
- copy_move_dst_not_writable_multi: "Cannot %1 following file(s) to non writable directory {mark=bright}%2{/mark}:"
35
- copy_move_error_single: "Cannot %1 file {mark=bright}%2{/mark} to directory {mark=bright}%3{/mark} due to this error: [%4] %5."
36
- copy_move_error_multi: "Cannot %1 following entries to {mark=bright}%2{/mark}:"
37
- move_in: "Moving into directory {mark=bright}%1{/mark}"
38
- move_out: "Moving back into directory {mark=bright}%1{/mark}"
27
+ copy_move_single_dry: "Will %s a file:"
28
+ copy_move_multi_dry: "Will %s following entries:"
29
+ copy_move_from: "From: {mark=bright}%s{/mark}"
30
+ copy_move_to: "To: {mark=bright}%s{/mark}"
31
+ copy_move_to_multi: "to directory: {mark=bright}%s{/mark}"
32
+ copy_move_single_to_directory: "Cannot %s file {mark=bright}%s{/mark} to {mark=bright}%s{/mark} because it is currently a directory."
33
+ copy_move_src_not_found: "Cannot %s non existent file {mark=bright}%s{/mark}."
34
+ copy_move_dst_not_writable_single: "Cannot %s file {mark=bright}%s{/mark} to non writable directory {mark=bright}%s{/mark}."
35
+ copy_move_dst_not_writable_multi: "Cannot %s following file(s) to non writable directory {mark=bright}%s{/mark}:"
36
+ copy_move_error_single: "Cannot %s file {mark=bright}%s{/mark} to directory {mark=bright}%s{/mark} due to this error: [%s] %s."
37
+ copy_move_error_multi: "Cannot %s following entries to {mark=bright}%s{/mark}:"
38
+ move_in: "Moving into directory {mark=bright}%s{/mark}"
39
+ move_out: "Moving back into directory {mark=bright}%s{/mark}"
39
40
  mkdir_dry: "Will create directories:"
40
- mkdir_existing: "The directory {mark=bright}%1{/mark} already exists."
41
- mkdir_file: "Path {mark=bright}%1{/mark} is currently a file."
42
- mkdir_denied: "Cannot create following directory due to permission denied: {mark=bright}%1{/mark}."
41
+ mkdir_existing: "The directory {mark=bright}%s{/mark} already exists."
42
+ mkdir_file: "Path {mark=bright}%s{/mark} is currently a file."
43
+ mkdir_denied: "Cannot create following directory due to permission denied: {mark=bright}%s{/mark}."
43
44
  mkdir_error: "Cannot create following directories:"
44
45
  application:
45
46
  default_application_name: "__APPLICATION__"
46
- ambigous_command: "Command shortcut \"%1\" is ambiguous across commands %2. Please add some other characters."
47
- needless_argument: "Option %1 does not expects an argument."
48
- missing_argument: "Option %1 expects an argument."
49
- invalid_option: "Invalid option %1."
50
- invalid_integer: "Option %1 expects a valid integer as argument."
51
- invalid_float: "Option %1 expects a valid floating number as argument."
52
- conflicting_options: "Options %1 and %2 have conflicting forms."
53
- missing_option: "Required option %1 is missing."
54
- invalid_value: "Value of option %1 must be one of these values: %2."
55
- invalid_for_regexp: "Value of option %1 must match the regular expression: %2."
56
- invalid_for_proc: "Value of option %1 is invalid."
47
+ ambigous_command: "Command shortcut \"%s\" is ambiguous across commands %s. Please add some other characters."
48
+ needless_argument: "Option %s does not expects an argument."
49
+ missing_argument: "Option %s expects an argument."
50
+ invalid_option: "Invalid option %s."
51
+ invalid_integer: "Option %s expects a valid integer as argument."
52
+ invalid_float: "Option %s expects a valid floating number as argument."
53
+ conflicting_options: "Options %s and %s have conflicting forms."
54
+ missing_option: "Required option %s is missing."
55
+ invalid_value: "Value of option %s must be one of these values: %s."
56
+ invalid_for_regexp: "Value of option %s must match the regular expression: %s."
57
+ invalid_for_proc: "Value of option %s is invalid."
57
58
  help_option_short_form: "-h"
58
59
  help_option_long_form: "--help"
59
60
  help_message: "Shows this message."
@@ -71,8 +72,8 @@
71
72
  help_subcommand_invocation: "[command [sub-command ...]] "
72
73
  help_subsubcommand_invocation: "[sub-command [sub-sub-command ...]] "
73
74
  help_command_description: "Shows a help about a command."
74
- existing_command: "The command \"%1\" already exists."
75
- existing_option_global: "The global option \"%1\" already exists."
76
- existing_option: "The option \"%1\" already exists for the command \"%2\"."
75
+ existing_command: "The command \"%s\" already exists."
76
+ existing_option_global: "The global option \"%s\" already exists."
77
+ existing_option: "The option \"%s\" already exists for the command \"%s\"."
77
78
  missing_app_block: "You have to provide a block to the Bovem::Application constructor!"
78
79
  join_separator: " and "
@@ -5,55 +5,56 @@
5
5
  #
6
6
 
7
7
  ---
8
+ it:
8
9
  bovem:
9
10
  configuration:
10
- using: "Uso il file di configurazione %1."
11
- invalid: "Il file di configurazione %1 non è valido."
12
- not_found: "Il file di configurazione %1 non esiste o non è leggibile."
11
+ using: "Uso il file di configurazione %s."
12
+ invalid: "Il file di configurazione %s non è valido."
13
+ not_found: "Il file di configurazione %s non esiste o non è leggibile."
13
14
  console:
14
15
  prompt: "Per favore inserisci un valore"
15
16
  unknown_reply: "Mi dispiace, la tua risposta non è stata compresa. Per favore prova di nuovo."
16
17
  shell:
17
- error: "a causa di quest'errore: [%1] %2."
18
- run: "Eseguo il comando: {mark=bright}\"%1\"{/mark}..."
19
- run_dry: "Eseguirò il comando: {mark=bright}\"%1\"{/mark}..."
18
+ error: "a causa di quest'errore: [%s] %s."
19
+ run: "Eseguo il comando: {mark=bright}\"%s\"{/mark}..."
20
+ run_dry: "Eseguirò il comando: {mark=bright}\"%s\"{/mark}..."
20
21
  remove_dry: "Rimuoverò i files:"
21
- remove_unwritable: "Non posso rimuovere il file di sola lettura: {mark=bright}%1{/mark}"
22
- remove_not_found: "Non posso rimuovere il file non esistente: {mark=bright}%1{/mark}"
22
+ remove_unwritable: "Non posso rimuovere il file di sola lettura: {mark=bright}%s{/mark}"
23
+ remove_not_found: "Non posso rimuovere il file non esistente: {mark=bright}%s{/mark}"
23
24
  remove_error: "Non posso rimuovere i seguenti file:"
24
25
  copy: "la copia"
25
26
  move: "lo spostamento"
26
- copy_move_single_dry: "Eseguirò %1 di un file:"
27
- copy_move_multi_dry: "Eseguirò %1 dei seguenti elementi:"
28
- copy_move_from: "Da: {mark=bright}%1{/mark}"
29
- copy_move_to: "A: {mark=bright}%1{/mark}"
30
- copy_move_to_multi: "nella cartella: {mark=bright}%1{/mark}"
31
- copy_move_single_to_directory: "Impossibile eseguire %1 del file {mark=bright}%2{/mark} in {mark=bright}%3{/mark} perché è attualmente una cartella."
32
- copy_move_src_not_found: "Impossibile eseguire %1 del file non esistente {mark=bright}%2{/mark}."
33
- copy_move_dst_not_writable_single: "Impossibile eseguire %1 del file {mark=bright}%2{/mark} nella cartella di sola lettura {mark=bright}%3{/mark}."
34
- copy_move_dst_not_writable_multi: "Impossibile eseguire %1 dei seguenti elementi nella cartella di sola lettura {mark=bright}%2{/mark}:"
35
- copy_move_error_single: "Impossibile eseguire %1 file {mark=bright}%2{/mark} nella cartella {mark=bright}%3{/mark} a causa di quest'errore: [%4] %5."
36
- copy_move_error_multi: "Impossibile eseguire %1 dei seguenti elementi {mark=bright}%2{/mark}:"
37
- move_in: "Entro nella cartella {mark=bright}%1{/mark}"
38
- move_out: "Torno indietro alla cartella {mark=bright}%1{/mark}"
27
+ copy_move_single_dry: "Eseguirò %s di un file:"
28
+ copy_move_multi_dry: "Eseguirò %s dei seguenti elementi:"
29
+ copy_move_from: "Da: {mark=bright}%s{/mark}"
30
+ copy_move_to: "A: {mark=bright}%s{/mark}"
31
+ copy_move_to_multi: "nella cartella: {mark=bright}%s{/mark}"
32
+ copy_move_single_to_directory: "Impossibile eseguire %s del file {mark=bright}%s{/mark} in {mark=bright}%s{/mark} perché è attualmente una cartella."
33
+ copy_move_src_not_found: "Impossibile eseguire %s del file non esistente {mark=bright}%s{/mark}."
34
+ copy_move_dst_not_writable_single: "Impossibile eseguire %s del file {mark=bright}%s{/mark} nella cartella di sola lettura {mark=bright}%s{/mark}."
35
+ copy_move_dst_not_writable_multi: "Impossibile eseguire %s dei seguenti elementi nella cartella di sola lettura {mark=bright}%s{/mark}:"
36
+ copy_move_error_single: "Impossibile eseguire %s file {mark=bright}%s{/mark} nella cartella {mark=bright}%s{/mark} a causa di quest'errore: [%s] %s."
37
+ copy_move_error_multi: "Impossibile eseguire %s dei seguenti elementi {mark=bright}%s{/mark}:"
38
+ move_in: "Entro nella cartella {mark=bright}%s{/mark}"
39
+ move_out: "Torno indietro alla cartella {mark=bright}%s{/mark}"
39
40
  mkdir_dry: "Creerò le cartelle:"
40
- mkdir_existing: "La cartella {mark=bright}%1{/mark} è già esistente."
41
- mkdir_file: "Il percorso {mark=bright}%1{/mark} è attualmente un file."
42
- mkdir_denied: "Impossible creare la seguente cartella a causa di permessi negati: {mark=bright}%1{/mark}."
41
+ mkdir_existing: "La cartella {mark=bright}%s{/mark} è già esistente."
42
+ mkdir_file: "Il percorso {mark=bright}%s{/mark} è attualmente un file."
43
+ mkdir_denied: "Impossible creare la seguente cartella a causa di permessi negati: {mark=bright}%s{/mark}."
43
44
  mkdir_error: "Impossibile creare le seguenti cartelle:"
44
45
  application:
45
46
  default_application_name: "__APPLICAZIONE__"
46
- ambigous_command: "La scorciatoia di comando \"%1\" è ambigua tra i seguenti comandi %2. Per favore aggiungi qualche altro carattere."
47
- needless_argument: "L'opzione %1 non richiede un argomento."
48
- missing_argument: "L'opzione %1 richiede un argomento."
49
- invalid_option: "L'opzione %1 non è valida."
50
- invalid_integer: "L'opzione %1 richiede un numero intero valido come argomento."
51
- invalid_float: "L'opzione %1 richiede un numero decimale valido come argomento."
52
- conflicting_options: "Le opzioni %1 e %2 hanno forme in conflitto."
53
- missing_option: "L'opzione richiesta %1 è mancante."
54
- invalid_value: "Il valore dell'opzione %1 deve essere uno dei seguenti valori: %2."
55
- invalid_for_regexp: "Il valore dell'opzione %1 deve soddisfare questa espressione regolare: %2."
56
- invalid_for_proc: "Il valore dell'opzione %1 non è valido."
47
+ ambigous_command: "La scorciatoia di comando \"%s\" è ambigua tra i seguenti comandi %s. Per favore aggiungi qualche altro carattere."
48
+ needless_argument: "L'opzione %s non richiede un argomento."
49
+ missing_argument: "L'opzione %s richiede un argomento."
50
+ invalid_option: "L'opzione %s non è valida."
51
+ invalid_integer: "L'opzione %s richiede un numero intero valido come argomento."
52
+ invalid_float: "L'opzione %s richiede un numero decimale valido come argomento."
53
+ conflicting_options: "Le opzioni %s e %s hanno forme in conflitto."
54
+ missing_option: "L'opzione richiesta %s è mancante."
55
+ invalid_value: "Il valore dell'opzione %s deve essere uno dei seguenti valori: %s."
56
+ invalid_for_regexp: "Il valore dell'opzione %s deve soddisfare questa espressione regolare: %s."
57
+ invalid_for_proc: "Il valore dell'opzione %s non è valido."
57
58
  help_option_short_form: "-h"
58
59
  help_option_long_form: "--help"
59
60
  help_message: "Mostra questo messaggio."
@@ -71,8 +72,8 @@
71
72
  help_subcommand_invocation: "[comando [sotto-comando ...]] "
72
73
  help_subsubcommand_invocation: "[sotto-comando [sotto-sotto-comando ...]] "
73
74
  help_command_description: "Mostra aiuto riguardo un comando."
74
- existing_command: "Il comando \"%1\" è già esistente."
75
- existing_option_global: "L'opzione globale \"%1\" è già esistente."
76
- existing_option: "L'opzione \"%1\" è già esistente per il comando \"%2\"."
75
+ existing_command: "Il comando \"%s\" è già esistente."
76
+ existing_option_global: "L'opzione globale \"%s\" è già esistente."
77
+ existing_option: "L'opzione \"%s\" è già esistente per il comando \"%s\"."
77
78
  missing_app_block: "Devi fornire un blocco per il costruttore di Bovem::Application!"
78
79
  join_separator: " e "
@@ -21,9 +21,9 @@ describe Bovem::Application do
21
21
  it "should set good defaults" do
22
22
  expect(application.shell).to eq(Bovem::Shell.instance)
23
23
  expect(application.console).to eq(application.shell.console)
24
- expect(application.skip_commands).to be_false
25
- expect(application.show_commands).to be_false
26
- expect(application.output_commands).to be_false
24
+ expect(application.skip_commands).to be_falsey
25
+ expect(application.show_commands).to be_falsey
26
+ expect(application.output_commands).to be_falsey
27
27
  end
28
28
  end
29
29
 
@@ -53,7 +53,7 @@ describe Bovem::Application do
53
53
 
54
54
  describe "#executable_name" do
55
55
  it "should return executable name" do
56
- expect(application.executable_name).to eq($0)
56
+ expect(application.executable_name).to eq($PROGRAM_NAME)
57
57
  end
58
58
  end
59
59
 
@@ -123,7 +123,7 @@ describe Bovem::Application do
123
123
  check = false
124
124
 
125
125
  application = Bovem::Application.create(options) { check = true }
126
- expect(check).to be_true
126
+ expect(check).to be_truthy
127
127
  expect(application.name).to eq("OK")
128
128
  end
129
129
 
@@ -134,6 +134,7 @@ describe Bovem::Application do
134
134
  option("require", [], {})
135
135
  option("format", [], {})
136
136
  option("example", [], {})
137
+ option("pattern", [], {})
137
138
 
138
139
  action do |command|
139
140
  args = command.arguments.join("-")
@@ -122,17 +122,17 @@ describe Bovem::Command do
122
122
  end
123
123
  end
124
124
 
125
- describe "#has_description?" do
125
+ describe "#description?" do
126
126
  it "should check if the command has a description" do
127
- expect(Bovem::Command.new.has_description?).to be_false
128
- expect(Bovem::Command.new({description: "DESCRIPTION"}).has_description?).to be_true
127
+ expect(Bovem::Command.new.description?).to be_falsey
128
+ expect(Bovem::Command.new({description: "DESCRIPTION"}).description?).to be_truthy
129
129
  end
130
130
  end
131
131
 
132
- describe "#has_banner?" do
132
+ describe "#banner?" do
133
133
  it "should check if the command has a banner" do
134
- expect(Bovem::Command.new.has_banner?).to be_false
135
- expect(Bovem::Command.new({banner: "BANNER"}).has_banner?).to be_true
134
+ expect(Bovem::Command.new.banner?).to be_falsey
135
+ expect(Bovem::Command.new({banner: "BANNER"}).banner?).to be_truthy
136
136
  end
137
137
  end
138
138
 
@@ -201,11 +201,11 @@ describe Bovem::Command do
201
201
  end
202
202
  end
203
203
 
204
- describe "#has_commands?" do
204
+ describe "#commands?" do
205
205
  it "should check if the command has subcommands" do
206
- expect(command.has_commands?).to be_false
206
+ expect(command.commands?).to be_falsey
207
207
  command.command("subcommand")
208
- expect(command.has_commands?).to be_true
208
+ expect(command.commands?).to be_truthy
209
209
  end
210
210
  end
211
211
 
@@ -233,11 +233,11 @@ describe Bovem::Command do
233
233
  end
234
234
  end
235
235
 
236
- describe "#has_options?" do
236
+ describe "#options?" do
237
237
  it "should check if the command has options" do
238
- expect(command.has_options?).to be_false
238
+ expect(command.options?).to be_falsey
239
239
  command.option("option")
240
- expect(command.has_options?).to be_true
240
+ expect(command.options?).to be_truthy
241
241
  end
242
242
  end
243
243
 
@@ -268,10 +268,10 @@ describe Bovem::Command do
268
268
  end
269
269
  end
270
270
 
271
- describe "#is_application?" do
271
+ describe "#application?" do
272
272
  it "should check if the command is an application" do
273
- expect(command.is_application?).to be_false
274
- expect(application.is_application?).to be_true
273
+ expect(command.application?).to be_falsey
274
+ expect(application.application?).to be_truthy
275
275
  end
276
276
  end
277
277
 
@@ -438,38 +438,38 @@ describe Bovem::Command do
438
438
  it "should only return provided options if required to" do
439
439
  Bovem::Parser.parse(reference.application, ["--aaa", "111"])
440
440
  Bovem::Parser.parse(reference, ["--ccc", "2.0"])
441
- expect(reference.get_options(false).symbolize_keys).to eq({application_aaa: 111, aaa: 456, ccc: ["2.0"]})
441
+ expect(reference.get_options.symbolize_keys).to eq({application_aaa: 111, aaa: 456, ccc: ["2.0"]})
442
442
  end
443
443
 
444
444
  it "should skip application options if required to" do
445
445
  Bovem::Parser.parse(reference.application, ["--aaa", "111", "--ddd", "2.0"])
446
446
  Bovem::Parser.parse(reference, ["--bbb", "2.0", "--ccc", "A,B,C"])
447
- expect(reference.get_options(true, false).symbolize_keys).to eq({aaa: 456, bbb: "2.0", ccc: ["A", "B", "C"]})
448
- expect(reference.get_options(true, nil).symbolize_keys).to eq({aaa: 456, bbb: "2.0", ccc: ["A", "B", "C"]})
447
+ expect(reference.get_options(unprovided: true, application: false).symbolize_keys).to eq({aaa: 456, bbb: "2.0", ccc: ["A", "B", "C"]})
448
+ expect(reference.get_options(unprovided: true, application: nil).symbolize_keys).to eq({aaa: 456, bbb: "2.0", ccc: ["A", "B", "C"]})
449
449
  end
450
450
 
451
451
  it "should apply the requested prefix for command options" do
452
452
  Bovem::Parser.parse(reference.application, ["--aaa", "111", "--ddd", "2.0"])
453
453
  Bovem::Parser.parse(reference, ["--bbb", "2.0", "--ccc", "A,B,C"])
454
- expect(reference.get_options(true, false, "PREFIX").symbolize_keys).to eq({PREFIXaaa: 456, PREFIXbbb: "2.0", PREFIXccc: ["A", "B", "C"]})
454
+ expect(reference.get_options(unprovided: true, application: false, prefix: "PREFIX").symbolize_keys).to eq({PREFIXaaa: 456, PREFIXbbb: "2.0", PREFIXccc: ["A", "B", "C"]})
455
455
  end
456
456
 
457
457
  it "should apply the requested prefix for application options" do
458
458
  Bovem::Parser.parse(reference.application, ["--aaa", "111", "--ddd", "2.0"])
459
459
  Bovem::Parser.parse(reference, ["--bbb", "2.0", "--ccc", "A,B,C"])
460
- expect(reference.get_options(true, "APP").symbolize_keys).to eq({APPaaa: 111, APPddd: 2.0, aaa: 456, bbb: "2.0", ccc: ["A", "B", "C"]})
460
+ expect(reference.get_options(unprovided: true, application: "APP").symbolize_keys).to eq({APPaaa: 111, APPddd: 2.0, aaa: 456, bbb: "2.0", ccc: ["A", "B", "C"]})
461
461
  end
462
462
 
463
463
  it "should only return requested options" do
464
464
  Bovem::Parser.parse(reference.application, ["--aaa", "111", "--ddd", "2.0"])
465
465
  Bovem::Parser.parse(reference, ["--bbb", "2.0", "--ccc", "A,B,C"])
466
- expect(reference.get_options(true, "application_", "", :aaa, :bbb).symbolize_keys).to eq({application_aaa: 111, aaa: 456, bbb: "2.0"})
466
+ expect(reference.get_options(unprovided: true, whitelist: [:aaa, :bbb]).symbolize_keys).to eq({application_aaa: 111, aaa: 456, bbb: "2.0"})
467
467
  end
468
468
 
469
469
  it "should apply higher precedence to command options in case of conflicts" do
470
470
  Bovem::Parser.parse(reference.application, ["--aaa", "111", "--ddd", "2.0"])
471
471
  Bovem::Parser.parse(reference, ["--bbb", "2.0", "--ccc", "A,B,C"])
472
- expect(reference.get_options(true, "", "").symbolize_keys).to eq({ddd: 2.0, aaa: 456, bbb: "2.0", ccc: ["A", "B", "C"]})
472
+ expect(reference.get_options(unprovided: true, application: "").symbolize_keys).to eq({ddd: 2.0, aaa: 456, bbb: "2.0", ccc: ["A", "B", "C"]})
473
473
  end
474
474
  end
475
475
 
@@ -517,7 +517,7 @@ describe Bovem::Command do
517
517
 
518
518
  it "should exit" do
519
519
  allow(Kernel).to receive(:puts)
520
- allow(Bovem::Console.any_instance).to receive(:write)
520
+ allow_any_instance_of(Bovem::Console).to receive(:write)
521
521
 
522
522
  expect(Kernel).to receive(:exit).with(0).exactly(1)
523
523
  application.show_help
@@ -7,11 +7,7 @@
7
7
  require "spec_helper"
8
8
 
9
9
  describe Bovem::Console do
10
- let(:console) {
11
- c = Bovem::Console.new
12
- c.i18n = :en
13
- c
14
- }
10
+ let(:console) { Bovem::Console.new }
15
11
 
16
12
  before(:each) do
17
13
  ENV["TERM"] = "xterm-256color"
@@ -74,7 +70,7 @@ describe Bovem::Console do
74
70
  it "should return a Fixnum greater than 0" do
75
71
  w = console.line_width
76
72
  expect(w).to be_a(Fixnum)
77
- expect(w >= 0).to be_true
73
+ expect(w >= 0).to be_truthy
78
74
  end
79
75
 
80
76
  it "should use $stdin.winsize if available" do
@@ -124,10 +120,10 @@ describe Bovem::Console do
124
120
  describe "#wrap" do
125
121
  it "should correct wrap text" do
126
122
  message = " ABC__DEF GHI JKL"
127
- expect(console.wrap(message, 2)).to eq("ABC__DEF\nGHI\nJKL")
128
- expect(console.wrap(message, 3)).to eq("ABC__DEF\nGHI\nJKL")
129
- expect(console.wrap(message, 4)).to eq("ABC__DEF\nGHI\nJKL")
130
- expect(console.wrap(message, 5)).to eq("ABC__DEF\nGHI\nJKL")
123
+ expect(console.wrap(message, 2)).to eq(" ABC__DEF\nGHI\nJKL")
124
+ expect(console.wrap(message, 3)).to eq(" ABC__DEF\nGHI\nJKL")
125
+ expect(console.wrap(message, 4)).to eq(" ABC__DEF\nGHI\nJKL")
126
+ expect(console.wrap(message, 5)).to eq(" ABC__DEF\nGHI\nJKL")
131
127
  expect(console.wrap(message, 20)).to eq(" ABC__DEF GHI JKL")
132
128
 
133
129
  expect(console.wrap(message, nil)).to eq(message)
@@ -137,7 +133,7 @@ describe Bovem::Console do
137
133
  it "should work well with #indent" do
138
134
  message = "AB CD"
139
135
  console.set_indentation(2)
140
- expect(console.wrap(console.indent(message), 2)).to eq("AB\nCD")
136
+ expect(console.wrap(console.indent(message), 2)).to eq(" AB\n CD")
141
137
  end
142
138
  end
143
139
 
@@ -162,18 +158,11 @@ describe Bovem::Console do
162
158
  it "should apply modifications to the message" do
163
159
  message = "ABC"
164
160
  console.set_indentation(2)
165
- expect(console.format(message, "\n", false)).to eq("ABC\n")
166
- expect(console.format(message, "A")).to eq(" ABCA")
167
- expect(console.format(message, "A", 3)).to eq(" ABCA")
168
- expect(console.format(message, "A", 3, 4)).to eq(" ABCA")
169
- expect(console.format("{mark=red}ABC{/mark}", "\n", true, true, true)).to eq(" ABC\n")
170
- end
171
- end
172
-
173
- describe "#replace_markers" do
174
- it "should just forwards to .replace_markers" do
175
- expect(Bovem::Console).to receive(:replace_markers).with("A", "B")
176
- console.replace_markers("A", "B")
161
+ expect(console.format(message, suffix: "\n", indented: false)).to eq("ABC\n")
162
+ expect(console.format(message, suffix: "A")).to eq(" ABCA")
163
+ expect(console.format(message, suffix: "A", indented: 3)).to eq(" ABCA")
164
+ expect(console.format(message, suffix: "A", indented: 3, wrap: 4)).to eq(" ABCA")
165
+ expect(console.format("{mark=red}ABC{/mark}", plain: true)).to eq(" ABC\n")
177
166
  end
178
167
  end
179
168
 
@@ -184,14 +173,21 @@ describe Bovem::Console do
184
173
  allow(console).to receive(:line_width).and_return(80)
185
174
 
186
175
  expect(console.format_right(message)).to eq("\e[A\e[0G\e[#{75}CABCDE")
187
- expect(console.format_right(message, 10)).to eq("\e[A\e[0G\e[#{-5}CABCDE")
176
+ expect(console.format_right(message, width: 10)).to eq("\e[A\e[0G\e[#{-5}CABCDE")
188
177
  expect(console.format_right(extended_message)).to eq("\e[A\e[0G\e[#{75}CABC\e[AD\e[3mE")
189
- expect(console.format_right(message, nil, false)).to eq("\e[0G\e[#{75}CABCDE")
178
+ expect(console.format_right(message, width: nil, go_up: false)).to eq("\e[0G\e[#{75}CABCDE")
190
179
  allow(console).to receive(:line_width).and_return(10)
191
180
  expect(console.format_right(message)).to eq("\e[A\e[0G\e[#{5}CABCDE")
192
181
  end
193
182
  end
194
183
 
184
+ describe "#replace_markers" do
185
+ it "should just forwards to .replace_markers" do
186
+ expect(Bovem::Console).to receive(:replace_markers).with("A", "B")
187
+ console.replace_markers("A", "B")
188
+ end
189
+ end
190
+
195
191
  describe "#emphasize" do
196
192
  it "should correctly emphasize messages" do
197
193
  expect(console.emphasize("MSG")).to eq("{mark=bright}MSG{/mark}")
@@ -201,41 +197,41 @@ describe Bovem::Console do
201
197
 
202
198
  describe "#write" do
203
199
  it "should call #format" do
204
- expect(console).to receive(:format).with("A", "B", "C", "D", "E")
205
- console.write("A", "B", "C", "D", "E")
200
+ expect(console).to receive(:format).with("A", suffix: "B", indented: "C", wrap: "D", plain: "E")
201
+ console.write("A", suffix: "B", indented: "C", wrap: "D", plain: "E")
206
202
  end
207
203
  end
208
204
 
209
205
  describe "#write_banner_aligned" do
210
206
  it "should call #min_banner_length and #format" do
211
207
  expect(Bovem::Console).to receive(:min_banner_length).and_return(1)
212
- expect(console).to receive(:format).with(" A", "B", "C", "D", "E")
213
- console.write_banner_aligned("A", "B", "C", "D", "E")
208
+ expect(console).to receive(:write).with(" A", suffix: "B", indented: "C", wrap: "D", plain: "E", print: "F")
209
+ console.write_banner_aligned("A", suffix: "B", indented: "C", wrap: "D", plain: "E", print: "F")
214
210
  end
215
211
  end
216
212
 
217
213
  describe "#get_banner" do
218
214
  it "should correctly format arguments" do
219
215
  expect(console.get_banner("LABEL", "red")).to eq("{mark=blue}[{mark=red}LABEL{/mark}]{/mark}")
220
- expect(console.get_banner("LABEL", "red", true)).to eq("{mark=red}[{mark=red}LABEL{/mark}]{/mark}")
221
- expect(console.get_banner("LABEL", "red", false, "yellow")).to eq("{mark=yellow}[{mark=red}LABEL{/mark}]{/mark}")
222
- expect(console.get_banner("LABEL", "red", false, "blue", nil)).to eq("{mark=blue}{mark=red}LABEL{/mark}{/mark}")
223
- expect(console.get_banner("LABEL", "red", false, "blue", "A")).to eq("{mark=blue}A{mark=red}LABEL{/mark}{/mark}")
224
- expect(console.get_banner("LABEL", "red", false, "blue", ["A", "B"])).to eq("{mark=blue}A{mark=red}LABEL{/mark}B{/mark}")
216
+ expect(console.get_banner("LABEL", "red", full_colored: true)).to eq("{mark=red}[{mark=red}LABEL{/mark}]{/mark}")
217
+ expect(console.get_banner("LABEL", "red", bracket_color: "yellow")).to eq("{mark=yellow}[{mark=red}LABEL{/mark}]{/mark}")
218
+ expect(console.get_banner("LABEL", "red", brackets: nil)).to eq("{mark=blue}{mark=red}LABEL{/mark}{/mark}")
219
+ expect(console.get_banner("LABEL", "red", brackets: "A")).to eq("{mark=blue}A{mark=red}LABEL{/mark}{/mark}")
220
+ expect(console.get_banner("LABEL", "red", brackets: ["A", "B"])).to eq("{mark=blue}A{mark=red}LABEL{/mark}B{/mark}")
225
221
  end
226
222
  end
227
223
 
228
224
  describe "#info" do
229
225
  it "should forward everything to #get_banner" do
230
- expect(console).to receive(:get_banner).with("I", "bright cyan", false).at_least(1).and_return("")
231
- console.info("OK", "\n", true, false, false, false, false, false)
232
- expect(console).to receive(:get_banner).with("I", "bright cyan", true).at_least(1).and_return("")
233
- console.info("OK", "\n", true, false, false, false, true, false)
226
+ expect(console).to receive(:get_banner).with("I", "bright cyan", full_colored: false).at_least(1).and_return("")
227
+ console.info("OK", suffix: "\n", full_colored: false)
228
+ expect(console).to receive(:get_banner).with("I", "bright cyan", full_colored: true).at_least(1).and_return("")
229
+ console.info("OK", suffix: "\n", full_colored: true)
234
230
  end
235
231
 
236
232
  it "should forward everything to #write" do
237
- expect(console).to receive(:write).with(/.+/, "B", "C", "D", "E", false)
238
- console.info("A", "B", "C", "D", "E", "F", "G", false)
233
+ expect(console).to receive(:write).with(/.+/, suffix: "B", indented: 0, wrap: "D", plain: "E", print: false)
234
+ console.info("A", suffix: "B", indented: "C", wrap: "D", plain: "E", print: false)
239
235
  end
240
236
  end
241
237
 
@@ -246,96 +242,98 @@ describe Bovem::Console do
246
242
  end
247
243
 
248
244
  it "should format good percentage progresses" do
249
- expect(console.progress(1, 100, :percentage)).to eq(" 1 %")
250
- expect(console.progress(33, 100, :percentage)).to eq(" 33 %")
251
- expect(console.progress(1400, 100, :percentage)).to eq("1400 %")
252
- expect(console.progress(50, 70, :percentage)).to eq(" 71 %")
253
- expect(console.progress(50, 70, :percentage, 2)).to eq(" 71.43 %")
254
- expect(console.progress(50, 70, :percentage, 3)).to eq(" 71.429 %")
255
- expect(console.progress(0, 0, :percentage)).to eq("100 %")
256
- expect(console.progress(1, 0, :percentage)).to eq("100 %")
257
- expect(console.progress(0, 100, :percentage)).to eq(" 0 %")
245
+ expect(console.progress(1, 100, type: :percentage)).to eq(" 1 %")
246
+ expect(console.progress(33, 100, type: :percentage)).to eq(" 33 %")
247
+ expect(console.progress(1400, 100, type: :percentage)).to eq("1400 %")
248
+ expect(console.progress(50, 70, type: :percentage)).to eq(" 71 %")
249
+ expect(console.progress(50, 70, type: :percentage, precision: 2)).to eq(" 71.43 %")
250
+ expect(console.progress(50, 70, type: :percentage, precision: 3)).to eq(" 71.429 %")
251
+ expect(console.progress(0, 0, type: :percentage)).to eq("100 %")
252
+ expect(console.progress(1, 0, type: :percentage)).to eq("100 %")
253
+ expect(console.progress(0, 100, type: :percentage)).to eq(" 0 %")
258
254
  end
259
255
  end
260
256
 
261
257
  describe "#begin" do
262
258
  it "should forward everything to #get_banner" do
263
- expect(console).to receive(:get_banner).with("*", "bright green", false).at_least(1).and_return("")
264
- console.begin("OK", "\n", true, false, false, false, false, false)
259
+ expect(console).to receive(:get_banner).with("*", "bright green", full_colored: false).at_least(1).and_return("")
260
+ console.begin("OK", suffix: "\n", full_colored: false)
261
+ expect(console).to receive(:get_banner).with("*", "bright green", full_colored: true).at_least(1).and_return("")
262
+ console.begin("OK", suffix: "\n", full_colored: true)
265
263
  end
266
264
 
267
265
  it "should forward everything to #write" do
268
- expect(console).to receive(:write).with(/.+/, "B", "C", "D", "E", false)
269
- console.begin("A", "B", "C", "D", "E", "F", "G", false)
266
+ expect(console).to receive(:write).with(/.+/, suffix: "B", indented: 0, wrap: "D", plain: "E", print: false)
267
+ console.begin("A", suffix: "B", indented: "C", wrap: "D", plain: "E", print: false)
270
268
  end
271
269
  end
272
270
 
273
271
  describe "#warn" do
274
272
  it "should forward everything to #get_banner" do
275
- expect(console).to receive(:get_banner).with("W", "bright yellow", false).at_least(1).and_return("")
276
- console.warn("OK", "\n", true, false, false, false, false, false)
277
- expect(console).to receive(:get_banner).with("W", "bright yellow", true).at_least(1).and_return("")
278
- console.warn("OK", "\n", true, false, false, false, true, false)
273
+ expect(console).to receive(:get_banner).with("W", "bright yellow", full_colored: false).at_least(1).and_return("")
274
+ console.warn("OK", suffix: "\n", full_colored: false)
275
+ expect(console).to receive(:get_banner).with("W", "bright yellow", full_colored: true).at_least(1).and_return("")
276
+ console.warn("OK", suffix: "\n", full_colored: true)
279
277
  end
280
278
 
281
279
  it "should forward everything to #write" do
282
- expect(console).to receive(:write).with(/.+/, "B", "C", "D", "E", false)
283
- console.warn("A", "B", "C", "D", "E", "F", "G", false)
280
+ expect(console).to receive(:write).with(/.+/, suffix: "B", indented: 0, wrap: "D", plain: "E", print: false)
281
+ console.warn("A", suffix: "B", indented: "C", wrap: "D", plain: "E", print: false)
284
282
  end
285
283
  end
286
284
 
287
285
  describe "#error" do
288
286
  it "should forward everything to #get_banner" do
289
- expect(console).to receive(:get_banner).with("E", "bright red", false).at_least(1).and_return("")
290
- console.error("OK", "\n", true, false, false, false, false, false)
291
- expect(console).to receive(:get_banner).with("E", "bright red", true).at_least(1).and_return("")
292
- console.error("OK", "\n", true, false, false, false, true, false)
287
+ expect(console).to receive(:get_banner).with("E", "bright red", full_colored: false).at_least(1).and_return("")
288
+ console.error("OK", suffix: "\n", full_colored: false)
289
+ expect(console).to receive(:get_banner).with("E", "bright red", full_colored: true).at_least(1).and_return("")
290
+ console.error("OK", suffix: "\n", full_colored: true)
293
291
  end
294
292
 
295
293
  it "should forward everything to #write" do
296
- expect(console).to receive(:write).with(/.+/, "B", "C", "D", "E", false)
297
- console.error("A", "B", "C", "D", "E", "F", "G", false)
294
+ expect(console).to receive(:write).with(/.+/, suffix: "B", indented: 0, wrap: "D", plain: "E", print: false)
295
+ console.error("A", suffix: "B", indented: "C", wrap: "D", plain: "E", print: false)
298
296
  end
299
297
  end
300
298
 
301
299
  describe "#fatal" do
302
300
  it "should forward anything to #error" do
303
301
  allow(Kernel).to receive(:exit).and_return(true)
304
- expect(console).to receive(:error).with("A", "B", "C", "D", "E", "F", "G", false)
305
- console.fatal("A", "B", "C", "D", "E", "F", "G", "H", false)
302
+ expect(console).to receive(:error).with("A", suffix: "B", indented: "C", wrap: "D", plain: "E", indented_banner: "F", full_colored: "G", print: true)
303
+ console.fatal("A", suffix: "B", indented: "C", wrap: "D", plain: "E", indented_banner: "F", full_colored: "G")
306
304
  end
307
305
 
308
306
  it "should call abort with the right error code" do
309
307
  allow(Kernel).to receive(:exit).and_return(true)
310
308
 
311
309
  expect(Kernel).to receive(:exit).with(-1).exactly(2)
312
- console.fatal("A", "B", "C", "D", "E", "F", "G", -1, false)
313
- console.fatal("A", "B", "C", "D", "E", "F", "G", "H", false)
310
+ console.fatal("A", suffix: "B", indented: "C", wrap: "D", plain: "E", indented_banner: "F", full_colored: "G", return_code: -1, print: false)
311
+ console.fatal("A", suffix: "B", indented: "C", wrap: "D", plain: "E", indented_banner: "F", full_colored: "G", return_code: "H", print: false)
314
312
  end
315
313
  end
316
314
 
317
315
  describe "#debug" do
318
316
  it "should forward everything to #get_banner" do
319
- expect(console).to receive(:get_banner).with("D", "bright magenta", false).at_least(1).and_return("")
320
- console.debug("OK", "\n", true, false, false, false, false, false)
321
- expect(console).to receive(:get_banner).with("D", "bright magenta", true).at_least(1).and_return("")
322
- console.debug("OK", "\n", true, false, false, false, true, false)
317
+ expect(console).to receive(:get_banner).with("D", "bright magenta", full_colored: false).at_least(1).and_return("")
318
+ console.debug("OK", suffix: "\n", full_colored: false)
319
+ expect(console).to receive(:get_banner).with("D", "bright magenta", full_colored: true).at_least(1).and_return("")
320
+ console.debug("OK", suffix: "\n", full_colored: true)
323
321
  end
324
322
 
325
323
  it "should forward everything to #write" do
326
- expect(console).to receive(:write).with(/.+/, "B", "C", "D", "E", false)
327
- console.debug("A", "B", "C", "D", "E", "F", "G", false)
324
+ expect(console).to receive(:write).with(/.+/, suffix: "B", indented: 0, wrap: "D", plain: "E", print: false)
325
+ console.debug("A", suffix: "B", indented: "C", wrap: "D", plain: "E", print: false)
328
326
  end
329
327
  end
330
328
 
331
329
  describe "#status" do
332
330
  it "should get the right status" do
333
- expect(console.status(:ok, false, true, false)).to eq({label: " OK ", color: "bright green"})
334
- expect(console.status(:pass, false, true, false)).to eq({label: "PASS", color: "bright cyan"})
335
- expect(console.status(:warn, false, true, false)).to eq({label: "WARN", color: "bright yellow"})
336
- expect(console.status(:fail, false, true, false)).to eq({label: "FAIL", color: "bright red"})
337
- expect(console.status("NO", false, true, false)).to eq({label: " OK ", color: "bright green"})
338
- expect(console.status(nil, false, true, false)).to eq({label: " OK ", color: "bright green"})
331
+ expect(console.status(:ok, print: false)).to eq({label: " OK ", color: "bright green"})
332
+ expect(console.status(:pass, print: false)).to eq({label: "PASS", color: "bright cyan"})
333
+ expect(console.status(:warn, print: false)).to eq({label: "WARN", color: "bright yellow"})
334
+ expect(console.status(:fail, print: false)).to eq({label: "FAIL", color: "bright red"})
335
+ expect(console.status("NO", print: false)).to eq({label: " OK ", color: "bright green"})
336
+ expect(console.status(nil, print: false)).to eq({label: " OK ", color: "bright green"})
339
337
  end
340
338
 
341
339
  it "should create the banner" do
@@ -344,10 +342,11 @@ describe Bovem::Console do
344
342
  end
345
343
 
346
344
  it "should format correctly" do
347
- expect(console).to receive(:format_right).with(/.+/, true, true, false)
348
- console.status(:ok, false, true)
349
- expect(console).to receive(:format).with(/.+/, "\n", true, true, false)
350
- console.status(:ok, false, true, false)
345
+ expect(console).to receive(:format_right).with(/.+/, width: true, go_up: true, plain: false)
346
+ expect(console).to receive(:format).with(/.+/, suffix: "\n", indent: true, wrap: true, plain: false)
347
+
348
+ console.status(:ok)
349
+ console.status(:ok, right: false)
351
350
  end
352
351
  end
353
352
 
@@ -357,30 +356,30 @@ describe Bovem::Console do
357
356
 
358
357
  prompt = "PROMPT"
359
358
  expect(Kernel).to receive(:print).with("Please insert a value: ")
360
- console.read(true)
359
+ console.read(prompt: true)
361
360
  expect(Kernel).to receive(:print).with(prompt + ": ")
362
- console.read(prompt)
361
+ console.read(prompt: prompt)
363
362
  expect(Kernel).not_to receive("print")
364
- console.read(nil)
363
+ console.read(prompt: nil)
365
364
  end
366
365
 
367
366
  it "should read a value or a default" do
368
367
  allow($stdin).to receive(:gets).and_return("VALUE\n")
369
- expect(console.read(nil, "DEFAULT")).to eq("VALUE")
368
+ expect(console.read(prompt: nil, default_value: "DEFAULT")).to eq("VALUE")
370
369
  allow($stdin).to receive(:gets).and_return("\n")
371
- expect(console.read(nil, "DEFAULT")).to eq("DEFAULT")
370
+ expect(console.read(prompt: nil, default_value: "DEFAULT")).to eq("DEFAULT")
372
371
  end
373
372
 
374
373
  it "should return the default value if the user quits" do
375
374
  allow($stdin).to receive(:gets).and_raise(Interrupt)
376
- expect(console.read(nil, "DEFAULT")).to eq("DEFAULT")
375
+ expect(console.read(prompt: nil, default_value: "DEFAULT")).to eq("DEFAULT")
377
376
  end
378
377
 
379
378
  it "should validate against an object or array validator" do
380
379
  count = 0
381
380
 
382
381
  allow($stdin).to receive(:gets) do
383
- if count == 0 then
382
+ if count == 0
384
383
  count += 1
385
384
  "2\n"
386
385
  else
@@ -390,13 +389,13 @@ describe Bovem::Console do
390
389
 
391
390
  expect(console).to receive(:write).with("Sorry, your reply was not understood. Please try again.", false, false).exactly(4)
392
391
  count = 0
393
- console.read(nil, nil, "A")
392
+ console.read(prompt: nil, validator: "A")
394
393
  count = 0
395
- console.read(nil, nil, "1")
394
+ console.read(prompt: nil, validator: "1")
396
395
  count = 0
397
- console.read(nil, nil, "nil")
396
+ console.read(prompt: nil, validator: "nil")
398
397
  count = 0
399
- console.read(nil, nil, ["A", 1])
398
+ console.read(prompt: nil, validator: ["A", 1])
400
399
  end
401
400
 
402
401
  it "should validate against an regexp validator" do
@@ -412,12 +411,12 @@ describe Bovem::Console do
412
411
  end
413
412
 
414
413
  expect(console).to receive(:write).with("Sorry, your reply was not understood. Please try again.", false, false)
415
- console.read(nil, nil, /[abc]/)
414
+ console.read(prompt: nil, validator: /[abc]/)
416
415
  end
417
416
 
418
417
  it "should hide echo to the user when the terminal shows echo" do
419
418
  expect($stdin).to receive(:noecho).and_return("VALUE")
420
- console.read(nil, nil, nil, false)
419
+ console.read(prompt: nil, echo: false)
421
420
  end
422
421
  end
423
422
 
@@ -428,9 +427,9 @@ describe Bovem::Console do
428
427
  end
429
428
 
430
429
  it "should print the message and indentate correctly" do
431
- expect(console).to receive(:begin).with("A", "B", "C", "D", "E", "F", "G")
430
+ expect(console).to receive(:begin).with("A", suffix: "B", indented: "C", wrap: "D", plain: "E", indented_banner: "F", full_colored: "G")
432
431
  expect(console).to receive(:with_indentation).with("H", "I")
433
- console.task("A", "B", "C", "D", "E", "F", "G", "H", "I") { :ok }
432
+ console.task("A", suffix: "B", indented: "C", wrap: "D", plain: "E", indented_banner: "F", full_colored: "G", block_indentation: "H", block_indentation_absolute: "I") { :ok }
434
433
  end
435
434
 
436
435
  it "should execute the given block" do
@@ -440,9 +439,9 @@ describe Bovem::Console do
440
439
 
441
440
  it "should write the correct status" do
442
441
  allow(console).to receive(:begin)
443
- expect(console).to receive(:status).with(:ok, false)
442
+ expect(console).to receive(:status).with(:ok, plain: false)
444
443
  console.task("OK") { :ok }
445
- expect(console).to receive(:status).with(:fail, false)
444
+ expect(console).to receive(:status).with(:fail, plain: false)
446
445
  expect { console.task("") { :fatal }}.to raise_error(SystemExit)
447
446
  end
448
447