args_parser 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.1.2 2012-10-11
2
+
3
+ * access params with String key
4
+
1
5
  === 0.1.1 2012-10-10
2
6
 
3
7
  * bugfix (equal style)
@@ -54,6 +54,7 @@ module ArgsParser
54
54
  end
55
55
 
56
56
  def arg(name, description, opts={})
57
+ name = name.to_sym
57
58
  params[name][:default] = opts[:default]
58
59
  params[name][:description] = description
59
60
  params[name][:index] = params.keys.size
@@ -114,11 +115,11 @@ module ArgsParser
114
115
  end
115
116
 
116
117
  def [](key)
117
- params[key][:value] || params[key][:default]
118
+ params[key.to_sym][:value] || params[key.to_sym][:default]
118
119
  end
119
120
 
120
121
  def []=(key, value)
121
- params[key][:value] = value
122
+ params[key.to_sym][:value] = value
122
123
  end
123
124
 
124
125
  def has_option?(*opt)
data/lib/args_parser.rb CHANGED
@@ -10,5 +10,5 @@ require 'args_parser/validator'
10
10
  require 'args_parser/config'
11
11
 
12
12
  module ArgsParser
13
- VERSION = '0.1.1'
13
+ VERSION = '0.1.2'
14
14
  end
@@ -5,7 +5,7 @@ class TestArgsParser < Test::Unit::TestCase
5
5
  @argv = 'test --input http://shokai.org -a --o ./out -h --depth 030 foo bar --pi 3.14 --n ShoKaI'.split(/\s+/)
6
6
  @parser = ArgsParser.parse @argv do
7
7
  arg :input, 'input', :alias => :i
8
- arg :output, 'output dir', :alias => :o
8
+ arg 'output', 'output dir', :alias => :o
9
9
  arg :name, 'user name', :alias => :n
10
10
  arg :help, 'show help', :alias => :h
11
11
 
@@ -35,6 +35,10 @@ class TestArgsParser < Test::Unit::TestCase
35
35
  assert @parser[:output] == './out'
36
36
  end
37
37
 
38
+ def test_string_access
39
+ assert @parser['output'] == './out'
40
+ end
41
+
38
42
  def test_cast_integer
39
43
  assert @parser[:depth] == 30
40
44
  assert @parser[:depth].class == Fixnum
@@ -4,7 +4,7 @@ class TestArgsParserStyleEqual < Test::Unit::TestCase
4
4
  def setup
5
5
  @argv = 'test --input=http://shokai.org --a --o=./out -h --depth=-030 foo bar --pi=-3.140 --n=ShoKaI'.split(/\s+/)
6
6
  @parser = ArgsParser.parse @argv, :style => :equal do
7
- arg :input, 'input', :alias => :i
7
+ arg 'input', 'input', :alias => :i
8
8
  arg :output, 'output dir', :alias => :o
9
9
  arg :name, 'user name', :alias => :n
10
10
  arg :help, 'show help', :alias => :h
@@ -35,6 +35,10 @@ class TestArgsParserStyleEqual < Test::Unit::TestCase
35
35
  assert @parser[:output] == './out'
36
36
  end
37
37
 
38
+ def test_string_access
39
+ assert @parser['output'] == './out'
40
+ end
41
+
38
42
  def test_cast_integer
39
43
  assert @parser[:depth] == -30
40
44
  assert @parser[:depth].class == Fixnum
metadata CHANGED
@@ -1,80 +1,74 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: args_parser
3
- version: !ruby/object:Gem::Version
4
- hash: 25
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Sho Hashimoto
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-10-09 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- prerelease: false
22
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2012-10-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rdoc
16
+ requirement: !ruby/object:Gem::Requirement
23
17
  none: false
24
- requirements:
18
+ requirements:
25
19
  - - ~>
26
- - !ruby/object:Gem::Version
27
- hash: 19
28
- segments:
29
- - 3
30
- - 10
31
- version: "3.10"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.10'
32
22
  type: :development
33
- name: rdoc
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
23
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.10'
30
+ - !ruby/object:Gem::Dependency
31
+ name: newgem
32
+ requirement: !ruby/object:Gem::Requirement
38
33
  none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 5
43
- segments:
44
- - 1
45
- - 5
46
- - 3
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
47
37
  version: 1.5.3
48
38
  type: :development
49
- name: newgem
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
39
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
54
41
  none: false
55
- requirements:
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.5.3
46
+ - !ruby/object:Gem::Dependency
47
+ name: hoe
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
56
51
  - - ~>
57
- - !ruby/object:Gem::Version
58
- hash: 5
59
- segments:
60
- - 3
61
- - 1
62
- version: "3.1"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.1'
63
54
  type: :development
64
- name: hoe
65
- version_requirements: *id003
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.1'
66
62
  description: Parse ARGV from command line with DSL.
67
- email:
63
+ email:
68
64
  - hashimoto@shokai.org
69
65
  executables: []
70
-
71
66
  extensions: []
72
-
73
- extra_rdoc_files:
67
+ extra_rdoc_files:
74
68
  - History.txt
75
69
  - Manifest.txt
76
70
  - README.rdoc
77
- files:
71
+ files:
78
72
  - Gemfile
79
73
  - Gemfile.lock
80
74
  - History.txt
@@ -102,39 +96,34 @@ files:
102
96
  - .gemtest
103
97
  homepage: http://shokai.github.com/args_parser
104
98
  licenses: []
105
-
106
99
  post_install_message:
107
- rdoc_options:
100
+ rdoc_options:
108
101
  - --main
109
102
  - README.rdoc
110
- require_paths:
103
+ require_paths:
111
104
  - lib
112
- required_ruby_version: !ruby/object:Gem::Requirement
105
+ required_ruby_version: !ruby/object:Gem::Requirement
113
106
  none: false
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- hash: 3
118
- segments:
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ segments:
119
112
  - 0
120
- version: "0"
121
- required_rubygems_version: !ruby/object:Gem::Requirement
113
+ hash: 3219864076564386058
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
115
  none: false
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- hash: 3
127
- segments:
128
- - 0
129
- version: "0"
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
130
120
  requirements: []
131
-
132
121
  rubyforge_project: args_parser
133
122
  rubygems_version: 1.8.24
134
123
  signing_key:
135
124
  specification_version: 3
136
125
  summary: Parse ARGV from command line with DSL.
137
- test_files:
126
+ test_files:
138
127
  - test/test_args_parser.rb
139
128
  - test/test_args_parser_style_equal.rb
140
129
  - test/test_filter.rb