optitron 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -134,5 +134,5 @@ Now, try running it.
134
134
  crapbook-pro:optitron joshua$ ruby test.rb install file
135
135
  installing file with {"verbose"=>false}!
136
136
 
137
- crapbook-pro:optitron joshua$ ruby test.rb install file --verbose true
137
+ crapbook-pro:optitron joshua$ ruby test.rb install file --verbose
138
138
  installing file with {"verbose"=>true}!
@@ -84,7 +84,7 @@ class Optitron
84
84
  when :boolean
85
85
  value = if opt_tok.respond_to?(:value)
86
86
  opt_tok.value
87
- elsif opt_tok.name == name and tokens[opt_tok_index].respond_to?(:val) and BOOLEAN_VALUES.include?(tokens[opt_tok_index].val)
87
+ elsif opt_tok.name == short_name and tokens[opt_tok_index].respond_to?(:val) and BOOLEAN_VALUES.include?(tokens[opt_tok_index].val)
88
88
  tokens.delete_at(opt_tok_index).val
89
89
  end
90
90
  response.params_array << [self, value.nil? ? !default : value]
@@ -1,3 +1,3 @@
1
1
  class Optitron
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -25,6 +25,30 @@ describe "Optitron::Parser options" do
25
25
  end
26
26
  end
27
27
 
28
+ context "boolean long names vs short names" do
29
+ before(:each) do
30
+ @parser = Optitron.new {
31
+ opt "verbose"
32
+ }
33
+ end
34
+
35
+ it "should parse '-v true'" do
36
+ @parser.parse(%w(-v true)).valid?.should be_true
37
+ end
38
+
39
+ it "shouldn't parse '-v that'" do
40
+ @parser.parse(%w(-v that)).valid?.should be_false
41
+ end
42
+
43
+ it "shouldn't parse '--verbose true'" do
44
+ @parser.parse(%w(--verbose true)).valid?.should be_false
45
+ end
46
+
47
+ it "shouldn't parse '--verbose=true'" do
48
+ @parser.parse(%w(--verbose=true)).valid?.should be_true
49
+ end
50
+ end
51
+
28
52
  context "multiple options" do
29
53
  before(:each) do
30
54
  @parser = Optitron.new {
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optitron
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Joshua Hull