clip 1.0.0 → 1.0.1

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.
@@ -1,3 +1,14 @@
1
+ === 1.0.1 / 2009-01-06
2
+
3
+ * Fixed a bug where generating help resulted in an infinite-loop
4
+
5
+ === 1.0.0 / 2008-09-19
6
+
7
+ * Added support for mapping dashes to underscores for flags
8
+ * Define Clip.hash.remainder as a singleton method instead of reopening Hash
9
+ * remainder works with Clip.hash now
10
+ * Reimplemented Clip.hash to use a parser.
11
+
1
12
  === 0.0.7 / 2008-07-14
2
13
 
3
14
  * remainder now works with Clip.hash method.
@@ -1,6 +1,6 @@
1
1
  History.txt
2
2
  Manifest.txt
3
- README.rdoc
3
+ README.txt
4
4
  Rakefile
5
5
  clip.gemspec
6
6
  lib/clip.rb
File without changes
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require './lib/clip.rb'
7
7
  Hoe.new('clip', Clip::VERSION) do |p|
8
8
  p.name = 'clip'
9
9
  p.developer('Alex Vollmer', 'alex.vollmer@gmail.com')
10
- p.description = p.paragraphs_of('README.rdoc', 5..5).join("\n\n")
10
+ p.description = p.paragraphs_of('README.txt', 5..5).join("\n\n")
11
11
  p.summary = 'Command-line parsing made short and sweet'
12
12
  p.url = 'http://clip.rubyforge.org'
13
13
  p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
@@ -8,10 +8,10 @@ Gem::Specification.new do |s|
8
8
  s.description = %q{You like command-line parsing, but you hate all of the bloat. Why should you have to create a Hash, then create a parser, fill the Hash out then throw the parser away (unless you want to print out a usage message) and deal with a Hash? Why, for Pete's sake, should the parser and the parsed values be handled by two different objects?}
9
9
  s.email = ["alex.vollmer@gmail.com"]
10
10
  s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
11
- s.files = ["History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "clip.gemspec", "lib/clip.rb", "spec/clip_spec.rb"]
11
+ s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "clip.gemspec", "lib/clip.rb", "spec/clip_spec.rb"]
12
12
  s.has_rdoc = true
13
13
  s.homepage = %q{http://clip.rubyforge.org}
14
- s.rdoc_options = ["--main", "README.rdoc"]
14
+ s.rdoc_options = ["--main", "README.txt"]
15
15
  s.require_paths = ["lib"]
16
16
  s.rubyforge_project = %q{clip}
17
17
  s.rubygems_version = %q{1.2.0}
@@ -15,7 +15,7 @@ def Clip(args=ARGV)
15
15
  end
16
16
 
17
17
  module Clip
18
- VERSION = "1.0.0"
18
+ VERSION = "1.0.1"
19
19
 
20
20
  ##
21
21
  # Indicates that the parser was incorrectly configured in the
@@ -247,7 +247,7 @@ module Clip
247
247
  i = 0
248
248
  while i < desc.length
249
249
  out << "\n" if i > 0
250
- j = [i + rem, desc.length - 1].min
250
+ j = [i + rem, desc.length].min
251
251
  while desc[j..j] =~ /[\w\d]/
252
252
  j -= 1
253
253
  end
@@ -1,6 +1,7 @@
1
1
  require "#{File.dirname(__FILE__)}/../lib/clip"
2
2
  require "rubygems"
3
3
  require "spec"
4
+ require "timeout"
4
5
 
5
6
  class HaveErrors
6
7
 
@@ -83,7 +84,7 @@ describe Clip do
83
84
  parser.should_not have_errors
84
85
  end
85
86
 
86
- it "should set fields for options with the given values" do
87
+ it "should set fields for flags with the given values" do
87
88
  parser = parse('--server localhost --port 8080 --files foo')
88
89
  parser.server.should eql("localhost")
89
90
  parser.port.should eql("8080")
@@ -97,7 +98,7 @@ describe Clip do
97
98
  parser.should be_valid
98
99
  parser.should_not have_errors
99
100
  end
100
-
101
+
101
102
  it "should map flags with '-' to methods with '_'" do
102
103
  parser = parse('--allow-dashes')
103
104
  parser.should be_allow_dashes
@@ -137,7 +138,7 @@ describe Clip do
137
138
  end
138
139
  end
139
140
 
140
- describe "When options are marked as required" do
141
+ describe "When parameters are marked as required" do
141
142
 
142
143
  it "should be invalid when there are missing arguments" do
143
144
  parser = parse('--server localhost')
@@ -146,9 +147,10 @@ describe Clip do
146
147
  end
147
148
  end
148
149
 
149
- describe "When options are marked with defaults" do
150
150
 
151
- it "should provide default option values when none are parsed" do
151
+ describe "When parameters are marked with defaults" do
152
+
153
+ it "should provide default parameter values when none are parsed" do
152
154
  parser = parse('--files foo')
153
155
  parser.should be_valid
154
156
  parser.should_not have_errors
@@ -232,6 +234,23 @@ describe Clip do
232
234
  out[0].should == 'USAGE foo bar baz'
233
235
  end
234
236
 
237
+ it "should handle Travis' degenerate infinite-loop case" do
238
+ opts = Clip('-c') do |c|
239
+ c.flag('c',
240
+ 'no-close-session',
241
+ :desc => 'Close the session after successful import?')
242
+ c.flag('l',
243
+ 'live-site',
244
+ :desc => "Query live wikipedia site for wiki text instead of DB session")
245
+ end
246
+
247
+ help = Timeout.timeout(2) { opts.to_s.split("\n") }
248
+ help[0].should match(/Usage/)
249
+ help[1].should == "-c --no-close-session Close the session after successful import?"
250
+ help[2].should == "-l --live-site Query live wikipedia site for wiki text instead of DB"
251
+ help[3].should == " session"
252
+ end
253
+
235
254
  it "should support overriding help flags" do
236
255
  opts = Clip('-?') do |p|
237
256
  p.opt 'h', 'host', :desc => 'The hostname'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clip
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Vollmer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-19 00:00:00 -07:00
12
+ date: 2009-01-06 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.7.0
23
+ version: 1.8.0
24
24
  version:
25
25
  description: You like command-line parsing, but you hate all of the bloat. Why should you have to create a Hash, then create a parser, fill the Hash out then throw the parser away (unless you want to print out a usage message) and deal with a Hash? Why, for Pete's sake, should the parser and the parsed values be handled by two different objects?
26
26
  email:
@@ -32,10 +32,11 @@ extensions: []
32
32
  extra_rdoc_files:
33
33
  - History.txt
34
34
  - Manifest.txt
35
+ - README.txt
35
36
  files:
36
37
  - History.txt
37
38
  - Manifest.txt
38
- - README.rdoc
39
+ - README.txt
39
40
  - Rakefile
40
41
  - clip.gemspec
41
42
  - lib/clip.rb
@@ -63,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
64
  requirements: []
64
65
 
65
66
  rubyforge_project: clip
66
- rubygems_version: 1.2.0
67
+ rubygems_version: 1.3.0
67
68
  signing_key:
68
69
  specification_version: 2
69
70
  summary: Command-line parsing made short and sweet