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!

Constructor Details

#initialize(opts) ⇒ Style

Returns a new instance of Style.



276
277
278
279
280
281
# File 'lib/rouge/cli.rb', line 276

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

  @theme = theme_class.new(opts)
end

Class Method Details

.descObject



244
245
246
# File 'lib/rouge/cli.rb', line 244

def self.desc
  "print CSS styles"
end

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

Yields:

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


248
249
250
251
252
253
254
255
256
257
258
# File 'lib/rouge/cli.rb', line 248

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|
end

.parse(argv) ⇒ Object



260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/rouge/cli.rb', line 260

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



283
284
285
# File 'lib/rouge/cli.rb', line 283

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