Skip to content

Commit

Permalink
Parse default values looking for Integer rather Fixnum to be forward …
Browse files Browse the repository at this point in the history
…compatible with Ruby 2.4.
  • Loading branch information
florianpilz committed Oct 2, 2017
1 parent b8fd6bc commit f0bf29a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Version History
===============

Version 1.2.1 (2017-10-02)
--------------------------

* Adjusted parsing of default values to look for `Integer` rather `Fixnum`
to be compatible with Ruby 2.4.0.

Version 1.2.0 (2013-12-29)
--------------------------

Expand Down
4 changes: 2 additions & 2 deletions lib/micro-optparse/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def process!(arguments = ARGV)
@used_short << short = o[:settings][:no_short] ? nil : o[:settings][:short] || short_from(o[:name])
@result[o[:name]] = o[:settings][:default] || false unless o[:settings][:optional] # set default
name = o[:name].to_s.gsub("_", "-")
klass = o[:settings][:default].class == Fixnum ? Integer : o[:settings][:default].class
klass = o[:settings][:default].is_a?(Integer) ? Integer : o[:settings][:default].class

args = [o[:description]]
args << "-" + short if short
Expand All @@ -70,7 +70,7 @@ def process!(arguments = ARGV)
rescue OptionParser::ParseError => e
puts e.message ; exit(1)
end

validate(@result) if self.respond_to?("validate")
@result
end
Expand Down
2 changes: 1 addition & 1 deletion lib/micro-optparse/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Micro
module Optparse
VERSION = "1.2.0"
VERSION = "1.2.1"
end
end

0 comments on commit f0bf29a

Please sign in to comment.