Class: Arc42Pandoc::ApiaryBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/arc42-pandoc/apiary/apiary_builder.rb

Instance Method Summary collapse

Constructor Details

#initializeApiaryBuilder

Returns a new instance of ApiaryBuilder.



7
8
9
# File 'lib/arc42-pandoc/apiary/apiary_builder.rb', line 7

def initialize

end

Instance Method Details

#create(output, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/arc42-pandoc/apiary/apiary_builder.rb', line 11

def create(output, options = {})
  options = sanatize_options(options)

  template = find_template(options[:template], options[:language])
  abort "The template is not available for the language '#{options[:language]}'. Check 'apiary list' for available templates." unless File.file?(template)

  ruyml = Ruyml::Data.new(options)
  ruyml.render_file(template, output)
end

#listObject



21
22
23
24
25
26
27
28
# File 'lib/arc42-pandoc/apiary/apiary_builder.rb', line 21

def list
  files = Dir[File.join(dirname, 'templates', '**/*')].select { |file| File.file?(file) }
  chunks = files.group_by { |file| file.split('/')[-2] }

  chunks.each { |lang, templates|
    puts "Templates available for language '#{lang}': \n  * #{templates.map { |t| t.split('/')[-1] }.join("\n  * ")}\n\n"
  }
end