iopts 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format doc
data/.rvmrc ADDED
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
+ environment_id="ruby-1.9.2@iopts"
8
+
9
+ #
10
+ # First we attempt to load the desired environment directly from the environment
11
+ # file. This is very fast and efficicent compared to running through the entire
12
+ # CLI and selector. If you want feedback on which environment was used then
13
+ # insert the word 'use' after --create as this triggers verbose mode.
14
+ #
15
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
16
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
17
+ then
18
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
19
+
20
+ if [[ -s ".rvm/hooks/after_use" ]]
21
+ then
22
+ . ".rvm/hooks/after_use"
23
+ fi
24
+ else
25
+ # If the environment file has not yet been created, use the RVM CLI to select.
26
+ if ! rvm --create "$environment_id"
27
+ then
28
+ echo "Failed to create RVM environment ''."
29
+ fi
30
+ fi
31
+
32
+ #
33
+ # If you use an RVM gemset file to install a list of gems (*.gems), you can have
34
+ # it be automatically loaded. Uncomment the following and adjust the filename if
35
+ # necessary.
36
+ #
37
+ # filename=".gems"
38
+ # if [[ -s "$filename" ]] ; then
39
+ # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
40
+ # fi
41
+
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem 'paint', '~> 0.8.4'
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem 'rake', '~> 0.9.2'
12
+ gem 'rspec', '~> 2.8.0'
13
+ gem 'shoulda', '~> 2.11.3'
14
+ gem 'bundler'
15
+ gem 'jeweler', '~> 1.8.3'
16
+ gem 'simplecov', '~> 0.5.4'
17
+ gem 'yard', '~> 0.7.5'
18
+ gem 'rdiscount', '~> 1.6.8'
19
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,45 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ git (1.2.5)
6
+ jeweler (1.8.3)
7
+ bundler (~> 1.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ rdoc
11
+ json (1.6.5)
12
+ multi_json (1.0.4)
13
+ paint (0.8.4)
14
+ rake (0.9.2.2)
15
+ rdiscount (1.6.8)
16
+ rdoc (3.12)
17
+ json (~> 1.4)
18
+ rspec (2.8.0)
19
+ rspec-core (~> 2.8.0)
20
+ rspec-expectations (~> 2.8.0)
21
+ rspec-mocks (~> 2.8.0)
22
+ rspec-core (2.8.0)
23
+ rspec-expectations (2.8.0)
24
+ diff-lcs (~> 1.1.2)
25
+ rspec-mocks (2.8.0)
26
+ shoulda (2.11.3)
27
+ simplecov (0.5.4)
28
+ multi_json (~> 1.0.3)
29
+ simplecov-html (~> 0.5.3)
30
+ simplecov-html (0.5.3)
31
+ yard (0.7.5)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ bundler
38
+ jeweler (~> 1.8.3)
39
+ paint (~> 0.8.4)
40
+ rake (~> 0.9.2)
41
+ rdiscount (~> 1.6.8)
42
+ rspec (~> 2.8.0)
43
+ shoulda (~> 2.11.3)
44
+ simplecov (~> 0.5.4)
45
+ yard (~> 0.7.5)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Alpha Hydrae (hydrae.alpha@gmail.com)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # iopts
2
+
3
+ **Improved ruby option parser.**
4
+
5
+ ## License (MIT)
6
+
7
+ Copyright (c) 2011 Alpha Hydrae
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,58 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "iopts"
18
+ gem.homepage = "http://github.com/AlphaHydrae/iopts"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Improved ruby option parser.}
21
+ gem.description = %Q{Improved ruby option parser.}
22
+ gem.email = "hydrae.alpha@gmail.com"
23
+ gem.authors = ["AlphaHydrae"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core/rake_task'
29
+ desc "Run specs"
30
+ RSpec::Core::RakeTask.new do |t|
31
+ #t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
32
+ # Put spec opts in a file named .rspec in root
33
+ end
34
+
35
+ task :default => :spec
36
+
37
+ desc "Generate documentation"
38
+ task :doc => ['doc:generate']
39
+ namespace :doc do
40
+ project_root = File.dirname __FILE__
41
+ doc_destination = File.join project_root, 'doc'
42
+
43
+ begin
44
+ require 'yard'
45
+ require 'yard/rake/yardoc_task'
46
+
47
+ YARD::Rake::YardocTask.new(:generate) do |yt|
48
+ yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) +
49
+ [ File.join(project_root, 'README.md') ]
50
+ yt.options = ['--output-dir', doc_destination, '--readme', 'README.md', '--private', '--protected']
51
+ end
52
+ rescue LoadError
53
+ desc "Generate YARD Documentation"
54
+ task :generate do
55
+ abort "Please install the YARD gem to generate rdoc."
56
+ end
57
+ end
58
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/iopts.gemspec ADDED
@@ -0,0 +1,76 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "iopts"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["AlphaHydrae"]
12
+ s.date = "2012-03-20"
13
+ s.description = "Improved ruby option parser."
14
+ s.email = "hydrae.alpha@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ ".rvmrc",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.md",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "iopts.gemspec",
30
+ "lib/iopts.rb",
31
+ "spec/helper.rb",
32
+ "spec/iopts_spec.rb"
33
+ ]
34
+ s.homepage = "http://github.com/AlphaHydrae/iopts"
35
+ s.licenses = ["MIT"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = "1.8.10"
38
+ s.summary = "Improved ruby option parser."
39
+
40
+ if s.respond_to? :specification_version then
41
+ s.specification_version = 3
42
+
43
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
+ s.add_runtime_dependency(%q<paint>, ["~> 0.8.4"])
45
+ s.add_development_dependency(%q<rake>, ["~> 0.9.2"])
46
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
47
+ s.add_development_dependency(%q<shoulda>, ["~> 2.11.3"])
48
+ s.add_development_dependency(%q<bundler>, [">= 0"])
49
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
50
+ s.add_development_dependency(%q<simplecov>, ["~> 0.5.4"])
51
+ s.add_development_dependency(%q<yard>, ["~> 0.7.5"])
52
+ s.add_development_dependency(%q<rdiscount>, ["~> 1.6.8"])
53
+ else
54
+ s.add_dependency(%q<paint>, ["~> 0.8.4"])
55
+ s.add_dependency(%q<rake>, ["~> 0.9.2"])
56
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
57
+ s.add_dependency(%q<shoulda>, ["~> 2.11.3"])
58
+ s.add_dependency(%q<bundler>, [">= 0"])
59
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
60
+ s.add_dependency(%q<simplecov>, ["~> 0.5.4"])
61
+ s.add_dependency(%q<yard>, ["~> 0.7.5"])
62
+ s.add_dependency(%q<rdiscount>, ["~> 1.6.8"])
63
+ end
64
+ else
65
+ s.add_dependency(%q<paint>, ["~> 0.8.4"])
66
+ s.add_dependency(%q<rake>, ["~> 0.9.2"])
67
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
68
+ s.add_dependency(%q<shoulda>, ["~> 2.11.3"])
69
+ s.add_dependency(%q<bundler>, [">= 0"])
70
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
71
+ s.add_dependency(%q<simplecov>, ["~> 0.5.4"])
72
+ s.add_dependency(%q<yard>, ["~> 0.7.5"])
73
+ s.add_dependency(%q<rdiscount>, ["~> 1.6.8"])
74
+ end
75
+ end
76
+
data/lib/iopts.rb ADDED
@@ -0,0 +1,95 @@
1
+ require 'ostruct'
2
+ require 'optparse'
3
+ require 'paint'
4
+
5
+ # Customized version of ruby's OptionParser.
6
+ class Iopts < OptionParser
7
+
8
+ attr_accessor :funnel
9
+
10
+ def self.section_title title
11
+ Paint[title, :bold]
12
+ end
13
+
14
+ def self.section_title_ref ref
15
+ Paint[ref, :underline]
16
+ end
17
+
18
+ def initialize *args
19
+ options = args.last.kind_of?(Hash) ? args.pop : {}
20
+
21
+ @funnel = options[:funnel] || OpenStruct.new
22
+ @footer = options[:footer]
23
+ @examples = options[:examples]
24
+
25
+ width = options[:width] || 32
26
+ indent = options[:indent] || (' ' * 2)
27
+ super nil, width, indent
28
+
29
+ @banner = options[:banner].kind_of?(Hash) ? summary_banner_section(options[:banner]) : options[:banner]
30
+ end
31
+
32
+ def on *args
33
+ if block_given?
34
+ super(*args)
35
+ else
36
+ sw = make_switch(args)
37
+ return super(*args) if !sw || sw.empty? || !sw.first.respond_to?(:long)
38
+ name = sw.first.long.first || sw.first.short.first
39
+ return super(*args) unless name
40
+ name = name.sub /^\-+/, ''
41
+ block = lambda{ |val| fill_funnel name, val }
42
+ super(*args, &block)
43
+ end
44
+ end
45
+
46
+ def program_name
47
+ @program_name || File.basename($0)
48
+ end
49
+
50
+ def to_s
51
+ "#{super}#{summary_examples_section}#{@footer}"
52
+ end
53
+
54
+ def help!
55
+ self.on('-h', '--help', 'show this help and exit'){ puts self; exit 0 }
56
+ end
57
+
58
+ def usage!
59
+ self.on('-u', '--usage', 'show this help and exit'){ puts self; exit 0 }
60
+ end
61
+
62
+ private
63
+
64
+ def fill_funnel name, value
65
+ if @funnel.kind_of? OpenStruct
66
+ @funnel.send "#{name}=", value
67
+ elsif @funnel.kind_of? Hash
68
+ @funnel[name] = value
69
+ end
70
+ end
71
+
72
+ def summary_program_name
73
+ Paint[program_name, :bold]
74
+ end
75
+
76
+ def summary_banner_section *args
77
+ options = args.extract_options!
78
+ %|#{summary_program_name} #{options[:description]}
79
+
80
+ #{self.class.section_title :USAGE}
81
+ #{@summary_indent}#{summary_program_name} #{options[:usage]}
82
+
83
+ #{self.class.section_title :OPTIONS}
84
+ |
85
+ end
86
+
87
+ def summary_examples_section
88
+ return nil unless @examples
89
+ String.new("\n#{self.class.section_title :EXAMPLES}").tap do |s|
90
+ @examples.each do |example|
91
+ s << "\n#{@summary_indent}#{summary_program_name} #{example}"
92
+ end
93
+ end
94
+ end
95
+ end
data/spec/helper.rb ADDED
@@ -0,0 +1,22 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'simplecov'
4
+
5
+ # test coverage
6
+ SimpleCov.start
7
+
8
+ begin
9
+ Bundler.setup(:default, :development)
10
+ rescue Bundler::BundlerError => e
11
+ $stderr.puts e.message
12
+ $stderr.puts "Run `bundle install` to install missing gems"
13
+ exit e.status_code
14
+ end
15
+
16
+ require 'rspec'
17
+ require 'shoulda'
18
+
19
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
20
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
21
+ require 'iopts'
22
+
@@ -0,0 +1,9 @@
1
+
2
+ require 'helper'
3
+
4
+ describe ImprovedOptionParser do
5
+
6
+ it "should work" do
7
+ pending 'not yet implemented'
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: iopts
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - AlphaHydrae
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-20 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: paint
16
+ requirement: &2165642680 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.8.4
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2165642680
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &2165166440 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 0.9.2
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2165166440
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &2165164740 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 2.8.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *2165164740
47
+ - !ruby/object:Gem::Dependency
48
+ name: shoulda
49
+ requirement: &2165163540 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 2.11.3
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *2165163540
58
+ - !ruby/object:Gem::Dependency
59
+ name: bundler
60
+ requirement: &2165162320 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2165162320
69
+ - !ruby/object:Gem::Dependency
70
+ name: jeweler
71
+ requirement: &2165160800 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 1.8.3
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *2165160800
80
+ - !ruby/object:Gem::Dependency
81
+ name: simplecov
82
+ requirement: &2165159700 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: 0.5.4
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *2165159700
91
+ - !ruby/object:Gem::Dependency
92
+ name: yard
93
+ requirement: &2165145540 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: 0.7.5
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *2165145540
102
+ - !ruby/object:Gem::Dependency
103
+ name: rdiscount
104
+ requirement: &2165144420 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.6.8
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *2165144420
113
+ description: Improved ruby option parser.
114
+ email: hydrae.alpha@gmail.com
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files:
118
+ - LICENSE.txt
119
+ - README.md
120
+ files:
121
+ - .document
122
+ - .rspec
123
+ - .rvmrc
124
+ - Gemfile
125
+ - Gemfile.lock
126
+ - LICENSE.txt
127
+ - README.md
128
+ - Rakefile
129
+ - VERSION
130
+ - iopts.gemspec
131
+ - lib/iopts.rb
132
+ - spec/helper.rb
133
+ - spec/iopts_spec.rb
134
+ homepage: http://github.com/AlphaHydrae/iopts
135
+ licenses:
136
+ - MIT
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ! '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ segments:
148
+ - 0
149
+ hash: 3374708909022107542
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ! '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 1.8.10
159
+ signing_key:
160
+ specification_version: 3
161
+ summary: Improved ruby option parser.
162
+ test_files: []