lib/nake.rb in nake-0.0.5 vs lib/nake.rb in nake-0.0.6
- old
+ new
@@ -1,11 +1,11 @@
# encoding: utf-8
require "nake/task"
module Nake
- VERSION ||= "0.0.5"
+ VERSION ||= "0.0.6"
def self.verbose
@@verbose
rescue NameError
@@verbose = true
end
@@ -39,23 +39,19 @@
end
end
end
def self.parse(args = ARGV)
- @result ||= begin
- args.inject(Hash.new) do |hash, argument|
- hash[:nake] ||= Array.new
- hash[:task] ||= Array.new
- hash[:file] ||= "tasks.rb" if File.exist?("tasks.rb")
- if argument.match(/^-/) && hash[:task].empty?
- hash[:nake].push(argument)
- elsif File.exist?(argument)
- hash[:file] = argument
- else
- hash[:task].push(argument)
- end
- hash
+ default = {nake: Array.new, task: Array.new}
+ args.inject(default) do |hash, argument|
+ if argument.match(/^-/) && hash[:task].empty?
+ hash[:nake].push(argument)
+ elsif File.exist?(argument) && hash[:file].nil? # just the first one
+ hash[:file] = argument
+ else
+ hash[:task].push(argument)
end
+ hash
end
end
def self.run_args
# TODO: proceed --debug and --verbose first! ... to by slo tak, ze by se iterovalo pres Nake.args a pokud je to pritomno tak proved