class Rouge::CLI::Help::Highlight::Style

Public Class Methods

desc() click to toggle source
# File lib/rouge/cli.rb, line 266
def self.desc
  "print CSS styles"
end
doc() { |%|usage: rougify style [] []| 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 %| end| ... } click to toggle source
# File lib/rouge/cli.rb, line 270
  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

  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

  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

  def run
    @theme.render(&method(:puts))
  end
end
new(opts) click to toggle source
# File lib/rouge/cli.rb, line 301
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
parse(argv) click to toggle source
# File lib/rouge/cli.rb, line 285
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

Public Instance Methods

run() click to toggle source
# File lib/rouge/cli.rb, line 309
def run
  @theme.render(&method(:puts))
end