Sha256: b96278f4ebc9d51fc44a9f20c4040c2d08ee6ab26ff902d40f291711427960f4
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
require 'yamlr/version' require 'yamlr/reader' require 'yamlr/writer' require 'yamlr/indicators' require 'yamlr/defaults' module Yamlr DOTFILE = "#{ENV['HOME']}/.yamlr" # File to Hash or Array # def self.read(input, options = {}) Yamlr::Reader.read(input, self.options(options)) end # Hash or Array to .yml Array # def self.parse(object, options = {}) Yamlr::Writer.build(object, self.options(options)) end # Hash or Array to .yml file, e.g. filename.yml # def self.write(object, filename, options = {}) Yamlr::Writer.write(object, filename, self.options(options)) end # writes a .yamlr file HOME, merges with options if :dot is true # def self.dotfile(home = ENV['HOME']) Yamlr::Writer.dotfile(Yamlr::Defaults.options, home) end private # options # def self.options(options = {}) opt = Yamlr::Defaults.options.merge(Yamlr::Indicators.options.merge(options)) dot_opt = File.exists?(DOTFILE) ? Yamlr::Reader.read(DOTFILE, opt.merge({:symbolize_keys => true})) : nil unless opt[:dot] opt = opt.merge(dot_opt) if (dot_opt && dot_opt[:dot]) end opt end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yamlr-2.0.0 | lib/yamlr.rb |