optparse-simple 0.2.6 → 0.2.7
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 +7 -2
- metadata +1 -1
data/lib/optparse-simple.rb
CHANGED
@@ -4,9 +4,9 @@ include REXML
|
|
4
4
|
|
5
5
|
class OptParseSimple
|
6
6
|
|
7
|
-
def initialize(s
|
8
|
-
|
7
|
+
def initialize(s)
|
9
8
|
super()
|
9
|
+
|
10
10
|
if s[/^https?:\/\//] then # url
|
11
11
|
buffer = Kernel.open(s, 'UserAgent' => 'Polyrex-Reader').read
|
12
12
|
elsif s[/\</] # xml
|
@@ -17,6 +17,10 @@ class OptParseSimple
|
|
17
17
|
|
18
18
|
@doc = Document.new(buffer)
|
19
19
|
|
20
|
+
end
|
21
|
+
|
22
|
+
def parse(args)
|
23
|
+
|
20
24
|
@options = XPath.match(@doc.root, 'records/option[summary/switch!=""]')
|
21
25
|
|
22
26
|
switches = @options.map do |option|
|
@@ -61,6 +65,7 @@ class OptParseSimple
|
|
61
65
|
invalid_option = a2.detect {|x,y| x.nil? }.last
|
62
66
|
raise "invalid option: %s not recognised" % invalid_option
|
63
67
|
end
|
68
|
+
self
|
64
69
|
end
|
65
70
|
|
66
71
|
def to_h()
|