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.



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

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:



37
38
39
# File 'lib/metanorma/cli/compiler.rb', line 37

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

Instance Method Details

#compileArray<String>

Returns:



32
33
34
# File 'lib/metanorma/cli/compiler.rb', line 32

def compile
  compile_file
end

#validate_file_path(file) ⇒ Object



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

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