Sha256: 3865a0dc2ce1d931f758184374c67b57c10f3cc223badc3a4bb5c8520346653b

Contents?: true

Size: 460 Bytes

Versions: 10

Compression:

Stored size: 460 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

10 entries across 10 versions & 1 rubygems

Version Path
spout-1.0.0.beta1 lib/spout/helpers/json_loader.rb
spout-0.14.1 lib/spout/helpers/json_loader.rb
spout-0.14.0 lib/spout/helpers/json_loader.rb
spout-0.14.0.rc lib/spout/helpers/json_loader.rb
spout-0.14.0.beta3 lib/spout/helpers/json_loader.rb
spout-0.14.0.beta2 lib/spout/helpers/json_loader.rb
spout-0.14.0.beta1 lib/spout/helpers/json_loader.rb
spout-0.13.0 lib/spout/helpers/json_loader.rb
spout-0.13.0.beta2 lib/spout/helpers/json_loader.rb
spout-0.13.0.beta1 lib/spout/helpers/json_loader.rb