lib/jeckyl.rb in jeckyl-0.3.7 vs lib/jeckyl.rb in jeckyl-0.4.0
- old
+ new
@@ -325,11 +325,11 @@
# parse the given command line using the defined options
#
# @param [Array] args which should usually be ARGV
# @yield self and optparse object to allow incidental options to be added
# @return false if --help so that the caller can decide what to do (e.g. exit)
- def optparse(args)
+ def optparse(args=ARGV)
# ensure calls to parameter methods do not trample on things
@_last_symbol = nil
opts = OptionParser.new
@@ -343,17 +343,10 @@
# loop through each of the options saved
@_options.each_pair do |param, options|
options << @_descriptions[param] if @_descriptions.has_key?(param)
- # opt_str = ''
- # options.each do |os|
- # opt_str << os.inspect
- # end
-
- # puts "#{param}: #{opt_str}"
-
# get the method itself to call with the given arg
pref_method = self.method("#{prefix}_#{param}".to_sym)
# now process the option
opts.on(*options) do |val|
@@ -383,20 +376,22 @@
# output the hash as a formatted set
def to_s(opts={})
keys = self.keys.collect {|k| k.to_s}
cols = 0
+ strs = Array.new
keys.each {|k| cols = k.length if k.length > cols}
keys.sort.each do |key_s|
- print ' '
- print key_s.ljust(cols)
+ str = ' '
+ str << key_s.ljust(cols)
key = key_s.to_sym
desc = @_descriptions[key]
value = self[key].inspect
- print ": #{value}"
- print " (#{desc})" unless desc.nil?
- puts
+ str << ": #{value}"
+ str << " (#{desc})" unless desc.nil?
+ strs << str
end
+ return strs.join("\n")
end
protected