Sha256: b40a5e0017a5e97c53675d33dc4379b9d8d5305dcb55e9ce5f364d8c51dfdf08

Contents?: true

Size: 672 Bytes

Versions: 7

Compression:

Stored size: 672 Bytes

Contents

require 'natives/catalog/merger'
require 'psych'
require 'yaml'

module Natives
  class Catalog
    class Loader
      def initialize(opts={})
        @merger = opts.fetch(:merger, Merger.new)
      end

      def load_from_paths(paths)
        master_hash = {}
        Array(paths).each do |path|
          yaml_files_in_path(path).sort.each do |file|
            @merger.merge_catalog!(master_hash, load_yaml_file(file))
          end
        end
        master_hash
      end

      def yaml_files_in_path(path)
        Dir.glob(File.join(path, '*.{yml,yaml}'))
      end

      def load_yaml_file(filename)
        YAML.load_file(filename)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
natives-0.6.2 lib/natives/catalog/loader.rb
natives-0.6.1 lib/natives/catalog/loader.rb
natives-0.6.0 lib/natives/catalog/loader.rb
natives-0.5.5 lib/natives/catalog/loader.rb
natives-0.5.4 lib/natives/catalog/loader.rb
natives-0.5.3 lib/natives/catalog/loader.rb
natives-0.5.2 lib/natives/catalog/loader.rb