module Athena

See README.

Constants

DEFAULT_EMPTY
DEFAULT_SEPARATOR
VERSION

Public Instance Methods

input_formats() click to toggle source
   # File lib/athena.rb
52 def input_formats
53   Formats.formats[:in].sort
54 end
output_formats() click to toggle source
   # File lib/athena.rb
56 def output_formats
57   Formats.formats[:out].sort
58 end
run(config, spec, format, input, output) click to toggle source
   # File lib/athena.rb
45 def run(config, spec, format, input, output)
46   Formats[:out, format, output].run(
47     Formats[:in, spec, build_config(config)],
48     input
49   )
50 end
valid_format?(direction, format) click to toggle source
   # File lib/athena.rb
60 def valid_format?(direction, format)
61   Formats.valid_format?(direction, format)
62 end
valid_input_format?(format) click to toggle source
   # File lib/athena.rb
64 def valid_input_format?(format)
65   valid_format?(:in, format)
66 end
valid_output_format?(format) click to toggle source
   # File lib/athena.rb
68 def valid_output_format?(format)
69   valid_format?(:out, format)
70 end

Private Instance Methods

build_config(config) click to toggle source
    # File lib/athena.rb
 74 def build_config(config)
 75   hash = {}
 76 
 77   config.each { |field, value|
 78     if field.to_s =~ /\A__/
 79       hash[field] = value
 80     else
 81       case value
 82         when String, Array
 83           elements, value = [*value], {}
 84         when Hash
 85           elements = value[:elements] || value[:element].to_a
 86 
 87           raise ArgumentError, "no elements specified for field #{field}" unless elements.is_a?(Array)
 88         else
 89           raise ArgumentError, "illegal value for field #{field}"
 90       end
 91 
 92       separator = value[:separator] || DEFAULT_SEPARATOR
 93 
 94       elements.each { |element|
 95         (hash[element] ||= {})[field] = {
 96           :string   => value[:string] || ['%s'] * elements.size * separator,
 97           :empty    => value[:empty]  || DEFAULT_EMPTY,
 98           :elements => elements
 99         }
100       }
101     end
102   }
103 
104   hash
105 end