# In you Gemfile
gem("hash_with_struct_access_yaml_loader", :git => "git://gist.github.com/1893175.git")
# In your code
HashWithStructAccess.load_yaml_file("load_me.yml")
Created
February 23, 2012 14:56
-
-
Save kostia/1893175 to your computer and use it in GitHub Desktop.
Plugin for HashWithStructAccess for loading YAML from string and from files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gem::Specification.new do |s| | |
s.name = "hash_with_struct_access_yaml_loader" | |
s.version = "0.0.1" | |
s.platform = Gem::Platform::RUBY | |
s.require_path = "." | |
s.files = %w(hash_with_struct_access_yaml_loader.rb) | |
s.add_dependency("hash_with_struct_access", "0.0.2") | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "yaml" | |
require "hash_with_struct_access" | |
class HashWithStructAccessYamlLoader | |
module Plugin | |
def load_yaml(string) | |
new(YAML.load(string)) | |
end | |
def load_yaml_file(path) | |
load_yaml(File.read(path)) | |
end | |
end | |
HashWithStructAccess.extend(HashWithStructAccessYamlLoader::Plugin) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment