Sha256: e13b7b5181f66675c37a9e5e957bf7e42e4c49130ff04fbdd8240f31be599f19

Contents?: true

Size: 535 Bytes

Versions: 9

Compression:

Stored size: 535 Bytes

Contents

module KumoKeisei
  class FileLoader
    def initialize(options)
      @config_dir_path = options[:config_dir_path]
    end

    def load_config!(file_name, context = nil)
      erb_result = ERB.new(File.read(file_path(file_name))).result(context)
      YAML.load(erb_result)
    end

    def load_config(file_name)
      path = file_path(file_name)
      return {} unless File.exist?(path)
      load_config!(file_name)
    end

    private

    def file_path(file_name)
      File.join(@config_dir_path, file_name)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
kumo_keisei-2.1.1 lib/kumo_keisei/file_loader.rb
kumo_keisei-2.1.1.pre lib/kumo_keisei/file_loader.rb
kumo_keisei-2.1.0 lib/kumo_keisei/file_loader.rb
kumo_keisei-2.0.0 lib/kumo_keisei/file_loader.rb
kumo_keisei-1.0.0 lib/kumo_keisei/file_loader.rb
kumo_keisei-1.0.0.pre lib/kumo_keisei/file_loader.rb
kumo_keisei-0.0.54 lib/kumo_keisei/file_loader.rb
kumo_keisei-0.0.53 lib/kumo_keisei/file_loader.rb
kumo_keisei-0.0.52 lib/kumo_keisei/file_loader.rb