hammer_cli 3.7.0 → 3.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/bin/hammer +1 -6
  3. data/doc/release_notes.md +15 -0
  4. data/lib/hammer_cli/help/builder.rb +1 -2
  5. data/lib/hammer_cli/i18n/find_task.rb +88 -0
  6. data/lib/hammer_cli/i18n.rb +4 -0
  7. data/lib/hammer_cli/options/normalizers.rb +2 -5
  8. data/lib/hammer_cli/settings.rb +7 -0
  9. data/lib/hammer_cli/task_helper.rb +84 -0
  10. data/lib/hammer_cli/testing/output_matchers.rb +1 -1
  11. data/lib/hammer_cli/utils.rb +1 -1
  12. data/lib/hammer_cli/version.rb +1 -1
  13. data/locale/Makefile.def +29 -7
  14. data/locale/ca/LC_MESSAGES/hammer-cli.mo +0 -0
  15. data/locale/cs_CZ/LC_MESSAGES/hammer-cli.mo +0 -0
  16. data/locale/de/LC_MESSAGES/hammer-cli.mo +0 -0
  17. data/locale/en/LC_MESSAGES/hammer-cli.mo +0 -0
  18. data/locale/en_GB/LC_MESSAGES/hammer-cli.mo +0 -0
  19. data/locale/es/LC_MESSAGES/hammer-cli.mo +0 -0
  20. data/locale/fr/LC_MESSAGES/hammer-cli.mo +0 -0
  21. data/locale/it/LC_MESSAGES/hammer-cli.mo +0 -0
  22. data/locale/ja/LC_MESSAGES/hammer-cli.mo +0 -0
  23. data/locale/ka/LC_MESSAGES/hammer-cli.mo +0 -0
  24. data/locale/ko/LC_MESSAGES/hammer-cli.mo +0 -0
  25. data/locale/pt_BR/LC_MESSAGES/hammer-cli.mo +0 -0
  26. data/locale/ru/LC_MESSAGES/hammer-cli.mo +0 -0
  27. data/locale/zh_CN/LC_MESSAGES/hammer-cli.mo +0 -0
  28. data/locale/zh_TW/LC_MESSAGES/hammer-cli.mo +0 -0
  29. data/man/hammer.1.gz +0 -0
  30. data/test/functional/help_test.rb +1 -1
  31. data/test/test_helper.rb +1 -1
  32. data/test/unit/abstract_test.rb +54 -54
  33. data/test/unit/apipie/command_test.rb +26 -27
  34. data/test/unit/apipie/option_builder_test.rb +28 -28
  35. data/test/unit/apipie/option_definition_test.rb +5 -5
  36. data/test/unit/apipie/test_helper.rb +3 -0
  37. data/test/unit/bash_test.rb +21 -21
  38. data/test/unit/command_extensions_test.rb +68 -68
  39. data/test/unit/completer_test.rb +57 -57
  40. data/test/unit/csv_parser_test.rb +12 -12
  41. data/test/unit/defaults_test.rb +3 -3
  42. data/test/unit/help/builder_test.rb +7 -7
  43. data/test/unit/help/definition/abstract_item_test.rb +2 -2
  44. data/test/unit/help/definition/list_test.rb +2 -2
  45. data/test/unit/help/definition/note_test.rb +2 -2
  46. data/test/unit/help/definition/section_test.rb +2 -2
  47. data/test/unit/help/definition/text_test.rb +2 -2
  48. data/test/unit/help/definition_test.rb +36 -36
  49. data/test/unit/help/text_builder_test.rb +39 -39
  50. data/test/unit/history_test.rb +6 -6
  51. data/test/unit/i18n_test.rb +2 -2
  52. data/test/unit/logger_test.rb +1 -1
  53. data/test/unit/main_test.rb +7 -7
  54. data/test/unit/modules_test.rb +24 -25
  55. data/test/unit/option_builder_test.rb +1 -1
  56. data/test/unit/options/matcher_test.rb +15 -15
  57. data/test/unit/options/normalizers_test.rb +92 -88
  58. data/test/unit/options/option_definition_test.rb +11 -11
  59. data/test/unit/options/option_family_test.rb +7 -7
  60. data/test/unit/options/validators/dsl_test.rb +35 -35
  61. data/test/unit/output/adapter/abstract_test.rb +10 -10
  62. data/test/unit/output/adapter/base_test.rb +36 -36
  63. data/test/unit/output/adapter/csv_test.rb +38 -38
  64. data/test/unit/output/adapter/json_test.rb +38 -38
  65. data/test/unit/output/adapter/table_test.rb +42 -50
  66. data/test/unit/output/adapter/yaml_test.rb +38 -38
  67. data/test/unit/output/definition_test.rb +43 -43
  68. data/test/unit/output/dsl_test.rb +19 -19
  69. data/test/unit/output/field_filter_test.rb +10 -10
  70. data/test/unit/output/fields_test.rb +27 -27
  71. data/test/unit/output/formatters_test.rb +39 -39
  72. data/test/unit/output/output_test.rb +14 -14
  73. data/test/unit/output/record_collection_test.rb +18 -18
  74. data/test/unit/settings_test.rb +35 -35
  75. data/test/unit/utils_test.rb +30 -27
  76. metadata +33 -44
@@ -28,26 +28,26 @@ describe HammerCLI::Modules do
28
28
 
29
29
  describe "names" do
30
30
  it "must return list of modules" do
31
- HammerCLI::Modules.names.must_equal ["hammer_cli_jerry", "hammer_cli_tom"]
31
+ _(HammerCLI::Modules.names).must_equal ["hammer_cli_jerry", "hammer_cli_tom"]
32
32
  end
33
33
 
34
34
  it "must return empty array by default" do
35
35
  HammerCLI::Settings.clear
36
- HammerCLI::Modules.names.must_equal []
36
+ _(HammerCLI::Modules.names).must_equal []
37
37
  end
38
38
  end
39
39
 
40
40
  describe "find by name" do
41
41
  it "must return nil if the module does not exist" do
42
- HammerCLI::Modules.find_by_name("hammer_cli_unknown").must_equal nil
42
+ assert_nil HammerCLI::Modules.find_by_name("hammer_cli_unknown")
43
43
  end
44
44
 
45
45
  it "must must find the module" do
46
- HammerCLI::Modules.find_by_name("hammer_cli_jerry").must_equal HammerCliJerry
46
+ _(HammerCLI::Modules.find_by_name("hammer_cli_jerry")).must_equal HammerCliJerry
47
47
  end
48
48
 
49
49
  it "must find the module with capital CLI in it's name" do
50
- HammerCLI::Modules.find_by_name("hammer_cli_tom").must_equal HammerCLITom
50
+ _(HammerCLI::Modules.find_by_name("hammer_cli_tom")).must_equal HammerCLITom
51
51
  end
52
52
  end
53
53
 
@@ -67,7 +67,7 @@ describe HammerCLI::Modules do
67
67
  })
68
68
  HammerCLI::Modules.stubs(:load).returns(nil)
69
69
  HammerCLI::Modules.stubs(:loaded_modules).returns(['hammer_cli_jerry', 'hammer_cli_tom'])
70
- proc { HammerCLI::Modules.load_all }.must_raise HammerCLI::ModuleDisabledButRequired
70
+ assert_raises(HammerCLI::ModuleDisabledButRequired) { HammerCLI::Modules.load_all }
71
71
  end
72
72
  end
73
73
 
@@ -85,15 +85,15 @@ describe HammerCLI::Modules do
85
85
  it "must log module's name and version" do
86
86
  HammerCLI::Modules.expects(:require_module).with("hammer_cli_tom")
87
87
  HammerCLI::Modules.load("hammer_cli_tom")
88
- @log_output.readline.strip.must_equal "INFO Modules : Extension module hammer_cli_tom (0.0.1) loaded."
88
+ _(@log_output.readline.strip).must_equal "INFO Modules : Extension module hammer_cli_tom (0.0.1) loaded."
89
89
  end
90
90
 
91
91
  it "must return true when load succeeds" do
92
- HammerCLI::Modules.load("hammer_cli_tom").must_equal true
92
+ _(HammerCLI::Modules.load("hammer_cli_tom")).must_equal true
93
93
  end
94
94
 
95
95
  it "must return true when load! succeeds" do
96
- HammerCLI::Modules.load!("hammer_cli_tom").must_equal true
96
+ _(HammerCLI::Modules.load!("hammer_cli_tom")).must_equal true
97
97
  end
98
98
  end
99
99
 
@@ -105,21 +105,21 @@ describe HammerCLI::Modules do
105
105
 
106
106
  it "must log an error if the load! fails" do
107
107
  capture_io do
108
- proc { HammerCLI::Modules.load!("hammer_cli_tom") }.must_raise LoadError
108
+ assert_raises(LoadError) { HammerCLI::Modules.load!("hammer_cli_tom") }
109
109
  end
110
- @log_output.readline.strip.must_equal @error_msg
110
+ _(@log_output.readline.strip).must_equal @error_msg
111
111
  end
112
112
 
113
113
  it "must log an error if the load fails" do
114
114
  capture_io do
115
115
  HammerCLI::Modules.load("hammer_cli_tom")
116
116
  end
117
- @log_output.readline.strip.must_equal @error_msg
117
+ _(@log_output.readline.strip).must_equal @error_msg
118
118
  end
119
119
 
120
120
  it "must return false when load fails" do
121
121
  capture_io do
122
- HammerCLI::Modules.load("hammer_cli_tom").must_equal false
122
+ _(HammerCLI::Modules.load("hammer_cli_tom")).must_equal false
123
123
  end
124
124
  end
125
125
  end
@@ -132,25 +132,24 @@ describe HammerCLI::Modules do
132
132
  end
133
133
 
134
134
  it "must log an error if the load! fails" do
135
- proc {
136
- proc {
137
- HammerCLI::Modules.load!("hammer_cli_tom")
138
- }.must_output("#{@warning_msg}\n", "")
139
- }.must_raise RuntimeError
140
- @log_output.readline.strip.must_equal @error_msg
135
+ out, _ = capture_io do
136
+ assert_raises(RuntimeError) { HammerCLI::Modules.load!('hammer_cli_tom') }
137
+ end
138
+ _(out).must_equal "#{@warning_msg}\n"
139
+ _(@log_output.readline.strip).must_equal @error_msg
141
140
  end
142
141
 
143
142
  it "must log an error if the load fails" do
144
- proc {
143
+ assert_output("#{@warning_msg}\n", "") do
145
144
  HammerCLI::Modules.load("hammer_cli_tom")
146
- }.must_output("#{@warning_msg}\n", "")
147
- @log_output.readline.strip.must_equal @error_msg
145
+ end
146
+ _(@log_output.readline.strip).must_equal @error_msg
148
147
  end
149
148
 
150
149
  it "must return false when load fails" do
151
- proc {
152
- HammerCLI::Modules.load("hammer_cli_tom").must_equal false
153
- }.must_output("#{@warning_msg}\n", "")
150
+ assert_output("#{@warning_msg}\n", "") do
151
+ _(HammerCLI::Modules.load("hammer_cli_tom")).must_equal false
152
+ end
154
153
  end
155
154
  end
156
155
 
@@ -17,7 +17,7 @@ describe HammerCLI::OptionBuilderContainer do
17
17
  builder.stubs(:build).returns(options)
18
18
 
19
19
  container.builders = [builder, builder]
20
- container.build.must_equal options+options
20
+ _(container.build).must_equal options+options
21
21
  end
22
22
 
23
23
  it "passes build parameters from contained builders" do
@@ -12,17 +12,17 @@ describe HammerCLI::Options::Matcher do
12
12
  matcher = HammerCLI::Options::Matcher.new(
13
13
  :long_switch => '--opt_a1'
14
14
  )
15
- matcher.matches?(option_a1).must_equal true
16
- matcher.matches?(option_a2).must_equal false
15
+ _(matcher.matches?(option_a1)).must_equal true
16
+ _(matcher.matches?(option_a2)).must_equal false
17
17
  end
18
18
 
19
19
  it "tests regex" do
20
20
  matcher = HammerCLI::Options::Matcher.new(
21
21
  :long_switch => /--opt_a.*/
22
22
  )
23
- matcher.matches?(option_a1).must_equal true
24
- matcher.matches?(option_a2).must_equal true
25
- matcher.matches?(option_b1).must_equal false
23
+ _(matcher.matches?(option_a1)).must_equal true
24
+ _(matcher.matches?(option_a2)).must_equal true
25
+ _(matcher.matches?(option_b1)).must_equal false
26
26
  end
27
27
 
28
28
  it "tests multiple conditions" do
@@ -30,32 +30,32 @@ describe HammerCLI::Options::Matcher do
30
30
  :long_switch => /--opt_.1/,
31
31
  :type => 'OPT_A'
32
32
  )
33
- matcher.matches?(option_a1).must_equal true
34
- matcher.matches?(option_a2).must_equal false
35
- matcher.matches?(option_a3).must_equal false
36
- matcher.matches?(option_b1).must_equal false
33
+ _(matcher.matches?(option_a1)).must_equal true
34
+ _(matcher.matches?(option_a2)).must_equal false
35
+ _(matcher.matches?(option_a3)).must_equal false
36
+ _(matcher.matches?(option_b1)).must_equal false
37
37
  end
38
38
 
39
39
  it "tests multiple values or regexes" do
40
40
  matcher = HammerCLI::Options::Matcher.new(
41
41
  :long_switch => [/--opt_.1/, "--opt_a3"]
42
42
  )
43
- matcher.matches?(option_a1).must_equal true
44
- matcher.matches?(option_a2).must_equal false
45
- matcher.matches?(option_a3).must_equal true
46
- matcher.matches?(option_b1).must_equal true
43
+ _(matcher.matches?(option_a1)).must_equal true
44
+ _(matcher.matches?(option_a2)).must_equal false
45
+ _(matcher.matches?(option_a3)).must_equal true
46
+ _(matcher.matches?(option_b1)).must_equal true
47
47
  end
48
48
 
49
49
  it "tests nil for unknown methods" do
50
50
  matcher = HammerCLI::Options::Matcher.new(
51
51
  :unknown_method => "some value"
52
52
  )
53
- matcher.matches?(option_a1).must_equal false
53
+ _(matcher.matches?(option_a1)).must_equal false
54
54
 
55
55
  matcher = HammerCLI::Options::Matcher.new(
56
56
  :unknown_method => nil
57
57
  )
58
- matcher.matches?(option_a1).must_equal true
58
+ _(matcher.matches?(option_a1)).must_equal true
59
59
  end
60
60
 
61
61
  end