optparse-simple 0.2.0 → 0.2.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.
- data/lib/optparse-simple.rb +16 -1
- metadata +2 -2
data/lib/optparse-simple.rb
CHANGED
@@ -5,12 +5,27 @@ class OptParseSimple
|
|
5
5
|
|
6
6
|
def initialize(filename, args)
|
7
7
|
doc = Document.new(File.open(filename,'r').read)
|
8
|
+
|
9
|
+
# -- bind any loose value to their argument
|
10
|
+
xpath = 'records/option/summary[switch != "" and value != ""]'
|
11
|
+
options = XPath.match(doc.root, xpath)
|
12
|
+
.map {|node| %w(switch alias)
|
13
|
+
.map{|x| node.text(x)}.compact}
|
14
|
+
.flatten
|
15
|
+
args.map!.with_index do |x,i|
|
16
|
+
next unless x or i < args.length - 1
|
17
|
+
(x += '=' + args[i+1]; args[i+1] = nil) if options.include?(x)
|
18
|
+
x
|
19
|
+
end
|
20
|
+
args.compact!
|
21
|
+
# -- end of bind any loose value to their argument
|
22
|
+
|
8
23
|
@options = XPath.match(doc.root, 'records/option[summary/switch!=""]')
|
9
24
|
|
10
25
|
switches = @options.map do |option|
|
11
26
|
switch = option.text('summary/switch')
|
12
27
|
switch[0] == '-' ? switch : nil
|
13
|
-
end
|
28
|
+
end
|
14
29
|
|
15
30
|
switches.compact!
|
16
31
|
|
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.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors: []
|
7
7
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-05-
|
12
|
+
date: 2010-05-12 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|