Class: Relaton::Cli::RelatonFile

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, options = {}) ⇒ RelatonFile

Returns a new instance of RelatonFile.



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

def initialize(source, options = {})
  @source = source
  @options = options
  @outdir = options.fetch(:outdir, nil)
  @outfile = options.fetch(:outfile, nil)
end

Class Method Details

.concatenate(source, outfile, options = {}) ⇒ Object

Concatenate files

This interface expect us to provide a source directory, output file and custom configuration options. Normally, this expect the source directory to contain RXL fles, but it also converts any YAML files to RXL and then finally combines those together.

This interface also allow us to provdie options like title and organization and then it usage those details to generate the collection file.

Parameters:

  • source (Dir)

    The source directory for files

  • output (String)

    The collection output file

  • options (Hash) (defaults to: {})

    Options as hash key value pair



57
58
59
# File 'lib/relaton/cli/relaton_file.rb', line 57

def self.concatenate(source, outfile, options = {})
  new(source, options.merge(outfile: outfile)).concatenate
end

.extract(source, outdir, options = {}) ⇒ Object

Extract files

This interface expect us to provide a source file / directory, output directory and custom configuration options. Then it wll extract Relaton XML file / files to output directory from the source file / directory. During this process it will use custom options when available.

Parameters:

  • source (Dir)

    The source directory for files

  • outdir (Dir)

    The output directory for files

  • options (Hash) (defaults to: {})

    Options as hash key value pair



38
39
40
# File 'lib/relaton/cli/relaton_file.rb', line 38

def self.extract(source, outdir, options = {})
  new(source, options.merge(outdir: outdir)).extract
end

.split(source, outdir = nil, options = {}) ⇒ Object

Split collection

This interface expects us to provide a Relaton Collection file and also an output directory, then it will split that collection into multiple files.

By default it usages ‘rxl` extension for these new files, but we can also customize that by providing the correct one as `extension` option parameter.

Parameters:

  • source (File)

    The source collection file

  • output (Dir)

    The output directory for files

  • options (Hash) (defaults to: {})

    Options as hash key value pair



75
76
77
# File 'lib/relaton/cli/relaton_file.rb', line 75

def self.split(source, outdir = nil, options = {})
  new(source, options.merge(outdir: outdir)).split
end

Instance Method Details

#concatenateObject



18
19
20
# File 'lib/relaton/cli/relaton_file.rb', line 18

def concatenate
  concatenate_and_write_to_files
end

#extractObject



14
15
16
# File 'lib/relaton/cli/relaton_file.rb', line 14

def extract
  extract_and_write_to_files
end

#splitObject



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

def split
  split_and_write_to_files
end