opt 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4c5e2c614056045ba24f44b7fe368b76bc3c8ae7
4
- data.tar.gz: 42212a7f059c754fd846bbcbd9f5ad6823ca8a57
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ M2JlZjg3YjFkYzA5N2QzNjYwNWZmMWQ4ODkwZTc5NjRlZmZhOWNkYw==
5
+ data.tar.gz: !binary |-
6
+ MjE4NmNlNDMzYzhkNTQ5NDUxYWExNDU1ZGNkYTc4MmFkOGNlZmEwNA==
5
7
  SHA512:
6
- metadata.gz: 29820dfd8267e9fe3e95586b74738e6094949ca4b4d95810522e9a7bf3f1ddc8ff7ae1c55b91f0f3422440a18d4e49c33f43fa6a085028a2e337752871c137c2
7
- data.tar.gz: 9d70b7861cc491645a317f7d608f503682afa42f80951a4163662efd7a78b704d67a8e835b0ecd83c1ca4b20c12bc18deae2479e80e2f15005f76d15ae17863e
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.size > 1
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 || !switches.disjoint?(option.switches)
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.first == 0 && nargs.last == 0
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.first == 1 && nargs.last == 1
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
@@ -1,3 +1,3 @@
1
1
  module Opt
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Opt::Switch do
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  require 'rspec'
2
2
 
3
3
  if ENV['CI'] || ENV['COVERAGE']
4
+ require "codeclimate-test-reporter"
5
+ CodeClimate::TestReporter.start
6
+
4
7
  require 'coveralls'
5
8
  Coveralls.wear! do
6
9
  add_filter 'spec'
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.0
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: