optparse-simple 0.4.4 → 0.4.5

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: a6b5f043c99689f3caba79090e8088dbbe2f46f9
4
- data.tar.gz: 541094409e54628ac4dcb27287b8e49c98fdf3cf
3
+ metadata.gz: ea3a3a04d3463032d7b2c0cd3120a8999705fd5a
4
+ data.tar.gz: 8c49b1a26f92d43c712ef2caf996d48d12b16c23
5
5
  SHA512:
6
- metadata.gz: aae95cf6610d9b3faf19d1a6a916de6c2a6124efb872f28b7bf14c2842bef91f5cdb8c47a85bd35bf77ec867077918996c5904cc3180308e59cd5aa52549607b
7
- data.tar.gz: 3903b7fb61f5746984fda6076458d81c3403adc07b08d39f0a76e8e2143e11f8a9d3091933931bf63cf470adb970569025d2a90ff7bfd99270d53a5e3d1ecb75
6
+ metadata.gz: 9f95efa9b778a9fb9965c0d70e5fa155d7bc81a00b3acf875c43cb78d5ac9bda5137c635fec282e794216d42159eae3084a102829d694112149c3e4ac4ed649f
7
+ data.tar.gz: 4ca8bfc69bfc82d4204ec470ee63cbdec94113bfbf95da78176fb775bb2c8537f305b35c330638ef6e48817527c0b30faa88c14fbc4a4c8b3421c4d4de50ede4
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -50,12 +50,14 @@ class OptParseSimple
50
50
  .map {|node| %w(switch alias)\
51
51
  .map{|x| node.text(x)}.compact}\
52
52
  .flatten
53
+ puts 'after flatten 2'
53
54
  args.map!.with_index do |x,i|
54
55
  next unless x or i < args.length - 1
55
56
  (x += '=' + args[i+1]; args[i+1] = nil) if options.include?(x)
56
57
  x
57
58
  end
58
- args.compact!
59
+ args.compact!
60
+
59
61
  # -- end of bind any loose value to their argument
60
62
 
61
63
  a1 = []
@@ -77,8 +79,9 @@ class OptParseSimple
77
79
  end
78
80
 
79
81
  a2 = args.zip(options_remaining).map(&:reverse)
82
+
80
83
  if a2.map(&:first).all? then
81
- @h = Hash[*(a1+a2).map{|x,y| [x.to_s.strip.to_sym, y]}.flatten]
84
+ @h = Hash[*(a1+a2).map{|x,y| [x.to_s.strip.to_sym, y || true]}.flatten]
82
85
  else
83
86
  invalid_option = a2.detect {|x,y| x.nil? }.last
84
87
  raise "invalid option: %s not recognised" % invalid_option
@@ -105,8 +108,10 @@ class OptParseSimple
105
108
  def options_match(option, args)
106
109
 
107
110
  switch, switch_alias = option.text('summary/switch'), option.text('summary/alias')
108
- switch_pattern = switch_alias ? "(%s|%s)" % [switch, switch_alias] : switch
111
+ switch_pattern = switch_alias ? "(%s|%s)" % [switch, switch_alias] : switch
112
+
109
113
  switch_matched, arg_index = args.each_with_index.detect {|x,j| x[/^#{switch_pattern}/]}
114
+
110
115
  key, value = nil
111
116
 
112
117
  if switch_matched then
@@ -164,11 +169,11 @@ class OptParseSimple
164
169
  end
165
170
 
166
171
  def readx(s)
167
-
168
- r = if s[/\s/] then
169
- Polyrex.new('options/optionx[name,switch,alias,value,mandatory]/errorx[msg]').parse(s).to_xml
170
- elsif s.is_a? Polyrex then
172
+
173
+ r = if s.is_a? Polyrex then
171
174
  s.to_xml
175
+ elsif s[/\s/] then
176
+ Polyrex.new('options/optionx[name,switch,alias,value,mandatory]/errorx[msg]').parse(s).to_xml
172
177
  elsif s[/^https?:\/\//] then # url
173
178
  Kernel.open(s, 'UserAgent' => 'Polyrex-Reader').read
174
179
  elsif s[/\</] # xml
@@ -176,8 +181,8 @@ class OptParseSimple
176
181
  else # local file
177
182
  File.read s
178
183
  end
179
-
184
+
180
185
  r
181
186
  end
182
187
 
183
- end
188
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optparse-simple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  reMUqAcVi3UK52Ugibv74I27D9zJTDYgqRMX3SevcEFrJo+g8ulq9nmVLQ3T+YB/
32
32
  BlF5+4+5WNopaw==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-02-09 00:00:00.000000000 Z
34
+ date: 2015-07-10 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: polyrex
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  version: '0'
101
101
  requirements: []
102
102
  rubyforge_project:
103
- rubygems_version: 2.2.2
103
+ rubygems_version: 2.4.8
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: optparse-simple
metadata.gz.sig CHANGED
Binary file