[DRE-commits] [ruby-slop] 01/03: Imported Upstream version 3.6.0

Youhei SASAKI uwabami-guest at moszumanska.debian.org
Mon Aug 11 18:42:26 UTC 2014


This is an automated email from the git hooks/post-receive script.

uwabami-guest pushed a commit to annotated tag debian/3.6.0-1
in repository ruby-slop.

commit f2caad212ff36daa387a2869f29ff232bc3ad79d
Author: Youhei SASAKI <uwabami at gfd-dennou.org>
Date:   Tue Aug 12 03:40:10 2014 +0900

    Imported Upstream version 3.6.0
---
 .travis.yml         |   5 +----
 CHANGES.md          |   6 ++++++
 README.md           |  48 ++++++++++++++++++++++++++++++++++--------------
 checksums.yaml.gz   | Bin 268 -> 269 bytes
 lib/slop.rb         |   2 +-
 lib/slop/option.rb  |   7 ++++++-
 metadata.yml        |  22 +++++++++++-----------
 slop.gemspec        |   2 +-
 test/option_test.rb |   7 +++++++
 9 files changed, 67 insertions(+), 32 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index e98a433..6fba0ce 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,11 +1,8 @@
 rvm:
-  - 1.8.7
-  - 1.9.2
   - 1.9.3
+  - 2.1
   - ruby-head
-  - jruby-18mode
   - jruby-19mode
-  - rbx-18mode
 notifications:
   email:
     on_success: change
diff --git a/CHANGES.md b/CHANGES.md
index fc3123c..c500beb 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,3 +1,9 @@
+3.6.0 (2014-06-18)
+------------------
+
+* Add example of rest arguments usage in the readme file #139
+* Default values on options are printed in the help message #134
+
 3.5.0 (2014-03-12)
 ------------------
 
diff --git a/README.md b/README.md
index 51a75ff..334c34b 100644
--- a/README.md
+++ b/README.md
@@ -41,20 +41,16 @@ Configuration Options
 
 All of these options can be sent to `Slop.new` or `Slop.parse` in Hash form.
 
-* `strict` - Enable strict mode. When processing unknown options, Slop will
-  raise an `InvalidOptionError`. **default:** *false*.
-* `help` - Automatically add the `--help` option. **default:** *false*.
-* `banner` - Set the help banner text. **default:** *nil*.
-* `ignore_case` - When enabled, `-A` will look for the `-a` option if `-A`
-  does not exist. **default:** *false*.
-* `autocreate` - Autocreate options on the fly. **default:** *false*.
-* `arguments` - Force all options to expect arguments. **default:** *false*.
-* `optional_arguments` - Force all options to accept optional arguments.
-  **default:** *false*.
-* `multiple_switches` - When disabled, Slop will parse `-abc` as the option `a`
-   with the argument `bc` rather than 3 separate options. **default:** *true*.
-* `longest_flag` - The longest string flag, used to aid configuring help
-   text. **default:** *0*.
+| Option | Description | Default/Example |
+| ------ | ----------- | --------------- |
+| strict | Enable strict mode. Slop will raise an `InvalidOptionError` for unkown options. | `false` |
+| help   | Automatically add the `--help` option. | `false` |
+| banner | Set the help banner text. | `nil` |
+| ignore_case | When enabled, `-A` will look for the `-a` option if `-A` does not exist. | `false` |
+| autocreate | Autocreate options on the fly. | `false` |
+| arguments | Force all options to expect arguments. | `false` |
+| optional_arguments | Force all options to accept optional arguments. | `false` |
+| multiple_switches | When disabled, Slop will parse `-abc` as the option `a` with the argument `bc` rather than 3 separate options. | `true` |
 
 Lists
 -----
@@ -139,6 +135,30 @@ opts.to_hash(true) # Pass true to tell Slop to merge sub-command option values.
 # => { :v => nil, :add => { :v => true, :name => "Lee" } }
 ```
 
+Remaining arguments
+-------------------
+
+The *parse!*  method will remove any options and option arguments from the original Array:
+
+```ruby
+# restarguments.rb
+opts = Slop.parse! do
+  on :foo
+end
+```
+
+Example:
+
+```
+ruby restarguments.rb --foo bar
+```
+
+```
+opts.to_hash = { :foo => true }
+
+ARGV #=> ["bar"]
+```
+
 Woah woah, why you hating on OptionParser?
 ------------------------------------------
 
diff --git a/checksums.yaml.gz b/checksums.yaml.gz
index 45dd8f9..76c7002 100644
Binary files a/checksums.yaml.gz and b/checksums.yaml.gz differ
diff --git a/lib/slop.rb b/lib/slop.rb
index 2cb5b33..6943176 100644
--- a/lib/slop.rb
+++ b/lib/slop.rb
@@ -4,7 +4,7 @@ require 'slop/commands'
 class Slop
   include Enumerable
 
-  VERSION = '3.5.0'
+  VERSION = '3.6.0'
 
   # The main Error class, all Exception classes inherit from this class.
   class Error < StandardError; end
diff --git a/lib/slop/option.rb b/lib/slop/option.rb
index be0668c..f2f6a19 100644
--- a/lib/slop/option.rb
+++ b/lib/slop/option.rb
@@ -138,7 +138,12 @@ class Slop
         out << (' ' * (@slop.config[:longest_flag] + 8))
       end
 
-      "#{out}#{description}"
+      if config[:default]
+        default = config[:default]
+        "#{out}#{description} (default: #{default})"
+      else
+        "#{out}#{description}"
+      end
     end
     alias help to_s
 
diff --git a/metadata.yml b/metadata.yml
index 7d023c0..d5af654 100644
--- a/metadata.yml
+++ b/metadata.yml
@@ -1,41 +1,41 @@
 --- !ruby/object:Gem::Specification
 name: slop
 version: !ruby/object:Gem::Version
-  version: 3.5.0
+  version: 3.6.0
 platform: ruby
 authors:
 - Lee Jarvis
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2014-03-12 00:00:00.000000000 Z
+date: 2014-07-18 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: rake
   requirement: !ruby/object:Gem::Requirement
     requirements:
-    - - ">="
+    - - '>='
       - !ruby/object:Gem::Version
         version: '0'
   type: :development
   prerelease: false
   version_requirements: !ruby/object:Gem::Requirement
     requirements:
-    - - ">="
+    - - '>='
       - !ruby/object:Gem::Version
         version: '0'
 - !ruby/object:Gem::Dependency
   name: minitest
   requirement: !ruby/object:Gem::Requirement
     requirements:
-    - - "~>"
+    - - ~>
       - !ruby/object:Gem::Version
         version: 5.0.0
   type: :development
   prerelease: false
   version_requirements: !ruby/object:Gem::Requirement
     requirements:
-    - - "~>"
+    - - ~>
       - !ruby/object:Gem::Version
         version: 5.0.0
 description: A simple DSL for gathering options and parsing the command line
@@ -44,8 +44,8 @@ executables: []
 extensions: []
 extra_rdoc_files: []
 files:
-- ".gitignore"
-- ".travis.yml"
+- .gitignore
+- .travis.yml
 - CHANGES.md
 - Gemfile
 - LICENSE
@@ -69,17 +69,17 @@ require_paths:
 - lib
 required_ruby_version: !ruby/object:Gem::Requirement
   requirements:
-  - - ">="
+  - - '>='
     - !ruby/object:Gem::Version
       version: 1.8.7
 required_rubygems_version: !ruby/object:Gem::Requirement
   requirements:
-  - - ">="
+  - - '>='
     - !ruby/object:Gem::Version
       version: '0'
 requirements: []
 rubyforge_project: 
-rubygems_version: 2.2.0
+rubygems_version: 2.0.14
 signing_key: 
 specification_version: 4
 summary: Simple Lightweight Option Parsing
diff --git a/slop.gemspec b/slop.gemspec
index d3500f8..d535e60 100644
--- a/slop.gemspec
+++ b/slop.gemspec
@@ -1,6 +1,6 @@
 Gem::Specification.new do |s|
   s.name        = 'slop'
-  s.version     = '3.5.0'
+  s.version     = '3.6.0'
   s.summary     = 'Simple Lightweight Option Parsing'
   s.description = 'A simple DSL for gathering options and parsing the command line'
   s.author      = 'Lee Jarvis'
diff --git a/test/option_test.rb b/test/option_test.rb
index 372cd1b..cec73c9 100644
--- a/test/option_test.rb
+++ b/test/option_test.rb
@@ -130,6 +130,13 @@ class OptionTest < TestCase
     assert_equal "    -V,             Display the version", slop.fetch_option(:V).help
   end
 
+  test "printing options that have defaults" do
+    opts = Slop.new
+    opts.on :n, :name=, 'Your name', :default => 'Lee'
+
+    assert_equal "    -n, --name      Your name (default: Lee)", opts.fetch_option(:name).to_s
+  end
+
   test "overwriting the help text" do
     slop = Slop.new
     slop.on :foo, :help => '    -f, --foo  SOMETHING FOOEY'

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-slop.git



More information about the Pkg-ruby-extras-commits mailing list