Class: Rouge::CLI::Style

Inherits:
Rouge::CLI show all
Defined in:
lib/rouge/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Rouge::CLI

class_from_arg, error!, #error!, normalize_syntax

Constructor Details

#initialize(opts) ⇒ Style

Returns a new instance of Style.


329
330
331
332
333
334
335
# File 'lib/rouge/cli.rb', line 329

def initialize(opts)
  theme_name = opts.delete(:theme_name)
  theme_class = Theme.find(theme_name) \
    or error! "unknown theme: #{theme_name}"

  @theme = theme_class.new(opts)
end

Class Method Details

.descObject


294
295
296
# File 'lib/rouge/cli.rb', line 294

def self.desc
  "print CSS styles"
end

.doc {|%|usage: rougify style [<theme-name>] [<options>]|| ... } ⇒ Object

Yields:

  • (%|usage: rougify style [<theme-name>] [<options>]|)

298
299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/rouge/cli.rb', line 298

def self.doc
  return enum_for(:doc) unless block_given?

  yield %|usage: rougify style [<theme-name>] [<options>]|
  yield %||
  yield %|Print CSS styles for the given theme.  Extra options are|
  yield %|passed to the theme.  Theme defaults to thankful_eyes.|
  yield %||
  yield %|options:|
  yield %|  --scope	(default: .highlight) a css selector to scope by|
  yield %||
  yield %|available themes:|
  yield %|  #{Theme.registry.keys.sort.join(', ')}|
end

.parse(argv) ⇒ Object


313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/rouge/cli.rb', line 313

def self.parse(argv)
  opts = { :theme_name => 'thankful_eyes' }

  until argv.empty?
    arg = argv.shift
    case arg
    when /--(\w+)/
      opts[$1.tr('-', '_').to_sym] = argv.shift
    else
      opts[:theme_name] = arg
    end
  end

  new(opts)
end

Instance Method Details

#runObject


337
338
339
# File 'lib/rouge/cli.rb', line 337

def run
  @theme.render(&method(:puts))
end