lucie-lib 0.0.20 → 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lucie/validators/mandatory_option.rb +4 -1
- data/lib/lucie/version.rb +1 -1
- data/lucie-lib.gemspec +1 -0
- data/test/fixtures/command_parser_fixtures.rb +17 -4
- data/test/functional/app_test.rb +12 -3
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ba29b920b702de3ef30c503fd5443bdb17556b3
|
4
|
+
data.tar.gz: 942edb65990bb556630bc172c1708c538143972f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 332c09f53af5787823467ef1b4c91a5b18645ba3aea03cce020c6910920e6085e68f71590214281617c8778c19a3d83fce760f97711ec69cfd2680206300c5ab
|
7
|
+
data.tar.gz: 43d194c86db40c664b6b2e19f8707af182524fe7ece3b5cd5fde1c4df9c654af2a96a7a63811e59eaf0ba6a9bf84bb23a25249fc0029191e0387c6cf22534138
|
@@ -7,7 +7,10 @@ module Lucie
|
|
7
7
|
|
8
8
|
class Validator < Base
|
9
9
|
def apply(params)
|
10
|
-
|
10
|
+
if !params[:"#{short_option.gsub(/^-*/, '')}"] &&
|
11
|
+
!params[:"#{long_option.gsub(/^--*/, '')}"]
|
12
|
+
fail RequestError.new(self)
|
13
|
+
end
|
11
14
|
end
|
12
15
|
end
|
13
16
|
|
data/lib/lucie/version.rb
CHANGED
data/lucie-lib.gemspec
CHANGED
@@ -26,16 +26,28 @@ class OptionalMandatoryController < Controller::Base
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
class
|
30
|
-
|
29
|
+
class ParameterPairingMandatoryController < Controller::Base
|
30
|
+
mandatory "-e", "--expression", "Search expression"
|
31
31
|
|
32
32
|
def search_short
|
33
|
-
print params[:
|
33
|
+
print params[:e]
|
34
34
|
end
|
35
35
|
|
36
36
|
def search_long
|
37
|
+
print params[:expression]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class ParameterPairingOptionalController < Controller::Base
|
42
|
+
optional "-e", "--expression", "Search expression"
|
43
|
+
|
44
|
+
def search_short
|
37
45
|
print params[:e]
|
38
46
|
end
|
47
|
+
|
48
|
+
def search_long
|
49
|
+
print params[:expression]
|
50
|
+
end
|
39
51
|
end
|
40
52
|
|
41
53
|
class ExitValueController < Controller::Base
|
@@ -72,4 +84,5 @@ class MethodShouldBeRemovedController < Controller::Base
|
|
72
84
|
def call_this_method
|
73
85
|
print params[:args][0]
|
74
86
|
end
|
75
|
-
end
|
87
|
+
end
|
88
|
+
|
data/test/functional/app_test.rb
CHANGED
@@ -41,9 +41,18 @@ describe App do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
should "be able to pair parameters" do
|
45
|
-
assert_output("some_string", nil) { TestApp.run("
|
46
|
-
assert_output("some_string", nil) { TestApp.run("
|
44
|
+
should "be able to pair optional parameters" do
|
45
|
+
assert_output("some_string", nil) { TestApp.run("parameter_pairing_optional search_short -e some_string") }
|
46
|
+
assert_output("some_string", nil) { TestApp.run("parameter_pairing_optional search_long -e some_string") }
|
47
|
+
assert_output("some_string", nil) { TestApp.run("parameter_pairing_optional search_short --expression some_string") }
|
48
|
+
assert_output("some_string", nil) { TestApp.run("parameter_pairing_optional search_long --expression some_string") }
|
49
|
+
end
|
50
|
+
|
51
|
+
should "be able to pair mandatory parameters" do
|
52
|
+
assert_output("some_string", nil) { TestApp.run("parameter_pairing_mandatory search_short -e some_string") }
|
53
|
+
assert_output("some_string", nil) { TestApp.run("parameter_pairing_mandatory search_long -e some_string") }
|
54
|
+
assert_output("some_string", nil) { TestApp.run("parameter_pairing_mandatory search_short --expression some_string") }
|
55
|
+
assert_output("some_string", nil) { TestApp.run("parameter_pairing_mandatory search_long --expression some_string") }
|
47
56
|
end
|
48
57
|
|
49
58
|
should "write to stderr that no controller found when controller is missing" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lucie-lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nucc
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: m
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.3.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.3.1
|
69
83
|
description: Command line utility framework
|
70
84
|
email:
|
71
85
|
- nucc@bteam.hu
|