Sha256: c53d319138886851b889126beb2689c4ab7eb2f44f76b17e9a715b4b0665bf71

Contents?: true

Size: 431 Bytes

Versions: 32

Compression:

Stored size: 431 Bytes

Contents

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

32 entries across 32 versions & 1 rubygems

Version Path
spout-0.11.0 lib/spout/helpers/json_loader.rb
spout-0.11.0.rc lib/spout/helpers/json_loader.rb
spout-0.11.0.beta3 lib/spout/helpers/json_loader.rb
spout-0.11.0.beta2 lib/spout/helpers/json_loader.rb
spout-0.11.0.beta1 lib/spout/helpers/json_loader.rb
spout-0.10.2 lib/spout/helpers/json_loader.rb
spout-0.10.1 lib/spout/helpers/json_loader.rb
spout-0.10.0 lib/spout/helpers/json_loader.rb
spout-0.10.0.rc3 lib/spout/helpers/json_loader.rb
spout-0.10.0.rc2 lib/spout/helpers/json_loader.rb
spout-0.10.0.rc lib/spout/helpers/json_loader.rb
spout-0.10.0.beta10 lib/spout/helpers/json_loader.rb
spout-0.10.0.beta9 lib/spout/helpers/json_loader.rb
spout-0.10.0.beta8 lib/spout/helpers/json_loader.rb
spout-0.10.0.beta7 lib/spout/helpers/json_loader.rb
spout-0.10.0.beta6 lib/spout/helpers/json_loader.rb
spout-0.10.0.beta4 lib/spout/helpers/json_loader.rb
spout-0.10.0.beta3 lib/spout/helpers/json_loader.rb
spout-0.10.0.beta2 lib/spout/helpers/json_loader.rb
spout-0.10.0.beta1 lib/spout/helpers/json_loader.rb