choice 0.1.6 → 0.1.7

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,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NzIxY2UxYzVhYWQ3M2MyMmJjMTU4OTRkNTA5MmM5N2I2YWI3OTk0YQ==
5
+ data.tar.gz: !binary |-
6
+ M2I0MjZhZjM5MTY5YjFlZTJlNmY4NTQxN2U1MzQ1YmJiNmZjNDA2NA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YzY2YzlmOGNlNTBkOTFjOWEzMzY3Y2QwN2Q2MjVmMTliNWE5ZDY5ZTdjYWZj
10
+ YjcwMDJkMjlhZDA5NzNiYjBkYTgwMGI5MWVmYWYyNTM4Nzg5OWNhNmQyNTlk
11
+ NzVhZDRiZGQ3NDQxY2U1YjNhYzllN2I0MWUxMzdkMjQ5YjM2YWU=
12
+ data.tar.gz: !binary |-
13
+ NWFlMzYyMGM0OWUzMWZjMTc1NTU1MjMyZGQ1ZDQxM2NlOGQ4OWE2MzViNzhh
14
+ ZWNjYjY1NWViZWY3MzVjNGE0NGUyZjljN2U5YjI2NmRkYjUzMTE1MjFhNjYy
15
+ MWUwMzhhNzI0YTgwNDM0ODYxODUzOGUyMjRlYzc1M2VmMTgwYzI=
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+ - rbx-2
7
+ - jruby
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ 0.1.7:
2
+ - Fix bug related to NilClass#to_h
3
+ - Simplified packaging process: Now possible to package with an up-to-date system.
4
+ 0.1.6:
5
+ - Use Array on a value that can be a string or an array.
6
+ - Wrap the banner/footer/header defining method with a method with a default param.
7
+ - Fixed expectation that Choice.parse returns an empty hash. It really returns a nil.
8
+
1
9
  0.1.4:
2
10
  - Monkeypatch to Hash for #index deprecation. Only applied on RUBY_VERSION < "1.9"
3
11
  - Fixed rake file for README filename change
@@ -5,7 +13,7 @@
5
13
 
6
14
  0.1.3:
7
15
  - Added args_of method to retrieve the arguments of an option
8
-
16
+
9
17
  0.1.2:
10
18
  - Made validate directive accept block and validate against its boolean value.
11
19
  - Created shorthand format for defining options directly with a hash.
@@ -1,7 +1,7 @@
1
1
  = Welcome to Choice
2
2
 
3
3
  Choice is a small library for defining and parsing command line options. It
4
- works awesomely with Highline[http://highline.rubyforge.org/] or other command
4
+ works awesomely with Highline[https://github.com/JEG2/highline] or other command
5
5
  line interface libraries.
6
6
 
7
7
  Choice was written by Chris Wanstrath as an exercise in test driving development
@@ -11,9 +11,7 @@ is appreciated.
11
11
  Installing is easy, with RubyGems. Give it a shot:
12
12
  $ gem install choice
13
13
 
14
- If you are lost, you can find Choice at http://choice.rubyforge.org or
15
- http://rubyforge.org/projects/choice/. E-mail inquiries can be directed to
16
- mailto:chris[at]ozmm[dot]org.
14
+ E-mail inquiries can be directed to mailto:chris[at]ozmm[dot]org.
17
15
 
18
16
  Of course, Choice is licensed under the MIT License, which you can find included
19
17
  in the LICENSE file or by surfing your World Wide Web browser of choice towards
@@ -0,0 +1,59 @@
1
+ require 'rubygems'
2
+ require 'rubygems/gem_runner'
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+ require 'rdoc/task'
6
+ require './lib/choice/version'
7
+
8
+ PACKAGE_VERSION = Choice::Version::STRING
9
+
10
+ desc "Default task"
11
+ task :default => [ :test ]
12
+
13
+ Rake::TestTask.new :test do |t|
14
+ t.test_files = [ "test/test*" ]
15
+ end
16
+
17
+ desc "Clean generated files"
18
+ task :clean do
19
+ rm_rf "choice-#{PACKAGE_VERSION}.gem"
20
+ end
21
+
22
+ desc "Prepackage warnings and reminders"
23
+ task :prepackage do
24
+ unless ENV["OK"] == "yes"
25
+ puts "========================================================="
26
+ puts " Please check that the following files have been updated"
27
+ puts " in preparation for release #{PACKAGE_VERSION}:"
28
+ puts
29
+ puts " README.rdoc (with latest info)"
30
+ puts " CHANGELOG (with the recent changes)"
31
+ puts " lib/choice/version.rb (with current version number)"
32
+ puts
33
+ puts " Did you remember to 'rake tag'?"
34
+ puts
35
+ puts " If you are sure these have all been taken care of, re-run"
36
+ puts " rake with 'OK=yes'."
37
+ puts "========================================================="
38
+ puts
39
+
40
+ abort
41
+ end
42
+ end
43
+
44
+ desc "Tag the current trunk with the current release version"
45
+ task :tag do
46
+ tag = "v#{PACKAGE_VERSION}"
47
+ warn "WARNING: this will tag using the tag #{tag} and push the ref to git://www.github.com/defunkt/choice"
48
+ warn "If you do not wish to continue, you have 5 seconds to cancel by pressing CTRL-C..."
49
+ 5.times { |i| print "#{5-i} "; $stdout.flush; sleep 1 }
50
+ system "git tag -a #{tag} -m \"Tagging the #{tag} release\""
51
+ system "git push origin #{tag}"
52
+ end
53
+
54
+ task :gem do
55
+ system "gem build choice.gemspec"
56
+ end
57
+
58
+ desc "Build all packages"
59
+ task :package => [ :prepackage, :test, :gem ]
data/TODO ADDED
@@ -0,0 +1,7 @@
1
+ 1. Add support for defining the number of arguments an option takes.
2
+ 2. Use a static gemspec.
3
+ 3. Add a Gemfile to help with consistency in development.
4
+ 4. Simplify anything in the Rakefile that has a more common current practice.
5
+ 5. Either make everything work on 1.8.6+ or start deprecating older interpreters.
6
+ 6. Publish docs similar to how we used to pub to RubyForge
7
+ 7. Convert these to Github Issues
@@ -0,0 +1,20 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'choice/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "choice"
8
+ spec.version = Choice::Version::STRING
9
+ spec.authors = ["Grant Austin", "Chris Wanstrath"]
10
+ spec.email = ["gaustin@gmail.com", "chris@ozmm.org"]
11
+ spec.summary = "Choice is a command line option parser."
12
+ spec.description = "Choice is a simple little gem for easily defining and parsing command line options with a friendly DSL."
13
+ spec.homepage = "http://www.github.com/defunkt/choice"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+ end
@@ -2,7 +2,7 @@ module Choice
2
2
  module Version #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 6
5
+ TINY = 7
6
6
  STRING = [MAJOR, MINOR, TINY] * '.'
7
7
  end
8
8
  end
@@ -63,7 +63,7 @@ module Choice
63
63
  # If the option is a hash, run it through option_line. Otherwise
64
64
  # just print it out as is.
65
65
  options.each do |name, option|
66
- if option.respond_to?(:to_h)
66
+ if !option.nil? && option.respond_to?(:to_h)
67
67
  option_line(option.to_h)
68
68
  else
69
69
  puts name
@@ -5,13 +5,13 @@ require 'choice'
5
5
  $VERBOSE = nil
6
6
 
7
7
  class TestChoice < Test::Unit::TestCase
8
-
8
+
9
9
  def setup
10
10
  Choice.reset!
11
11
  Choice.dont_exit_on_help = true
12
12
  Choice.send(:class_variable_set, '@@choices', {})
13
13
  end
14
-
14
+
15
15
  def test_choices
16
16
  Choice.options do
17
17
  header "Tell me about yourself?"
@@ -63,10 +63,10 @@ class TestChoice < Test::Unit::TestCase
63
63
  short '-m'
64
64
  desc 'Your favorite meal.'
65
65
  end
66
-
66
+
67
67
  separator ""
68
68
  separator "And you eat it with..."
69
-
69
+
70
70
  option :utencil do
71
71
  short "-u"
72
72
  long "--utencil[=UTENCIL]"
@@ -75,7 +75,7 @@ class TestChoice < Test::Unit::TestCase
75
75
  end
76
76
 
77
77
  Choice.args = ['-m', 'lunch', '--help']
78
-
78
+
79
79
  help_string = <<-HELP
80
80
  Usage: choice [-mu]
81
81
 
@@ -83,15 +83,15 @@ Usage: choice [-mu]
83
83
 
84
84
  And you eat it with...
85
85
  -u, --utencil[=UTENCIL] Your favorite eating utencil.
86
- HELP
86
+ HELP
87
87
 
88
88
  assert_equal help_string, HELP_STRING
89
89
  end
90
-
90
+
91
91
  UNKNOWN_STRING = ''
92
92
  def test_unknown_argument
93
93
  Choice.output_to(UNKNOWN_STRING)
94
-
94
+
95
95
  Choice.options do
96
96
  banner "Usage: choice [-mu]"
97
97
  header ""
@@ -99,10 +99,10 @@ HELP
99
99
  short '-m'
100
100
  desc 'Your favorite meal.'
101
101
  end
102
-
102
+
103
103
  separator ""
104
104
  separator "And you eat it with..."
105
-
105
+
106
106
  option :utencil do
107
107
  short "-u"
108
108
  long "--utencil[=UTENCIL]"
@@ -111,7 +111,7 @@ HELP
111
111
  end
112
112
 
113
113
  Choice.args = ['-m', 'lunch', '--motorcycles']
114
-
114
+
115
115
  help_string = <<-HELP
116
116
  Usage: choice [-mu]
117
117
 
@@ -119,15 +119,15 @@ Usage: choice [-mu]
119
119
 
120
120
  And you eat it with...
121
121
  -u, --utencil[=UTENCIL] Your favorite eating utencil.
122
- HELP
123
-
122
+ HELP
123
+
124
124
  assert_equal help_string, UNKNOWN_STRING
125
125
  end
126
-
126
+
127
127
  REQUIRED_STRING = ''
128
128
  def test_required_argument
129
129
  Choice.output_to(REQUIRED_STRING)
130
-
130
+
131
131
  Choice.options do
132
132
  banner "Usage: choice [-mu]"
133
133
  header ""
@@ -135,10 +135,10 @@ HELP
135
135
  short '-m'
136
136
  desc 'Your favorite meal.'
137
137
  end
138
-
138
+
139
139
  separator ""
140
140
  separator "And you eat it with..."
141
-
141
+
142
142
  option :utencil do
143
143
  short "-u"
144
144
  long "--utencil[=UTENCIL]"
@@ -147,7 +147,7 @@ HELP
147
147
  end
148
148
 
149
149
  Choice.args = ['-u', 'spork']
150
-
150
+
151
151
  help_string = <<-HELP
152
152
  Usage: choice [-mu]
153
153
 
@@ -155,8 +155,8 @@ Usage: choice [-mu]
155
155
 
156
156
  And you eat it with...
157
157
  -u, --utencil[=UTENCIL] Your favorite eating utencil.
158
- HELP
159
-
158
+ HELP
159
+
160
160
  assert_equal help_string, REQUIRED_STRING
161
161
  end
162
162
 
@@ -165,25 +165,25 @@ HELP
165
165
  header "Tell me about yourself?"
166
166
  header ""
167
167
  options :band => { :short => "-b", :long => "--band=BAND", :cast => String, :desc => ["Your favorite band.", "Something cool."],
168
- :validate => /\w+/ },
169
- :animal => { :short => "-a", :long => "--animal=ANIMAL", :cast => String, :desc => "Your favorite animal." }
170
-
168
+ :validate => /\w+/ },
169
+ :animal => { :short => "-a", :long => "--animal=ANIMAL", :cast => String, :desc => "Your favorite animal." }
170
+
171
171
  footer ""
172
172
  footer "--help This message"
173
173
  end
174
-
174
+
175
175
  band = 'LedZeppelin'
176
176
  animal = 'Reindeer'
177
-
177
+
178
178
  args = ['-b', band, "--animal=#{animal}"]
179
179
  Choice.args = args
180
-
180
+
181
181
  assert_equal band, Choice.choices['band']
182
182
  assert_equal animal, Choice.choices[:animal]
183
183
  assert_equal ["Tell me about yourself?", ""], Choice.header
184
184
  assert_equal ["", "--help This message"], Choice.footer
185
185
  end
186
-
186
+
187
187
  def test_args_of
188
188
  suits = %w[clubs diamonds spades hearts]
189
189
  stringed_numerics = (1..13).to_a.map { |a| a.to_s }
@@ -191,7 +191,7 @@ HELP
191
191
  cards = {}
192
192
  stringed_numerics.each { |n| cards[n] = n }
193
193
  cards.merge!('1' => 'ace', '11' => 'jack', '12' => 'queen', '13' => 'king')
194
-
194
+
195
195
  Choice.options do
196
196
  header "Gambling is fun again! Pick a card and a suit (or two), then see if you win!"
197
197
  header ""
@@ -215,7 +215,7 @@ HELP
215
215
  valid valid_cards
216
216
  cast String
217
217
  end
218
-
218
+
219
219
  #cheat! to test --option=
220
220
  option :autowin do
221
221
  short '-a'
@@ -224,7 +224,7 @@ HELP
224
224
  desc 'Beware: raises the suspitions of other players'
225
225
  end
226
226
  end
227
-
227
+
228
228
  args = ["-c", "king", "--suit", "clubs", "diamonds", "spades", "hearts", "--autowin", "Grant"]
229
229
  Choice.args = args
230
230
  assert_equal ["king"], Choice.args_of("-c")
metadata CHANGED
@@ -1,61 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: choice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
5
- prerelease:
4
+ version: 0.1.7
6
5
  platform: ruby
7
6
  authors:
7
+ - Grant Austin
8
8
  - Chris Wanstrath
9
- autorequire: choice
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-26 00:00:00.000000000 Z
12
+ date: 2014-12-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Choice is a simple little gem for easily defining and parsing command
15
15
  line options with a friendly DSL.
16
- email: chris@ozmm.org
16
+ email:
17
+ - gaustin@gmail.com
18
+ - chris@ozmm.org
17
19
  executables: []
18
20
  extensions: []
19
21
  extra_rdoc_files: []
20
22
  files:
21
- - README.rdoc
23
+ - .travis.yml
22
24
  - CHANGELOG
23
25
  - LICENSE
26
+ - README.rdoc
27
+ - Rakefile
28
+ - TODO
29
+ - choice.gemspec
30
+ - examples/ftpd.rb
31
+ - examples/gamble.rb
32
+ - lib/choice.rb
24
33
  - lib/choice/lazyhash.rb
25
34
  - lib/choice/option.rb
26
35
  - lib/choice/parser.rb
27
36
  - lib/choice/version.rb
28
37
  - lib/choice/writer.rb
29
- - lib/choice.rb
30
38
  - test/test_choice.rb
31
39
  - test/test_lazyhash.rb
32
40
  - test/test_option.rb
33
41
  - test/test_parser.rb
34
42
  - test/test_writer.rb
35
- - examples/ftpd.rb
36
- - examples/gamble.rb
37
- homepage: http://choice.rubyforge.org/
38
- licenses: []
43
+ homepage: http://www.github.com/defunkt/choice
44
+ licenses:
45
+ - MIT
46
+ metadata: {}
39
47
  post_install_message:
40
48
  rdoc_options: []
41
49
  require_paths:
42
50
  - lib
43
51
  required_ruby_version: !ruby/object:Gem::Requirement
44
- none: false
45
52
  requirements:
46
53
  - - ! '>='
47
54
  - !ruby/object:Gem::Version
48
55
  version: '0'
49
56
  required_rubygems_version: !ruby/object:Gem::Requirement
50
- none: false
51
57
  requirements:
52
58
  - - ! '>='
53
59
  - !ruby/object:Gem::Version
54
60
  version: '0'
55
61
  requirements: []
56
62
  rubyforge_project:
57
- rubygems_version: 1.8.15
63
+ rubygems_version: 2.4.5
58
64
  signing_key:
59
- specification_version: 3
65
+ specification_version: 4
60
66
  summary: Choice is a command line option parser.
61
- test_files: []
67
+ test_files:
68
+ - test/test_choice.rb
69
+ - test/test_lazyhash.rb
70
+ - test/test_option.rb
71
+ - test/test_parser.rb
72
+ - test/test_writer.rb
73
+ has_rdoc: