Some more idiomatic Ruby code.

This commit is contained in:
Renato Silva 2014-12-02 21:40:41 -02:00
parent 5f234f88e8
commit 74223b62d7
2 changed files with 20 additions and 18 deletions

View File

@ -1,2 +1,5 @@
Style/IndentationWidth:
Width: 4
Metrics/LineLength:
Max: 160

View File

@ -122,7 +122,7 @@ module EasyOptions
doc = doc.find_all do |line|
line =~ /^##[^#]*/
end
doc = doc.map do |line|
doc.map do |line|
line.strip!
line.sub!(/^## ?/, '')
line.gsub!(/@script.name/, File.basename($PROGRAM_NAME))
@ -202,14 +202,14 @@ module EasyOptions
else
puts @documentation
end
exit -1
exit(-1)
end
# Regular arguments
next_is_value = false
raw_arguments.each do |argument|
if argument.start_with?('-')
known_option = @known_options.find { |known_option| known_option.in?(argument) }
known_option = @known_options.find { |option| option.in?(argument) }
next_is_value = (known_option && !known_option.boolean)
else
arguments << argument unless next_is_value
@ -218,7 +218,7 @@ module EasyOptions
end
# Bash support
if BashOutput
return unless BashOutput
@options.keys.each do |name|
puts "#{name}=\"#{@options[name].to_s.sub('true', 'yes')}\""
end
@ -227,7 +227,6 @@ module EasyOptions
puts "arguments+=(\"#{argument}\")"
end
end
end
def self.finish(error)
$stderr.puts "Error: #{error}."