lib/bundler/ui/shell.rb in bundler-1.14.6 vs lib/bundler/ui/shell.rb in bundler-1.15.0.pre.1
- old
+ new
@@ -38,20 +38,19 @@
def error(msg, newline = nil)
tell_me(msg, :red, newline) if level("error")
end
def debug(msg, newline = nil)
- tell_me(msg, nil, newline) if level("debug")
+ tell_me(msg, nil, newline) if debug?
end
def debug?
- # needs to be false instead of nil to be newline param to other methods
- level("debug") ? true : false
+ level("debug")
end
def quiet?
- LEVELS.index(@level) <= LEVELS.index("warn")
+ level("quiet")
end
def ask(msg)
@shell.ask(msg)
end
@@ -64,14 +63,18 @@
@shell.no?(msg)
end
def level=(level)
raise ArgumentError unless LEVELS.include?(level.to_s)
- @level = level
+ @level = level.to_s
end
def level(name = nil)
- name ? LEVELS.index(name) <= LEVELS.index(@level) : @level
+ return @level unless name
+ unless index = LEVELS.index(name)
+ raise "#{name.inspect} is not a valid level"
+ end
+ index <= LEVELS.index(@level)
end
def trace(e, newline = nil, force = false)
return unless debug? || force
msg = "#{e.class}: #{e.message}\n#{e.backtrace.join("\n ")}"