lab42_rgxargs 0.1.9 → 0.2.1

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: 63983b6491bb1ce75a959a0bbf95c22d2146468ed7ea45c5281065d96b0c79ba
4
- data.tar.gz: d70cbfbcd144f2d1fe639347592a80d3e3667f62ddb411dc1d3b9eb231492ee1
3
+ metadata.gz: b9f2ee6bdaddb5db512e1cf55c65f42699b2441ac0878760f44c8083ff12f023
4
+ data.tar.gz: 8e4175e4906cc5b5a3511f413b96f27f63cf7eaeaec7c07fe5e851ee2faa6e08
5
5
  SHA512:
6
- metadata.gz: 45318701acaf53c2afe7ee571d2a38af1743bedd3554c514c1a06512ad16c0cb7afed0a3cf427ff44e0c67f8bf75e7b21f63703c18ac892dea562b712cbccb7d
7
- data.tar.gz: 19d9bf8c3d67f10a6848a368996717418eec67873141edc862d4a4cc1ece1703acddc041fa25393d05eaabc8fca77142d5c3213b99ffce0012d8e2d9d60556ff
6
+ metadata.gz: 33a12fa2ce1f98386d28bdd1c99a18fc982545fb26030c5a6dd618f5ce75e2276dfc06f91a4c9bbe6bb6867550be9a9a2aa95ca18d67244f4c3861409d4d58fe
7
+ data.tar.gz: 022b992b251e8027bb19e1a91810abc066fac549b4d74ff77d43ecfa3c8ceae7bd41311b3161d7f7546ba187673307385c522f272a677aa0e81c54250c4ca0af
@@ -15,7 +15,7 @@ module Lab42
15
15
  missing = required - options.to_h.keys
16
16
  @errors += missing.map(&_mk_pair(:required_kwd_missing))
17
17
  end
18
-
18
+
19
19
 
20
20
  def _mk_pair(prefix)
21
21
  -> element do
@@ -24,7 +24,7 @@ module Lab42
24
24
  end
25
25
 
26
26
  def _check_switch(_)
27
-
27
+
28
28
  end
29
29
 
30
30
 
@@ -1,5 +1,6 @@
1
1
  module Lab42::Rgxargs::PredefinedMatchers extend self
2
2
  PREDEFINED = {
3
+ existing_dirs: [%r{(.+)}, ->(glob){ Dir.glob(glob).filter{ File.directory?(_1) } }],
3
4
  int: [%r{\A([-+]?\d+)\z}, :to_i.to_proc],
4
5
  int_list: [%r{\A(-?\d+(?:,-?\d+)*)\z}, ->(*groups){ groups.first.split(",").map(&:to_i)}],
5
6
  int_range: [%r{\A(-?\d+)(?:-|\.\.)(-?\d+)\z}, ->(f, l){ Range.new(f.to_i, l.to_i) }],
@@ -1,5 +1,5 @@
1
1
  module Lab42
2
2
  class Rgxargs
3
- VERSION = "0.1.9"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
data/lib/lab42/rgxargs.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'forwardable'
2
2
  require 'ostruct'
3
3
  require 'lab42/enumerable'
4
+ require 'set'
4
5
  module Lab42
5
6
 
6
7
  class Rgxargs
@@ -19,6 +20,10 @@ module Lab42
19
20
 
20
21
  attr_reader :allowed, :args, :conversions, :defaults, :defined_rules, :errors, :options, :required, :syntaxes
21
22
 
23
+ def predefined_matchers
24
+ Predefined.defined_names
25
+ end
26
+
22
27
 
23
28
  def add_conversion(param, conversion=nil, required=nil, &block)
24
29
  case conversion
@@ -54,7 +59,6 @@ module Lab42
54
59
  [options, args, errors]
55
60
  end
56
61
 
57
-
58
62
  def allows name, matcher=nil, &converter
59
63
  add_conversion(name, matcher, &converter)
60
64
  end
@@ -72,11 +76,11 @@ module Lab42
72
76
  @defaults = {}
73
77
  @defined_rules = []
74
78
  @errors = []
75
- @required = Set.new
79
+ @required = ::Set.new
76
80
  @syntaxes = []
77
81
 
78
82
  instance_exec(&blk) if blk
79
- @options = OpenStruct.new(defaults)
83
+ @options = ::OpenStruct.new(defaults)
80
84
  end
81
85
 
82
86
  def _convert(value, name:)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lab42_rgxargs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Dober
@@ -94,14 +94,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
- version: 2.7.0
97
+ version: 3.1.0
98
98
  required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  requirements: []
104
- rubygems_version: 3.1.2
104
+ rubygems_version: 3.3.3
105
105
  signing_key:
106
106
  specification_version: 4
107
107
  summary: Parse CL args according to regexen