Class: Mizuho::Generator
- Inherits:
-
Object
- Object
- Mizuho::Generator
- Defined in:
- lib/mizuho/generator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(input, options = {}) ⇒ Generator
constructor
A new instance of Generator.
- #start ⇒ Object
Constructor Details
#initialize(input, options = {}) ⇒ Generator
Returns a new instance of Generator.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/mizuho/generator.rb', line 34 def initialize(input, = {}) @options = @input_file = input @output_file = [:output] || default_output_filename(input) @id_map_file = [:id_map] || default_id_map_filename(input) @icons_dir = [:icons_dir] @conf_file = [:conf_file] @attributes = [:attributes] || [] @enable_topbar = [:topbar] @no_run = [:no_run] @commenting_system = [:commenting_system] @index = [:index] @index_filename = [:index_filename] || default_index_filename(input) if @commenting_system == 'juvia' (, :juvia_url, :juvia_site_key) end end |
Class Method Details
.run_asciidoc(input, output, icons_dir = nil, conf_file = nil, attributes = []) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/mizuho/generator.rb', line 78 def self.run_asciidoc(input, output, icons_dir = nil, conf_file = nil, attributes = []) args = [ ASCIIDOC, "-b", "html5", "-a", "theme=flask", "-a", "icons", "-n" ].flatten if icons_dir args << "-a" args << "iconsdir=#{icons_dir}" end attributes.each do |attribute| args << "-a" args << attribute end if conf_file # With the splat operator we support a string and an array of strings. [*conf_file].each do |cf| args << "-f" args << cf end end args += ["-o", output, input] if !system(*args) raise GenerationError, "Asciidoc failed." end end |
Instance Method Details
#start ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/mizuho/generator.rb', line 52 def start if @commenting_system @id_map = IdMap.new if File.exist?(@id_map_file) @id_map.load(@id_map_file) else warn "No ID map file, generating one (#{@id_map_file})..." end end if !@no_run self.class.run_asciidoc(@input_file, @output_file, @icons_dir, @conf_file, @attributes) end transform(@output_file) if @commenting_system @id_map.save(@id_map_file) stats = @id_map.stats if stats[:fuzzy] > 0 warn "Warning: #{stats[:fuzzy]} fuzzy ID(s)" end if stats[:orphaned] > 0 warn "Warning: #{stats[:orphaned]} unused ID(s)" end end end |