lab42_rgxargs 0.1.3 → 0.1.4

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
  SHA256:
3
- metadata.gz: e7ea5cf52b4dcf047e658abb12af417cbc24a055941f79645eb51f22e0697707
4
- data.tar.gz: f5970679785663ca6ea8e831cc26f060824bc6ea8f79c8f00eebd6502b4b5201
3
+ metadata.gz: dfe60f4e05870ad8a1766abbe5b06b0a6925276696285bb19139ef11aeee70a3
4
+ data.tar.gz: 682386ba4e34b99f53877e0826b0e10f824c3750198c1b6bf66d634de3104d46
5
5
  SHA512:
6
- metadata.gz: c4d7c897da552ee32fa69d40fde98a398fbd274337fb64aa5739ebd01533807cc4e5d185512a5af75a561d805e82eacdad603dd9cba3275bb81866ad68bc71bc
7
- data.tar.gz: 45854555bb805ea65e797cc3b835f440efa2505107a73e5a6b58d4a1c884b2b8776378061a4ea5e6bc50c1a493a9b230dc9b983e39e480819ca702826b86bb6b
6
+ metadata.gz: 87cba6d04bfe08e2df0b1f90ccb273e2dd37594f4b44b15814a0c6def76466e244ae164f6876a9ad83dceee3ee43ffa815a2e5aa1ad877d929d352febdafab32
7
+ data.tar.gz: 75744824c57165417049bc8415315efc29de23a3af3c88a94b4cada576652a47e54ae472097a9819020c563bea93ec0e357fa7dfc3672a65b4e7700deaa402ed
data/lib/lab42/rgxargs.rb CHANGED
@@ -62,7 +62,7 @@ module Lab42
62
62
  conv.(value)
63
63
  when Array
64
64
  if (match = conv.first.match(value))
65
- conv[1].(match.captures)
65
+ conv[1].(*match.captures)
66
66
  else
67
67
  errors << [:syntax_error, name, "#{value} does not match #{conv.first}"]
68
68
  nil
@@ -89,6 +89,9 @@ module Lab42
89
89
  rest
90
90
  when %r{(.*):\z}
91
91
  _parse_value $1.gsub('-', '_').to_sym, rest
92
+ when %r{\A\\(.*)}
93
+ args << $1
94
+ rest
92
95
  else
93
96
  _parse_syntax(first)
94
97
  rest
@@ -13,7 +13,7 @@ class Lab42::Rgxargs::ArgumentMatcher
13
13
  case matcher
14
14
  when Regexp
15
15
  match = matcher.match(value)
16
- match && [converter.(match.captures), arg_name]
16
+ match && [converter.(*match.captures), arg_name]
17
17
  else
18
18
  matcher.to_s == value && [converter.(), arg_name]
19
19
  end
@@ -1,9 +1,9 @@
1
1
  module Lab42::Rgxargs::PredefinedMatchers extend self
2
2
  PREDEFINED = {
3
- int_list: [%r{\A(-?\d+(?:,-?\d+)*)\z}, ->(groups){ groups.first.split(",").map(&:to_i)}],
4
- int_range: [%r{\A(-?\d+)(?:-|\.\.)(-?\d+)\z}, ->((f, l)){ Range.new(f.to_i, l.to_i) }],
5
- list: [%r{(\w+)(?:,(\w+))*}, ->(groups){ groups.compact }],
6
- range: [%r{\A(\d+)\.\.(\d+)\z}, ->(groups){ Range.new(*groups.map(&:to_i)) }]
3
+ int_list: [%r{\A(-?\d+(?:,-?\d+)*)\z}, ->(*groups){ groups.first.split(",").map(&:to_i)}],
4
+ int_range: [%r{\A(-?\d+)(?:-|\.\.)(-?\d+)\z}, ->(f, l){ Range.new(f.to_i, l.to_i) }],
5
+ list: [%r{(\w+)(?:,(\w+))*}, ->(*groups){ groups.compact }],
6
+ range: [%r{\A(\d+)\.\.(\d+)\z}, ->(*groups){ Range.new(*groups.map(&:to_i)) }]
7
7
  }
8
8
 
9
9
  def defined_names
@@ -22,6 +22,6 @@ module Lab42::Rgxargs::PredefinedMatchers extend self
22
22
 
23
23
  # Memoized
24
24
  def _list_extractor
25
- @__list_extractor__ ||= ->(groups){ groups.first.split(",") }
25
+ @__list_extractor__ ||= ->(*groups){ groups.first.split(",") }
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lab42_rgxargs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-18 00:00:00.000000000 Z
11
+ date: 2020-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -62,7 +62,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
62
62
  requirements:
63
63
  - - ">="
64
64
  - !ruby/object:Gem::Version
65
- version: '0'
65
+ version: 2.6.0
66
66
  required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - ">="