optparse-pathname 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *~
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 KITAITI Makoto
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,66 @@
1
+ optparse-pathname
2
+ =================
3
+
4
+ This gem allow you convert command line options to `Pathname` objects
5
+ when parsing them using `OptionParser`.
6
+
7
+ It's similar to `optparse/uri`, a Ruby standard bundled library.
8
+
9
+ Installation
10
+ ------------
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'optparse-pathname'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install optparse-pathname
23
+
24
+ Usage
25
+ -----
26
+
27
+ Your command file(bin/my-command here):
28
+
29
+ #!/usr/bin/env ruby
30
+ require 'optparse/pathname'
31
+
32
+ options = {}
33
+ parser = OptionParser.new
34
+ parser.on '-f', '--file=FILE', Pathname do |path|
35
+ unless path.file?
36
+ warn 'ERROR: `file` option must be an existing file'
37
+ raise OptionParser::InvalidArgument
38
+ end
39
+ options[:path] = path
40
+ end
41
+ parser.parse!
42
+
43
+ puts options[:path].class
44
+ puts options[:path].expand_path
45
+
46
+ You will see like this:
47
+
48
+ $ bundle exec my-command --file=./bin/my-command
49
+ Pathname
50
+ path/to/current/bin/my-command
51
+
52
+ Or like this:
53
+
54
+ $ bundle exec bin/my-command --file=.
55
+ ERROR: `file` option must be an existing file
56
+ bin/my-command:9:in `block in <main>': invalid argument: --file=. (OptionParser::InvalidArgument)
57
+ from bin/my-command:13:in `<main>'
58
+
59
+ Contributing
60
+ ------------
61
+
62
+ 1. Fork it
63
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
64
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
65
+ 4. Push to the branch (`git push origin my-new-feature`)
66
+ 5. Create new Merge Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,6 @@
1
+ require 'optparse'
2
+ require 'pathname'
3
+
4
+ OptionParser.accept Pathname do |path|
5
+ Pathname.new path if path
6
+ end
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.authors = ["KITAITI Makoto"]
3
+ gem.email = ["KitaitiMakoto@gmail.com"]
4
+ gem.description = %q{Make Pathname class one of options OptionParser's option can accept}
5
+ gem.summary = %q{Make Pathanme acceptable to OptionParser}
6
+ gem.homepage = "https://gitorious.org/optparse"
7
+
8
+ gem.files = `git ls-files`.split($\)
9
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
10
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
11
+ gem.name = "optparse-pathname"
12
+ gem.require_paths = ["lib"]
13
+ gem.version = '0.0.1'
14
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: optparse-pathname
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - KITAITI Makoto
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-12 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: Make Pathname class one of options OptionParser's option can accept
15
+ email:
16
+ - KitaitiMakoto@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE
24
+ - README.markdown
25
+ - Rakefile
26
+ - lib/optparse/pathname.rb
27
+ - optparse-pathname.gemspec
28
+ homepage: https://gitorious.org/optparse
29
+ licenses: []
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ none: false
36
+ requirements:
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ segments:
41
+ - 0
42
+ hash: -4333050483793939503
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ segments:
50
+ - 0
51
+ hash: -4333050483793939503
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 1.8.8
55
+ signing_key:
56
+ specification_version: 3
57
+ summary: Make Pathanme acceptable to OptionParser
58
+ test_files: []