lib/rouge/cli.rb in rouge-1.2.0 vs lib/rouge/cli.rb in rouge-1.3.0

- old
+ new

@@ -73,14 +73,18 @@ end def initialize(options={}) end - def error!(msg, status=1) + def self.error!(msg, status=1) raise Error.new(msg, status) end + def error!(*a) + self.class.error!(*a) + end + def self.class_from_arg(arg) case arg when 'version', '--version' Version when 'help' @@ -235,24 +239,22 @@ end @lexer_opts = opts[:lexer_opts] formatter_class = Formatter.find(opts[:formatter]) \ - or error! "unknown formatter #{opts[:formatter]}" + or error! "unknown formatter #{opts[:formatter]}" @formatter = formatter_class.new(opts[:formatter_opts]) end def run - formatter.format(lexer.lex(input)) do |chunk| - print chunk - end + formatter.format(lexer.lex(input), &method(:print)) end private def self.parse_cgi(str) - pairs = CGI.parse(str).map { |k, v| v.first } + pairs = CGI.parse(str).map { |k, v| [k.to_sym, v.first] } Hash[pairs] end end class Style < CLI @@ -287,10 +289,11 @@ new(opts) end def initialize(opts) - theme_class = Theme.find(opts.delete(:theme_name)) \ + theme_name = opts.delete(:theme_name) + theme_class = Theme.find(theme_name) \ or error! "unknown theme: #{theme_name}" @theme = theme_class.new(opts) end