opt 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/lib/opt/option.rb +5 -4
- data/lib/opt/version.rb +1 -1
- data/spec/opt/option_spec.rb +6 -0
- data/spec/opt/switch_spec.rb +1 -0
- data/spec/spec_helper.rb +3 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
M2JlZjg3YjFkYzA5N2QzNjYwNWZmMWQ4ODkwZTc5NjRlZmZhOWNkYw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MjE4NmNlNDMzYzhkNTQ5NDUxYWExNDU1ZGNkYTc4MmFkOGNlZmEwNA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZGI2ZmRjODA3NjU5MmUxYzc1MTMwZTRlZGM4ZmY3YWZmN2YyMDFhNjA2ZmQ3
|
10
|
+
NTlhZTEwYTJiODM1NGJlN2VjMGQ3NTJmNzAxMjk0NjI2NmJmZmI4Zjg1NDdm
|
11
|
+
MjU3N2U0ODdjZDQxMTRiZmQzNGZiMmEyM2M1MTFmNmY2ODgxOGI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
Y2YzYmVkMzM1MWU4NzMwMDY2N2RiNjYzZmEzOGMyZGNhNDA0ZDQzYTNkY2Rj
|
14
|
+
MWRhNWNjZGIyOTI5NzJmYmExNzVmMzY4MThhZDk2OGJhNTA3OTMwZGZkZjRl
|
15
|
+
NzlmMmI1MWJhMDYyZTc1MzRhMWQ2MmYyNzE4NDI5ZWEwNjIwYmQ=
|
data/lib/opt/option.rb
CHANGED
@@ -57,7 +57,7 @@ module Opt
|
|
57
57
|
@switches = Set.new
|
58
58
|
@name = options.fetch(:name, definition).to_s.freeze
|
59
59
|
|
60
|
-
unless nargs.first > 0 || nargs.
|
60
|
+
unless nargs.first > 0 || nargs.last > 0
|
61
61
|
raise 'A text option must consist of at least one argument.'
|
62
62
|
end
|
63
63
|
else
|
@@ -79,7 +79,8 @@ module Opt
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def collide?(option)
|
82
|
-
name == option.name ||
|
82
|
+
name == option.name ||
|
83
|
+
switches.any?{|s1| option.switches.any?{|s2| s1.eql?(s2) }}
|
83
84
|
end
|
84
85
|
|
85
86
|
def parse!(argv, result)
|
@@ -109,7 +110,7 @@ module Opt
|
|
109
110
|
end
|
110
111
|
|
111
112
|
def parse_args!(argv, result)
|
112
|
-
if nargs
|
113
|
+
if nargs == (0..0)
|
113
114
|
result[name] = value
|
114
115
|
else
|
115
116
|
args = []
|
@@ -122,7 +123,7 @@ module Opt
|
|
122
123
|
end
|
123
124
|
|
124
125
|
if nargs.include?(args.size)
|
125
|
-
if nargs
|
126
|
+
if nargs == (1..1)
|
126
127
|
result[name] = args.first
|
127
128
|
else
|
128
129
|
result[name] = args
|
data/lib/opt/version.rb
CHANGED
data/spec/opt/option_spec.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
RSpec::Matchers.define :parse do |*expected|
|
@@ -112,6 +113,11 @@ describe Opt::Option do
|
|
112
113
|
expect(option).to be_text
|
113
114
|
expect(option.name).to eq 'file'
|
114
115
|
end
|
116
|
+
|
117
|
+
it 'should raise error on invalid nargs on free-text' do
|
118
|
+
expect { described_class.new('file', nargs: 0) }.to \
|
119
|
+
raise_error(/A text option must consist of at least one argument/)
|
120
|
+
end
|
115
121
|
end
|
116
122
|
|
117
123
|
describe '#parse!' do
|
data/spec/opt/switch_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
@@ -14,14 +14,14 @@ dependencies:
|
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
27
|
description: An option parsing library. Optional.
|
@@ -58,12 +58,12 @@ require_paths:
|
|
58
58
|
- lib
|
59
59
|
required_ruby_version: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - ! '>='
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
requirements: []
|
@@ -79,3 +79,4 @@ test_files:
|
|
79
79
|
- spec/opt_spec.rb
|
80
80
|
- spec/readme_spec.rb
|
81
81
|
- spec/spec_helper.rb
|
82
|
+
has_rdoc:
|