Class: Frozen::Generators::RougeGenerator
- Inherits:
-
FrozenRails::Generator
- Object
- Rails::Generators::Base
- FrozenRails::Generator
- Frozen::Generators::RougeGenerator
- Defined in:
- lib/generators/frozen/rouge_generator.rb
Constant Summary
Constants included from Nodeable
Nodeable::REQUIRED_EXECUTABLES
Instance Method Summary collapse
Instance Method Details
#generate_rouge_css_stylesheet ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/frozen/rouge_generator.rb', line 13 def generate_rouge_css_stylesheet theme = [:rouge_theme] if theme.blank? && behavior == :invoke && $stdin.tty? # Run in subshell so we pick up newly installed gem without needing to require it in the current process. themes = `bundle exec ruby -e "require 'rouge'; puts Rouge::Theme.registry.keys.sort"`.split("\n") say_status :info, "Available Rouge themes (#{themes.size}):", :blue themes.each_with_index { |t, i| say " #{i + 1}. #{t}" } answer = ask("Choose a theme (name or number) [github]") theme = if /^\d+$/.match?(answer) themes[answer.to_i - 1] else answer.presence end end theme ||= "github" say_status :info, "Generating Rouge CSS for theme #{theme}", :blue run "rougify style #{theme} > app/assets/rouge/rouge.css" end |