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



52
53
54
# File 'lib/relaton/cli/relaton_file.rb', line 52

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 directory, output directory and custom configuration options. Then it wll extract Relaton XML files to output directory from the source 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



33
34
35
# File 'lib/relaton/cli/relaton_file.rb', line 33

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

Instance Method Details

#concatenateObject



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

def concatenate
  write_to_file(bibcollection.to_xml)
end

#extractObject



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

def extract
  extract_and_write_to_files
end