Module: Indexer::Importer::YAMLImportation

Included in:
Indexer::Importer
Defined in:
lib/indexer/importer/yaml.rb

Overview

Import metadata from a YAML source.

Instance Method Summary collapse

Instance Method Details

#import(source) ⇒ Object

YAML import procedure.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/indexer/importer/yaml.rb', line 12

def import(source)
  if File.file?(source)
    case File.extname(source)
    when '.yaml', '.yml'
      load_yaml(source)
      true
    else
      text = read(source)
      if text =~ /\A---/
        load_yaml(source)
        true
      else
        super(source) if defined?(super)
      end
    end
  else
    super(source) if defined?(super)
  end
end

#load_yaml(file) ⇒ Object

Import metadata from YAML file.



35
36
37
# File 'lib/indexer/importer/yaml.rb', line 35

def load_yaml(file)
  .merge!(YAML.load_file(file))
end