Class: Metanorma::Cli::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/metanorma/cli/compiler.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, options) ⇒ Compiler

Returns a new instance of Compiler.



8
9
10
11
12
13
# File 'lib/metanorma/cli/compiler.rb', line 8

def initialize(file, options)
  validate_file_path(file)
  @file = file
  @options = options
  normalize_special_options
end

Class Method Details

.compile(file, options) ⇒ Array<String>

Returns:



34
35
36
# File 'lib/metanorma/cli/compiler.rb', line 34

def self.compile(file, options)
  new(file, options).compile
end

Instance Method Details

#compileArray<String>

Returns:



29
30
31
# File 'lib/metanorma/cli/compiler.rb', line 29

def compile
  compile_file
end

#validate_file_path(file) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/metanorma/cli/compiler.rb', line 15

def validate_file_path(file)
  path = Pathname.new(file)
  # Check if provided file path exists
  unless path.exist?
    raise ::Metanorma::Cli::Errors::FileNotFoundError.new("Specified input file '#{file}' does not exist")
  end

  # Check if provided file is really a file
  unless path.file?
    raise ::Metanorma::Cli::Errors::FileNotFoundError.new("Specified input file '#{file}' is not a file")
  end
end