hammer_cli 3.7.0 → 3.8.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.
- checksums.yaml +4 -4
- data/bin/hammer +1 -6
- data/doc/release_notes.md +15 -0
- data/lib/hammer_cli/help/builder.rb +1 -2
- data/lib/hammer_cli/i18n/find_task.rb +88 -0
- data/lib/hammer_cli/i18n.rb +4 -0
- data/lib/hammer_cli/options/normalizers.rb +2 -5
- data/lib/hammer_cli/settings.rb +7 -0
- data/lib/hammer_cli/task_helper.rb +84 -0
- data/lib/hammer_cli/testing/output_matchers.rb +1 -1
- data/lib/hammer_cli/utils.rb +1 -1
- data/lib/hammer_cli/version.rb +1 -1
- data/locale/Makefile.def +29 -7
- data/locale/ca/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/cs_CZ/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/de/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/en/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/en_GB/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/es/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/fr/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/it/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ja/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ka/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ko/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/ru/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli.mo +0 -0
- data/man/hammer.1.gz +0 -0
- data/test/functional/help_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- data/test/unit/abstract_test.rb +54 -54
- data/test/unit/apipie/command_test.rb +26 -27
- data/test/unit/apipie/option_builder_test.rb +28 -28
- data/test/unit/apipie/option_definition_test.rb +5 -5
- data/test/unit/apipie/test_helper.rb +3 -0
- data/test/unit/bash_test.rb +21 -21
- data/test/unit/command_extensions_test.rb +68 -68
- data/test/unit/completer_test.rb +57 -57
- data/test/unit/csv_parser_test.rb +12 -12
- data/test/unit/defaults_test.rb +3 -3
- data/test/unit/help/builder_test.rb +7 -7
- data/test/unit/help/definition/abstract_item_test.rb +2 -2
- data/test/unit/help/definition/list_test.rb +2 -2
- data/test/unit/help/definition/note_test.rb +2 -2
- data/test/unit/help/definition/section_test.rb +2 -2
- data/test/unit/help/definition/text_test.rb +2 -2
- data/test/unit/help/definition_test.rb +36 -36
- data/test/unit/help/text_builder_test.rb +39 -39
- data/test/unit/history_test.rb +6 -6
- data/test/unit/i18n_test.rb +2 -2
- data/test/unit/logger_test.rb +1 -1
- data/test/unit/main_test.rb +7 -7
- data/test/unit/modules_test.rb +24 -25
- data/test/unit/option_builder_test.rb +1 -1
- data/test/unit/options/matcher_test.rb +15 -15
- data/test/unit/options/normalizers_test.rb +92 -88
- data/test/unit/options/option_definition_test.rb +11 -11
- data/test/unit/options/option_family_test.rb +7 -7
- data/test/unit/options/validators/dsl_test.rb +35 -35
- data/test/unit/output/adapter/abstract_test.rb +10 -10
- data/test/unit/output/adapter/base_test.rb +36 -36
- data/test/unit/output/adapter/csv_test.rb +38 -38
- data/test/unit/output/adapter/json_test.rb +38 -38
- data/test/unit/output/adapter/table_test.rb +42 -50
- data/test/unit/output/adapter/yaml_test.rb +38 -38
- data/test/unit/output/definition_test.rb +43 -43
- data/test/unit/output/dsl_test.rb +19 -19
- data/test/unit/output/field_filter_test.rb +10 -10
- data/test/unit/output/fields_test.rb +27 -27
- data/test/unit/output/formatters_test.rb +39 -39
- data/test/unit/output/output_test.rb +14 -14
- data/test/unit/output/record_collection_test.rb +18 -18
- data/test/unit/settings_test.rb +35 -35
- data/test/unit/utils_test.rb +30 -27
- metadata +33 -44
data/test/unit/modules_test.rb
CHANGED
@@ -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")
|
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
|
-
|
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
|
-
|
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
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
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
|
-
|
143
|
+
assert_output("#{@warning_msg}\n", "") do
|
145
144
|
HammerCLI::Modules.load("hammer_cli_tom")
|
146
|
-
|
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
|
-
|
152
|
-
HammerCLI::Modules.load("hammer_cli_tom").must_equal false
|
153
|
-
|
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
|