Class: Relaton::Cli::BaseConvertor

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton/cli/base_convertor.rb

Direct Known Subclasses

XMLConvertor, YAMLConvertor

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, options = {}) ⇒ BaseConvertor

Returns a new instance of BaseConvertor.



9
10
11
12
13
14
15
16
17
18
# File 'lib/relaton/cli/base_convertor.rb', line 9

def initialize(file, options = {})
  @file = file
  @options = options
  @outdir = options.fetch(:outdir, nil)
  @writable = options.fetch(:write, true)
  @overwrite = options.fetch(:overwrite, true)
  @default_filelabel = 0

  install_dependencies(options[:require] || [])
end

Class Method Details

.to_html(file, style = nil, template = nil) ⇒ String

Convert to HTML

This interface expect us to provide Relaton collection XML as XML/RXL, and necessary styels / templates then it will be used convert that collection to HTML.

Parameters:

  • file (String)

    Relaton collection file path

  • style (String) (defaults to: nil)

    Stylesheet file path for styles

  • template (String) (defaults to: nil)

    The liquid tempalte directory

Returns:

  • (String)

    HTML



37
38
39
40
41
42
43
44
# File 'lib/relaton/cli/base_convertor.rb', line 37

def self.to_html(file, style = nil, template = nil)
  new(
    file,
    style: style || File.join(File.dirname(__FILE__), "../../../templates/index-style.css"),
    template: template || File.join(File.dirname(__FILE__), "../../../templates/"),
    extension: "html"
  ).to_html
end

Instance Method Details

#to_htmlString

Returns HTML.

Returns:

  • (String)

    HTML



21
22
23
24
# File 'lib/relaton/cli/base_convertor.rb', line 21

def to_html
  content = convert_to_html
  write_to_a_file(content)
end