args_parser 0.1.2 → 0.1.3

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.
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ *~
3
+ pkg/*
4
+ .\#*
5
+ *\#*
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
- gem 'hoe', '>= 2.1.0'
4
- gem 'newgem'
3
+ # Specify your gem's dependencies in args_parser.gemspec
4
+ gemspec
5
+ gem 'minitest'
@@ -1,3 +1,7 @@
1
+ === 0.1.3 2013-01-04
2
+
3
+ * use bundler gem template
4
+
1
5
  === 0.1.2 2012-10-11
2
6
 
3
7
  * access params with String key
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Sho Hashimoto
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,86 @@
1
+ args_parser
2
+ ===========
3
+
4
+ * Parse ARGV from command line with DSL.
5
+ * http://shokai.github.com/args_parser
6
+
7
+
8
+ Requirements
9
+ ------------
10
+ * Ruby 1.8.7+
11
+ * Ruby 1.9.3+
12
+ * JRuby 1.6.7+
13
+
14
+
15
+ Install
16
+ -------
17
+
18
+ % gem install args_parser
19
+
20
+
21
+ Synopsis
22
+ --------
23
+
24
+ % ruby samples/download_webpage.rb -url http://example.com -o out.html
25
+
26
+
27
+ parse ARGV
28
+ ```ruby
29
+ require 'rubygems'
30
+ require 'args_parser'
31
+
32
+ parser = ArgsParser.parse ARGV do
33
+ arg :url, 'URL', :alias => :u
34
+ arg :output, 'output file', :alias => :o, :default => 'out.html'
35
+ arg :verbose, 'verbose mode'
36
+ arg :help, 'show help', :alias => :h
37
+
38
+ filter :url do |v|
39
+ v.to_s.strip
40
+ end
41
+
42
+ validate :url, "invalid URL" do |v|
43
+ v =~ /^https?:\/\/.+$/
44
+ end
45
+ end
46
+
47
+ if parser.has_option? :help or !parser.has_param?(:url, :output)
48
+ STDERR.puts parser.help
49
+ exit 1
50
+ end
51
+
52
+ require 'open-uri'
53
+ puts 'download..' if parser[:verbose]
54
+ open(parser[:output], 'w+') do |f|
55
+ f.write open(parser[:url]).read
56
+ end
57
+ puts "saved! => #{parser[:output]}"
58
+ ```
59
+
60
+ equal style
61
+
62
+ % ruby samples/twitter_timeline.rb --user=shokai --fav --rt
63
+
64
+ parse equal style ARGV
65
+ ```ruby
66
+ parser = ArgsParser.parse ARGV, :style => :equal do
67
+ ```
68
+
69
+ see more samples https://github.com/shokai/args_parser/tree/master/samples
70
+
71
+
72
+ Test
73
+ ----
74
+
75
+ % gem install bundler
76
+ % bundle install
77
+ % rake test
78
+
79
+
80
+ Contributing
81
+ ------------
82
+ 1. Fork it
83
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
84
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
85
+ 4. Push to the branch (`git push origin my-new-feature`)
86
+ 5. Create new Pull Request
data/Rakefile CHANGED
@@ -1,25 +1,8 @@
1
- require 'rubygems'
2
- gem 'hoe', '>= 2.1.0'
3
- require 'hoe'
4
- require 'fileutils'
5
- require './lib/args_parser'
6
-
7
- Hoe.plugin :newgem
8
- # Hoe.plugin :website
9
- # Hoe.plugin :cucumberfeatures
10
-
11
- # Generate all the Rake tasks
12
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
- $hoe = Hoe.spec 'args_parser' do
14
- self.developer 'Sho Hashimoto', 'hashimoto@shokai.org'
15
- self.rubyforge_name = self.name # TODO this is default value
16
- # self.extra_deps = [['newgem','>= 1.5.3']]
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
17
3
 
4
+ Rake::TestTask.new do |t|
5
+ t.pattern = "test/test_*.rb"
18
6
  end
19
7
 
20
- require 'newgem/tasks'
21
- Dir['tasks/**/*.rake'].each { |t| load t }
22
-
23
- # TODO - want other tests/tasks run by default? Add them to the list
24
- # remove_task :default
25
- # task :default => [:spec, :features]
8
+ task :default => :test
@@ -0,0 +1,18 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'args_parser/version'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "args_parser"
7
+ gem.version = ArgsParser::VERSION
8
+ gem.authors = ["Sho Hashimoto"]
9
+ gem.email = ["hashimoto@shokai.org"]
10
+ gem.description = %q{Parse ARGV from command line with DSL.}
11
+ gem.summary = gem.description
12
+ gem.homepage = "http://shokai.github.com/args_parser"
13
+
14
+ gem.files = `git ls-files`.split($/).reject{|i| i=="Gemfile.lock" }
15
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = ["lib"]
18
+ end
@@ -8,7 +8,4 @@ require 'args_parser/error'
8
8
  require 'args_parser/filter'
9
9
  require 'args_parser/validator'
10
10
  require 'args_parser/config'
11
-
12
- module ArgsParser
13
- VERSION = '0.1.2'
14
- end
11
+ require 'args_parser/version'
@@ -0,0 +1,3 @@
1
+ module ArgsParser
2
+ VERSION = '0.1.3'
3
+ end
@@ -1,6 +1,6 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
1
+ require File.expand_path 'test_helper', File.dirname(__FILE__)
2
2
 
3
- class TestArgsParser < Test::Unit::TestCase
3
+ class TestArgsParser < MiniTest::Unit::TestCase
4
4
  def setup
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
@@ -64,13 +64,14 @@ class TestArgsParser < Test::Unit::TestCase
64
64
  def test_has_param?
65
65
  assert @parser.has_param? :input
66
66
  assert @parser.has_param? :output
67
+ assert @parser.has_param? 'output'
67
68
  assert @parser.has_param? :depth
68
69
  assert @parser.has_param? :pi
69
70
  assert @parser.has_param? :name
70
71
  end
71
72
 
72
73
  def test_has_params?
73
- assert @parser.has_param? :input, :output, :depth, :pi, :name
74
+ assert @parser.has_param? :input, :output, 'depth', :pi, :name
74
75
  end
75
76
 
76
77
  def test_has_not_param?
@@ -78,12 +79,13 @@ class TestArgsParser < Test::Unit::TestCase
78
79
  end
79
80
 
80
81
  def test_has_option?
81
- assert @parser.has_option? :help
82
+ assert @parser.has_option? :help
83
+ assert @parser.has_option? 'help'
82
84
  assert @parser.has_option? :a
83
85
  end
84
86
 
85
87
  def test_has_options?
86
- assert @parser.has_option? :help, :a
88
+ assert @parser.has_option? :help, 'a'
87
89
  end
88
90
 
89
91
  def test_has_not_option?
@@ -1,6 +1,6 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
1
+ require File.expand_path 'test_helper', File.dirname(__FILE__)
2
2
 
3
- class TestArgsParserStyleEqual < Test::Unit::TestCase
3
+ class TestArgsParserStyleEqual < MiniTest::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
@@ -1,6 +1,6 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
1
+ require File.expand_path 'test_helper', File.dirname(__FILE__)
2
2
 
3
- class TestArgsParserFilter < Test::Unit::TestCase
3
+ class TestArgsParserFilter < MiniTest::Unit::TestCase
4
4
  def setup
5
5
  @argv = ['--count', '35']
6
6
  @@err = nil
@@ -1,4 +1,6 @@
1
+ require 'rubygems'
1
2
  require 'bundler/setup'
2
- require 'stringio'
3
- require 'test/unit'
4
- require File.dirname(__FILE__) + '/../lib/args_parser'
3
+ require 'minitest/autorun'
4
+
5
+ $:.unshift File.expand_path '../lib', File.dirname(__FILE__)
6
+ require 'args_parser'
@@ -1,6 +1,6 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
1
+ require File.expand_path 'test_helper', File.dirname(__FILE__)
2
2
 
3
- class TestArgsParserValidator < Test::Unit::TestCase
3
+ class TestArgsParserValidator < MiniTest::Unit::TestCase
4
4
  def setup
5
5
  @argv = ['--url', 'hptt://shokai.org']
6
6
  @@err = nil
@@ -0,0 +1,7 @@
1
+ require File.expand_path 'test_helper', File.dirname(__FILE__)
2
+
3
+ class TestVersion < MiniTest::Unit::TestCase
4
+ def test_version
5
+ assert ArgsParser::VERSION > '0.0.0'
6
+ end
7
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: args_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,72 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
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
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: '3.10'
22
- type: :development
23
- prerelease: false
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
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: 1.5.3
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
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:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: '3.1'
54
- type: :development
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'
12
+ date: 2013-01-03 00:00:00.000000000 Z
13
+ dependencies: []
62
14
  description: Parse ARGV from command line with DSL.
63
15
  email:
64
16
  - hashimoto@shokai.org
65
17
  executables: []
66
18
  extensions: []
67
- extra_rdoc_files:
68
- - History.txt
69
- - Manifest.txt
70
- - README.rdoc
19
+ extra_rdoc_files: []
71
20
  files:
21
+ - .gitignore
72
22
  - Gemfile
73
- - Gemfile.lock
74
23
  - History.txt
75
- - Manifest.txt
76
- - README.rdoc
24
+ - LICENSE.txt
25
+ - README.md
77
26
  - Rakefile
27
+ - args_parser.gemspec
78
28
  - lib/args_parser.rb
79
29
  - lib/args_parser/config.rb
80
30
  - lib/args_parser/error.rb
@@ -83,23 +33,19 @@ files:
83
33
  - lib/args_parser/styles/default.rb
84
34
  - lib/args_parser/styles/equal.rb
85
35
  - lib/args_parser/validator.rb
36
+ - lib/args_parser/version.rb
86
37
  - samples/download_webpage.rb
87
38
  - samples/twitter_timeline.rb
88
- - script/console
89
- - script/destroy
90
- - script/generate
91
39
  - test/test_args_parser.rb
92
40
  - test/test_args_parser_style_equal.rb
93
41
  - test/test_filter.rb
94
42
  - test/test_helper.rb
95
43
  - test/test_validator.rb
96
- - .gemtest
44
+ - test/test_version.rb
97
45
  homepage: http://shokai.github.com/args_parser
98
46
  licenses: []
99
47
  post_install_message:
100
- rdoc_options:
101
- - --main
102
- - README.rdoc
48
+ rdoc_options: []
103
49
  require_paths:
104
50
  - lib
105
51
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -108,9 +54,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
54
  - - ! '>='
109
55
  - !ruby/object:Gem::Version
110
56
  version: '0'
111
- segments:
112
- - 0
113
- hash: 3219864076564386058
114
57
  required_rubygems_version: !ruby/object:Gem::Requirement
115
58
  none: false
116
59
  requirements:
@@ -118,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
61
  - !ruby/object:Gem::Version
119
62
  version: '0'
120
63
  requirements: []
121
- rubyforge_project: args_parser
64
+ rubyforge_project:
122
65
  rubygems_version: 1.8.24
123
66
  signing_key:
124
67
  specification_version: 3
@@ -129,3 +72,4 @@ test_files:
129
72
  - test/test_filter.rb
130
73
  - test/test_helper.rb
131
74
  - test/test_validator.rb
75
+ - test/test_version.rb
data/.gemtest DELETED
File without changes
@@ -1,26 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- RedCloth (4.2.9)
5
- RedCloth (4.2.9-java)
6
- activesupport (2.3.14)
7
- hoe (3.1.0)
8
- rake (~> 0.8)
9
- newgem (1.5.3)
10
- RedCloth (>= 4.1.1)
11
- activesupport (~> 2.3.4)
12
- hoe (>= 2.4.0)
13
- rubigen (>= 1.5.3)
14
- syntax (>= 1.0.0)
15
- rake (0.9.2.2)
16
- rubigen (1.5.8)
17
- activesupport (>= 2.3.5, < 3.2.0)
18
- syntax (1.0.0)
19
-
20
- PLATFORMS
21
- java
22
- ruby
23
-
24
- DEPENDENCIES
25
- hoe (>= 2.1.0)
26
- newgem
@@ -1,24 +0,0 @@
1
- Gemfile
2
- Gemfile.lock
3
- History.txt
4
- Manifest.txt
5
- README.rdoc
6
- Rakefile
7
- lib/args_parser.rb
8
- lib/args_parser/config.rb
9
- lib/args_parser/error.rb
10
- lib/args_parser/filter.rb
11
- lib/args_parser/parser.rb
12
- lib/args_parser/styles/default.rb
13
- lib/args_parser/styles/equal.rb
14
- lib/args_parser/validator.rb
15
- samples/download_webpage.rb
16
- samples/twitter_timeline.rb
17
- script/console
18
- script/destroy
19
- script/generate
20
- test/test_args_parser.rb
21
- test/test_args_parser_style_equal.rb
22
- test/test_filter.rb
23
- test/test_helper.rb
24
- test/test_validator.rb
@@ -1,100 +0,0 @@
1
- = args_parser
2
-
3
- * http://shokai.github.com/args_parser
4
-
5
- == DESCRIPTION:
6
-
7
- Parse ARGV from command line with DSL.
8
-
9
- == SYNOPSIS:
10
-
11
- % ruby samples/download_webpage.rb -url http://example.com -o out.html
12
-
13
- parse ARGV
14
-
15
- require 'rubygems'
16
- require 'args_parser'
17
-
18
- parser = ArgsParser.parse ARGV do
19
- arg :url, 'URL', :alias => :u
20
- arg :output, 'output file', :alias => :o, :default => 'out.html'
21
- arg :verbose, 'verbose mode'
22
- arg :help, 'show help', :alias => :h
23
-
24
- filter :url do |v|
25
- v.to_s.strip
26
- end
27
-
28
- validate :url, "invalid URL" do |v|
29
- v =~ /^https?:\/\/.+$/
30
- end
31
- end
32
-
33
- if parser.has_option? :help or !parser.has_param?(:url, :output)
34
- STDERR.puts parser.help
35
- exit 1
36
- end
37
-
38
- require 'open-uri'
39
- puts 'download..' if parser[:verbose]
40
- open(parser[:output], 'w+') do |f|
41
- f.write open(parser[:url]).read
42
- end
43
- puts "saved! => #{parser[:output]}"
44
-
45
-
46
- equal style
47
-
48
- % ruby samples/twitter_timeline.rb --user=shokai --fav --rt
49
-
50
- parse equal style ARGV
51
-
52
- parser = ArgsParser.parse ARGV, :style => :equal do
53
-
54
- see more [samples](https://github.com/shokai/args_parser/tree/master/samples)
55
-
56
-
57
- == REQUIREMENTS:
58
-
59
- * Ruby 1.8.7+
60
- * Ruby 1.9.3+
61
- * JRuby 1.6.7+
62
-
63
- == INSTALL:
64
-
65
- * gem install args_parser
66
-
67
- == TEST:
68
-
69
- % bundle install
70
- % rake
71
-
72
- == RELEASE
73
-
74
- % rake package
75
- % gem push pkg/args_parser-x.x.x.gem
76
-
77
- == LICENSE:
78
-
79
- (The MIT License)
80
-
81
- Copyright (c) 2012 Sho Hashimoto
82
-
83
- Permission is hereby granted, free of charge, to any person obtaining
84
- a copy of this software and associated documentation files (the
85
- 'Software'), to deal in the Software without restriction, including
86
- without limitation the rights to use, copy, modify, merge, publish,
87
- distribute, sublicense, and/or sell copies of the Software, and to
88
- permit persons to whom the Software is furnished to do so, subject to
89
- the following conditions:
90
-
91
- The above copyright notice and this permission notice shall be
92
- included in all copies or substantial portions of the Software.
93
-
94
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
95
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
96
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
97
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
98
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
99
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
100
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # File: script/console
3
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
-
5
- libs = " -r irb/completion"
6
- # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
- libs << " -r #{File.dirname(__FILE__) + '/../lib/args_parser.rb'}"
9
- puts "Loading args_parser gem"
10
- exec "#{irb} #{libs} --simple-prompt"
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/destroy'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/generate'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Generate.new.run(ARGV)