cl 0.1.7 → 0.1.8
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/lib/cl/parser.rb +13 -1
- data/lib/cl/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4995063f3759138d112ed1bb61ce14256bb887150a9ef22034acfe013b591b9
|
4
|
+
data.tar.gz: c1f88f145e4de2f95cb11cabd01ef0488ab0cbc5415e316c11ad6d9e73d32d0e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a63ff04a0835935ac5f284a524bacabb98ad8e294b70f020f246854a8d2843f39a4487fd10710253f84eefd2a63f29e97f25abcaeda33be26f7dc5b69f8ae09
|
7
|
+
data.tar.gz: 9123971310dd5aaba0c38d3f1e0901b22cc40d8301838a068f0f58cf5636a597dc091df405fb06232c161b056d815a1843008b6d79c56ca3b4085c3007e10d7b
|
data/lib/cl/parser.rb
CHANGED
@@ -9,7 +9,7 @@ class Cl
|
|
9
9
|
|
10
10
|
super do
|
11
11
|
opts.each do |opt|
|
12
|
-
on(*opt.strs) do |value|
|
12
|
+
on(*underscore!(opt.strs)) do |value|
|
13
13
|
set(opt, value)
|
14
14
|
end
|
15
15
|
|
@@ -21,6 +21,7 @@ class Cl
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
underscore!(args)
|
24
25
|
parse!(args)
|
25
26
|
end
|
26
27
|
|
@@ -35,5 +36,16 @@ class Cl
|
|
35
36
|
args = args[-opt.block.arity, opt.block.arity]
|
36
37
|
instance_exec(*args, &opt.block)
|
37
38
|
end
|
39
|
+
|
40
|
+
# OptionParser has started accepting dasherized options in 2.4.
|
41
|
+
# We want to support them on any Ruby >= 2.0 version, so we'll
|
42
|
+
# need to normalize things ourselves.
|
43
|
+
|
44
|
+
PATTERN = /^(-{1,2})(\[?no-\]?)?(.*)$/
|
45
|
+
|
46
|
+
def underscore!(strs)
|
47
|
+
return strs if RUBY_VERSION >= '2.4'
|
48
|
+
strs.each { |str| str.gsub!(PATTERN) { "#{$1}#{$2}#{$3.tr('-', '_')}" } }
|
49
|
+
end
|
38
50
|
end
|
39
51
|
end
|
data/lib/cl/version.rb
CHANGED