lib/scss_beautifier/config.rb in scss_beautifier-0.1.18 vs lib/scss_beautifier/config.rb in scss_beautifier-0.1.19

- old
+ new

@@ -1,16 +1,18 @@ require "yaml" module SCSSBeautifier class Config + DEFAULT = File.realpath(File.join(File.dirname(__FILE__), "..", "..", "data", "default_config.yml")).freeze def initialize(config_location) - @config = parse_config(config_location) + @config = parse_config(config_location.to_s) end def parse_config(config_location) - YAML.load(File.read(config_location)) + config_contents = read_config(config_location) + YAML.load(config_contents) end def formatters enabled_formatters = [] @config["formatters"].each do |formatter, options| @@ -20,11 +22,22 @@ end end enabled_formatters end - def tab_style - @config["tab_style"] || " " + def options + options_with_key_symbols = {} + @config["options"].each do |k, v| + options_with_key_symbols[:"#{k}"] = v + end + options_with_key_symbols + end + + private + + def read_config(config_location) + location = File.exists?(config_location) ? config_location : DEFAULT + File.read(location) end end end