Class: Spout::Helpers::JsonLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/spout/helpers/json_loader.rb

Class Method Summary collapse

Class Method Details

.get_json(file_name, file_type) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/spout/helpers/json_loader.rb', line 8

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.parse(File.read(file, encoding: "utf-8"))
rescue => e
  puts "JsonLoader Warning".red
  puts e.to_s.white
  nil
end

.get_variable(variable_name) ⇒ Object



17
18
19
# File 'lib/spout/helpers/json_loader.rb', line 17

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