optbind 0.3.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf2645df5139cfb5f2da9545d463f30b5e2e7fcd
4
- data.tar.gz: 19b95d76da822aa643ba5ee62ad5c00e6ab86ef4
3
+ metadata.gz: 1e7c51a5d7ef46991d57c770ec2ea085618afac9
4
+ data.tar.gz: 0df2427adc39fb0e7af3aee0db9f24786fb05e6f
5
5
  SHA512:
6
- metadata.gz: 33129020311fbd81302a02c87c18a11e8efbfe42f2ed66335b9cfa584dd2c023620918663088365e3147a47ecffef50c3abb40d11cfae29bd128753b2e5549d5
7
- data.tar.gz: 65e76a032087b2590ffa173776c04f3e284ea707c8d1cc0cbdf246794a36cf27c5757dc37dd707bd05202f8a22e7309a6eee9db477924add3b23010e77b99b8e
6
+ metadata.gz: bbab6b6240755ff1606a927f484007ef575ff6141966c489e0626fd2316596c071f1bc54bf66f626e05f926c2ee3244174d77c72b92131ed77738e34eb0afcc1
7
+ data.tar.gz: 17d347012c595802087bfa0114ee4612488f0a804e52d89d35eaa92d1dde6d89ad7a514fd86845caa7cfb5569d34f4e3fc4bb66370c426a4a76536b0b4699742
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.3.1
2
+
3
+ * Fix critical bug when parsing arguments
4
+
5
+ *Pavol Zbell*
6
+
1
7
  ## 0.3.0
2
8
 
3
9
  * Add support for access to assigned variables
@@ -1,3 +1,3 @@
1
1
  module OptBind
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
data/lib/optbind.rb CHANGED
@@ -144,7 +144,7 @@ class OptionBinder
144
144
  n[2] ? "--#{n}" : "-#{n}"
145
145
  end
146
146
 
147
- argument = (hash[:argument].to_s.sub(/\A\[=/, '=[') if hash[:argument])
147
+ argument = (hash[:argument].to_s.sub(/\A(\[)?=?/, '=\1') if hash[:argument])
148
148
  description = ([hash[:description]].flatten * ' ' if hash[:description])
149
149
  handler ||= hash[:handler]
150
150
  return ([style, pattern, values] + names + [argument, description]).compact, handler
@@ -159,19 +159,19 @@ class OptionBinder
159
159
 
160
160
  style, pattern, values, argument = nil
161
161
 
162
- while string.sub!(/\A(?:(?<long>--[\[\]\-\w]+[\]\w]+)?(?:(?<argument>\[?=[<(]\S+[)>]\.{,3}\]?)|\s+))/, '')
162
+ while string.sub!(/\A(?:(?<long>--[\[\]\-\w]+[\]\w]+)?(?:(?<argument>(?:\[?=?|=\[)[<(]\S+[)>]\.{,3}\]?)|\s+))/, '')
163
163
  longs << $~[:long] if $~[:long]
164
164
  next unless $~[:argument]
165
165
  argument = $~[:argument]
166
- style = argument[0] == '=' ? :REQUIRED : :OPTIONAL
167
- values = $~[:values].split('|') if argument =~ /\[?=\((?<values>\S*)\)\]?/
166
+ style = argument =~ /\A=?[<(]/ ? :REQUIRED : :OPTIONAL
167
+ values = $~[:values].split('|') if argument =~ /(?:\[?=?|=\[)\((?<values>\S*)\)\]?/
168
168
 
169
- if values.nil? && argument =~ /\[?=<(?<name>\S+):(?<pattern>\S+)>\]?/
169
+ if values.nil? && argument =~ /(?:\[?=?|=\[)<(?<name>\S+):(?<pattern>\S+)>\]?/
170
170
  pattern = Module.const_get($~[:pattern]) rescue Regexp.new($~[:pattern])
171
171
  argument = "=<#{$~[:name]}>"
172
172
  argument = "=[#{argument[1..-1]}]" if style == :OPTIONAL
173
173
  else
174
- argument.sub!(/\A\[=/, '=[')
174
+ argument.sub!(/\A(?:=\[|\[?=?)/, style == :OPTIONAL ? '=[' : '=')
175
175
  end
176
176
  end
177
177
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optbind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavol Zbell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-14 00:00:00.000000000 Z
11
+ date: 2016-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  version: '0'
73
73
  requirements: []
74
74
  rubyforge_project:
75
- rubygems_version: 2.5.0
75
+ rubygems_version: 2.4.5.1
76
76
  signing_key:
77
77
  specification_version: 4
78
78
  summary: Binds command-line options to variables.