Sha256: 050b293307833d25c9d83abb3fb2b9a02b211bb2d639358fe7b632524fea6efa

Contents?: true

Size: 440 Bytes

Versions: 3

Compression:

Stored size: 440 Bytes

Contents

module Stylish
  module Util
    def self.deserialize(path, format=nil)
      path = path.to_pathname

      contents = path.read

      if format.nil?
        format = "yml" if path.extname.downcase == ".yml"
        format = "json" if path.extname.downcase == ".json"
      end

      if format == "json"
        JSON.parse(contents)
      elsif format == "yaml" || format == "yml"
        YAML.load(contents)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
stylish-0.3.1 lib/stylish/util.rb
stylish-0.3.0 lib/stylish/util.rb
stylish-0.0.2 lib/stylish/util.rb