Sha256: 66dc15f74932602159e6f2ac55aedf6b231d5e4694d3ef9eb0d4563ebf3d68a9

Contents?: true

Size: 777 Bytes

Versions: 2

Compression:

Stored size: 777 Bytes

Contents

# vim:ft=ruby:fileencoding=utf-8

require 'yaml'

module ToPass
  # The AlgorithmReader's primary API is to load the rules from a YAML-file
  # into a Hash.
  #
  # Algorithms are searched in a list of standard directories. Those are defined
  # and managed in ToPass::Directories
  #
  # see ToPass::Converter for usage of the loaded algorithm
  class AlgorithmReader < FileReader
    def initialize(algorithm) # :nodoc:
      super(algorithm, 'algorithms')
    end

    class << self
      def extension # :nodoc:
        'yml'
      end
    end

    def load_from_file # :nodoc:
      fn = super

      YAML.load_file(fn.expand_path)
    rescue LoadError
      raise LoadError, "algorithm #{@file} could not be found in #{load_path.join(', ')}" if fn.nil?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
to_pass-1.0.1 lib/to_pass/algorithm_reader.rb
to_pass-1.0.0 lib/to_pass/algorithm_reader.rb