lib/figly.rb in figly-1.0.0.beta.0 vs lib/figly.rb in figly-1.0.1

- old
+ new

@@ -1,13 +1,27 @@ require "figly/version" require "figly/settings" -module Figly - @@path = nil unless defined? @@path +module Figly def self.setup(path) - @@path = path + raise "File does not exist: #{path}" unless File.exists?(path) + ext = File.extname(path) + @@data = case ext + when '.toml' + require 'toml' + TOML.load_file(path) + when '.yml' + require 'yaml' + YAML.load_file(path) + when '.json' + require 'json' + JSON.parse(File.read(path)) + else + raise "Unsupported file extension (#{ext})" + end + @@data end - def self.path - @@path + def self.data + @@data end end