Sha256: 052015aec8d1221caa333452563272cd6562bf0489312539b79d39567e829103

Contents?: true

Size: 462 Bytes

Versions: 7

Compression:

Stored size: 462 Bytes

Contents

# frozen_string_literal: true

require 'json'

module Spout
  module Helpers
    class JsonLoader

      def self.get_json(file_name, file_type)
        file = Dir.glob("#{file_type.to_s.downcase}s/**/#{file_name.to_s.downcase}.json", File::FNM_CASEFOLD).first
        json = JSON.parse(File.read(file)) rescue json = nil
        json
      end

      def self.get_variable(variable_name)
        get_json(variable_name, 'variable')
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
spout-0.12.1 lib/spout/helpers/json_loader.rb
spout-0.12.0 lib/spout/helpers/json_loader.rb
spout-0.12.0.rc2 lib/spout/helpers/json_loader.rb
spout-0.12.0.rc lib/spout/helpers/json_loader.rb
spout-0.12.0.beta2 lib/spout/helpers/json_loader.rb
spout-0.12.0.beta1 lib/spout/helpers/json_loader.rb
spout-0.11.1 lib/spout/helpers/json_loader.rb