dry_option_parser 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/dry_option_parser_example.rb +12 -10
- data/lib/dry_option_parser/version.rb +1 -1
- data/lib/dry_option_parser.rb +1 -1
- data/spec/refactored_optionparser_spec.rb +11 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f2ef69e05bb350dc77b839f08832c4dce09f5c1
|
4
|
+
data.tar.gz: ef5e9b6c05fe8bfa426a5d71dbc2f52ffbf4bb15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65a62be0815faa7b0c5c6641a571450340fa78997402842d577ab674718e99b7d88cf30e2491f014cb30fa91e6747907aaa31ce62c738f6eff31c5b0fcfc76e7
|
7
|
+
data.tar.gz: a2a757c8a66efa38d2dfefca8a6d25ca8c8f244aa94dbbd1a00adb97b0a6db02ff49760ce53982a82975e73f158f16f421d8084ac8e597ee4d36c9c5fad074c3
|
@@ -17,24 +17,24 @@ opt_parser = cli_options(options) do
|
|
17
17
|
codes = %w[iso-2022-jp shift_jis euc-jp utf8 binary]
|
18
18
|
code_aliases = { "jis" => "iso-2022-jp", "sjis" => "shift_jis" }
|
19
19
|
|
20
|
-
self.banner = "Usage: example.rb [
|
20
|
+
self.banner = "Usage: example.rb [options]"
|
21
21
|
|
22
22
|
separator ""
|
23
|
-
separator "Specific
|
23
|
+
separator "Specific options:"
|
24
24
|
|
25
25
|
# Mandatory argument.
|
26
|
-
|
26
|
+
on("-r", "--require LIBRARY",
|
27
27
|
"Require the LIBRARY before executing your script") do |lib|
|
28
|
-
|
28
|
+
options.library << lib
|
29
29
|
end
|
30
30
|
|
31
31
|
# Optional argument; multi-line description.
|
32
32
|
on("-i", "--inplace [EXTENSION]",
|
33
33
|
"Edit ARGV files in place",
|
34
34
|
" (make backup if EXTENSION supplied)") do |ext|
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
options.inplace = true
|
36
|
+
options.extension = ext || ''
|
37
|
+
options.extension.sub!(/\A\.?(?=.)/, ".") # Ensure extension begins with dot.
|
38
38
|
end
|
39
39
|
|
40
40
|
# Cast 'delay' argument to a Float.
|
@@ -64,12 +64,12 @@ opt_parser = cli_options(options) do
|
|
64
64
|
on("-v", "--[no-]verbose", "Run verbosely", "verbose")
|
65
65
|
|
66
66
|
separator ""
|
67
|
-
separator "Common
|
67
|
+
separator "Common options:"
|
68
68
|
|
69
|
-
# No argument, shows at tail. This will print an
|
69
|
+
# No argument, shows at tail. This will print an options summary.
|
70
70
|
# Try it and see!
|
71
71
|
on_tail("-h", "--help", "Show this message") do
|
72
|
-
puts
|
72
|
+
puts options
|
73
73
|
exit
|
74
74
|
end
|
75
75
|
|
@@ -82,4 +82,6 @@ end
|
|
82
82
|
|
83
83
|
opt_parser.parse!(ARGV)
|
84
84
|
options = opt_parser.options
|
85
|
+
p options
|
86
|
+
p ARGV
|
85
87
|
|
data/lib/dry_option_parser.rb
CHANGED
@@ -22,24 +22,24 @@ describe "DryOptionParser--the long OptionParser example" do
|
|
22
22
|
codes = %w[iso-2022-jp shift_jis euc-jp utf8 binary]
|
23
23
|
code_aliases = { "jis" => "iso-2022-jp", "sjis" => "shift_jis" }
|
24
24
|
|
25
|
-
self.banner = "Usage: example.rb [
|
25
|
+
self.banner = "Usage: example.rb [options]"
|
26
26
|
|
27
27
|
separator ""
|
28
|
-
separator "Specific
|
28
|
+
separator "Specific options:"
|
29
29
|
|
30
30
|
# Mandatory argument.
|
31
|
-
|
31
|
+
on( "-r", "--require LIBRARY",
|
32
32
|
"Require the LIBRARY before executing your script") do |lib|
|
33
|
-
|
33
|
+
options.library << lib
|
34
34
|
end
|
35
35
|
|
36
36
|
# Optional argument; multi-line description.
|
37
37
|
on("-i", "--inplace [EXTENSION]",
|
38
38
|
"Edit ARGV files in place",
|
39
39
|
" (make backup if EXTENSION supplied)") do |ext|
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
options.inplace = true
|
41
|
+
options.extension = ext || ''
|
42
|
+
options.extension.sub!(/\A\.?(?=.)/, ".") # Ensure extension begins with dot.
|
43
43
|
end
|
44
44
|
|
45
45
|
# Cast 'delay' argument to a Float.
|
@@ -69,9 +69,9 @@ describe "DryOptionParser--the long OptionParser example" do
|
|
69
69
|
on("-v", "--[no-]verbose", "Run verbosely", "verbose")
|
70
70
|
|
71
71
|
separator ""
|
72
|
-
separator "Common
|
72
|
+
separator "Common options:"
|
73
73
|
|
74
|
-
# No argument, shows at tail. This will print an
|
74
|
+
# No argument, shows at tail. This will print an options summary.
|
75
75
|
# Try it and see!
|
76
76
|
on_tail("-h", "--help", "Show this message") do
|
77
77
|
puts opts
|
@@ -100,6 +100,8 @@ describe "DryOptionParser--the long OptionParser example" do
|
|
100
100
|
|
101
101
|
it "-r something should add library" do
|
102
102
|
subject.parse!(%w[-r foo])
|
103
|
+
library = subject.options[:library]
|
104
|
+
expect(library).to be_an(Array)
|
103
105
|
expect(subject.options[:library]).to include("foo")
|
104
106
|
end
|
105
107
|
it "--delay 7 should assign a delay of 7.0" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry_option_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petr Skocik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|