ArgsParser 0.0.3 → 0.0.4
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/Manifest.txt +4 -3
- data/README.rdoc +1 -1
- data/Rakefile +1 -0
- data/examples/example.rb +1 -0
- data/lib/ArgsParser.rb +2 -1
- data/spec/parser_spec.rb +71 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/tasks/rspec.rake +21 -0
- metadata +9 -10
- data/PostInstall.txt +0 -7
- data/test/test_ArgsParser.rb +0 -15
- data/test/test_helper.rb +0 -3
data/Manifest.txt
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
History.txt
|
2
2
|
Manifest.txt
|
3
|
-
PostInstall.txt
|
4
3
|
README.rdoc
|
5
4
|
Rakefile
|
6
5
|
lib/ArgsParser.rb
|
@@ -9,5 +8,7 @@ examples/example.rb
|
|
9
8
|
script/console
|
10
9
|
script/destroy
|
11
10
|
script/generate
|
12
|
-
|
13
|
-
|
11
|
+
tasks/rspec.rake
|
12
|
+
spec/parser_spec.rb
|
13
|
+
spec/spec.opts
|
14
|
+
spec/spec_helper.rb
|
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
data/examples/example.rb
CHANGED
data/lib/ArgsParser.rb
CHANGED
data/spec/parser_spec.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe "options" do
|
4
|
+
before do
|
5
|
+
@argv = ['-x', '320',
|
6
|
+
'-yscale', '240',
|
7
|
+
'-m', 'hello world',
|
8
|
+
'-h',
|
9
|
+
'--output', '/path/to/output/',
|
10
|
+
'-debug']
|
11
|
+
@parser = ArgsParser.parser
|
12
|
+
@parser.bind(:message, :m, "message text")
|
13
|
+
@parser.bind(:output, :o, "path to output directory")
|
14
|
+
@parser.comment(:debug, "debug mode")
|
15
|
+
@parser.bind(:help, :h, "show help")
|
16
|
+
@parser.bind(:xscale, :x, "width")
|
17
|
+
@parser.bind(:yscale, :y, "height")
|
18
|
+
@params = @parser.parse(@argv)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "has param" do
|
22
|
+
@parser.has_param(:message).should == true
|
23
|
+
@parser.has_param(:output).should == true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "has not param" do
|
27
|
+
@parser.has_param(:m).should == false
|
28
|
+
@parser.has_param(:o).should == false
|
29
|
+
@parser.has_param(:help).should == false
|
30
|
+
@parser.has_param(:name).should == false
|
31
|
+
end
|
32
|
+
|
33
|
+
it "has option" do
|
34
|
+
@parser.has_option(:debug).should == true
|
35
|
+
@parser.has_option(:help).should == true
|
36
|
+
end
|
37
|
+
|
38
|
+
it "has not option" do
|
39
|
+
@parser.has_option(:h).should == false
|
40
|
+
@parser.has_option(:m).should == false
|
41
|
+
@parser.has_option(:message).should == false
|
42
|
+
@parser.has_option(:output).should == false
|
43
|
+
end
|
44
|
+
|
45
|
+
it "has params" do
|
46
|
+
@parser.has_params([:message, :output]).should == true
|
47
|
+
end
|
48
|
+
|
49
|
+
it "has not params" do
|
50
|
+
@parser.has_params([:message, :output, :help]).should == false
|
51
|
+
end
|
52
|
+
|
53
|
+
it "has options" do
|
54
|
+
@parser.has_options([:help, :debug]).should == true
|
55
|
+
end
|
56
|
+
|
57
|
+
it "has not options" do
|
58
|
+
@parser.has_options([:help, :debug, :h]).should == false
|
59
|
+
end
|
60
|
+
|
61
|
+
it "has String in params" do
|
62
|
+
@params[:output].should == '/path/to/output/'
|
63
|
+
end
|
64
|
+
|
65
|
+
it "has Number in params" do
|
66
|
+
@params[:yscale].to_i.should == 240
|
67
|
+
@params[:xscale].to_i.should == 320
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- shokai
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-12 00:00:00 +09:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -69,11 +69,9 @@ extensions: []
|
|
69
69
|
extra_rdoc_files:
|
70
70
|
- History.txt
|
71
71
|
- Manifest.txt
|
72
|
-
- PostInstall.txt
|
73
72
|
files:
|
74
73
|
- History.txt
|
75
74
|
- Manifest.txt
|
76
|
-
- PostInstall.txt
|
77
75
|
- README.rdoc
|
78
76
|
- Rakefile
|
79
77
|
- lib/ArgsParser.rb
|
@@ -82,8 +80,10 @@ files:
|
|
82
80
|
- script/console
|
83
81
|
- script/destroy
|
84
82
|
- script/generate
|
85
|
-
-
|
86
|
-
-
|
83
|
+
- tasks/rspec.rake
|
84
|
+
- spec/parser_spec.rb
|
85
|
+
- spec/spec.opts
|
86
|
+
- spec/spec_helper.rb
|
87
87
|
has_rdoc: true
|
88
88
|
homepage: http://bitbucket.org/shokai/argsparser-ruby
|
89
89
|
licenses: []
|
@@ -115,6 +115,5 @@ rubygems_version: 1.3.6
|
|
115
115
|
signing_key:
|
116
116
|
specification_version: 3
|
117
117
|
summary: "* Parse args form command line."
|
118
|
-
test_files:
|
119
|
-
|
120
|
-
- test/test_helper.rb
|
118
|
+
test_files: []
|
119
|
+
|
data/PostInstall.txt
DELETED
data/test/test_ArgsParser.rb
DELETED
data/test/test_helper.rb
DELETED