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 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
- test/test_ArgsParser.rb
13
- test/test_helper.rb
11
+ tasks/rspec.rake
12
+ spec/parser_spec.rb
13
+ spec/spec.opts
14
+ spec/spec_helper.rb
data/README.rdoc CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  == FEATURES/PROBLEMS:
10
10
 
11
- *
11
+
12
12
 
13
13
  == SYNOPSIS:
14
14
 
data/Rakefile CHANGED
@@ -21,3 +21,4 @@ Dir['tasks/**/*.rake'].each { |t| load t }
21
21
  # TODO - want other tests/tasks run by default? Add them to the list
22
22
  # remove_task :default
23
23
  # task :default => [:spec, :features]
24
+
data/examples/example.rb CHANGED
@@ -22,6 +22,7 @@ if parser.has_option(:help) or !parser.has_params(required_params)
22
22
  }
23
23
  puts 'e.g. ruby example.rb -f frame.png -m "hello world" -s 320x240 -debug'
24
24
  puts '-'*30
25
+ exit 1
25
26
  end
26
27
 
27
28
  if parser.has_param(:size)
data/lib/ArgsParser.rb CHANGED
@@ -4,8 +4,9 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  directory = File.expand_path(File.dirname(__FILE__))
5
5
 
6
6
  require File.join(directory, 'ArgsParser', 'Parser')
7
+
7
8
  module ArgsParser
8
- VERSION = '0.0.3'
9
+ VERSION = '0.0.4'
9
10
 
10
11
  def ArgsParser.parser
11
12
  Parser.new
@@ -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
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
+ require 'ArgsParser'
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
- - 3
9
- version: 0.0.3
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-11 00:00:00 +09:00
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
- - test/test_ArgsParser.rb
86
- - test/test_helper.rb
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
- - test/test_ArgsParser.rb
120
- - test/test_helper.rb
118
+ test_files: []
119
+
data/PostInstall.txt DELETED
@@ -1,7 +0,0 @@
1
-
2
- For more information on ArgsParser, see http://ArgsParser.rubyforge.org
3
-
4
- NOTE: Change this information in PostInstall.txt
5
- You can also delete it if you don't want it.
6
-
7
-
@@ -1,15 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class TestArgsParser < Test::Unit::TestCase
4
-
5
- def setup
6
- end
7
-
8
- def test_truth
9
- assert true
10
- end
11
-
12
- def
13
- ArgsParser.parse()
14
- end
15
- end
data/test/test_helper.rb DELETED
@@ -1,3 +0,0 @@
1
- require 'stringio'
2
- require 'test/unit'
3
- require File.dirname(__FILE__) + '/../lib/ArgsParser'