cl 0.1.17 → 0.1.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '08d5d5b99924ab415b3374aa08821148e70f1181'
4
- data.tar.gz: 42d69b175b38e6f19c26dae4001283973266ab86
3
+ metadata.gz: 54b800fbadeb907af1b519de5fdcf782e368c493
4
+ data.tar.gz: f7901ca63ad3a15cad81831c932dac59be139fc8
5
5
  SHA512:
6
- metadata.gz: 22e5ee9fa16e17b14104d7edd9a98afd87c4a0d09506dd9bf135c55a692b89731e42f52541f2d359f8281351e1193dab544431ed7d909f4d9b3efc27eafe0289
7
- data.tar.gz: 9a67c76aa4c3afe578fc219fa73569c2efe86d73cc702684a5a7c3be871f59654604435b24fcc5407beb88e65c4a9778e6c39c00a54a33128b3bd51d956b4a0f
6
+ metadata.gz: d25a93f2eb87df5d1146a86375d1f804f469eadfb22af140ae52df1a531f1ace7a4381f49705f38d82e1bfe69016e14f6e2f5db4f9c151e3881f8c0464d9264f
7
+ data.tar.gz: 56f2c95bccd01fa76d4502a9c2d22fabfc1612cc9c01f0502b67691d4927c64b08d58d6ff98f1318aa315c4078bf624cfc45be4f33735f6476641075b2acb868
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cl (0.1.16)
4
+ cl (0.1.17)
5
5
  regstry (~> 1.0.3)
6
6
 
7
7
  GEM
data/lib/cl/opt.rb CHANGED
@@ -15,7 +15,7 @@ class Cl
15
15
 
16
16
  def initialize(*)
17
17
  super
18
- noize(strs) if type == :flag && default.is_a?(TrueClass)
18
+ noize!(strs) if type == :flag
19
19
  end
20
20
 
21
21
  def define(const)
@@ -64,7 +64,6 @@ class Cl
64
64
  def deprecated
65
65
  return [name, opts[:deprecated]] unless opts[:deprecated].is_a?(Symbol)
66
66
  [opts[:deprecated], name] if opts[:deprecated]
67
- # [name, opts[:deprecated]] if opts[:deprecated]
68
67
  end
69
68
 
70
69
  def downcase?
@@ -183,10 +182,10 @@ class Cl
183
182
  end
184
183
  end
185
184
 
186
- def noize(strs)
185
+ def noize!(strs)
187
186
  strs = strs.select { |str| str.start_with?('--') }
188
187
  strs = strs.reject { |str| str.include?('[no-]') }
189
- strs.each { |str| str.replace(str.sub('--', '--[no-]')) }
188
+ strs.each { |str| str.replace(str.sub('--', '--[no-]')) unless str == '--help' }
190
189
  end
191
190
  end
192
191
  end
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(*underscore!(opt.strs)) do |value|
12
+ on(*dasherize(opt.strs)) do |value|
13
13
  set(opt, value)
14
14
  end
15
15
 
@@ -21,7 +21,7 @@ class Cl
21
21
  end
22
22
  end
23
23
 
24
- underscore!(args)
24
+ dasherize!(args)
25
25
  parse!(args)
26
26
  end
27
27
 
@@ -37,16 +37,12 @@ class Cl
37
37
  instance_exec(*args, &opt.block)
38
38
  end
39
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-\]?)?(.*)$/
40
+ def dasherize(strs)
41
+ strs.map { |str| str.gsub('_', '-') }
42
+ end
45
43
 
46
- def underscore!(strs)
47
- return strs if RUBY_VERSION >= '2.4'
48
- strs.each { |str| str.gsub!(PATTERN) { "#{$1}#{$2}#{$3.tr('-', '_')}" } }
49
- strs.each { |str| str.gsub!(/^--no_/, '--no-') } # ruby < 2.4
44
+ def dasherize!(strs)
45
+ strs.replace(dasherize(strs))
50
46
  end
51
47
  end
52
48
  end
data/lib/cl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Cl
2
- VERSION = '0.1.17'
2
+ VERSION = '0.1.18'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.17
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Fuchs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-12 00:00:00.000000000 Z
11
+ date: 2019-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: regstry