Blaml

DESCRIPTION:

Blaml is a parser based on Psych (ruby 1.9 only) for yaml files that have been blamed with a SCM. Blaml parses the blamed yaml file and makes the blame metadata available on the returned ruby object through a ‘meta’ attribute.

FEATURES:

  • Load blamed yaml files and access blame data as metadata.

  • Supports custom SCM blaming and parsing (see Blaml::GitBlamer).

USAGE:

Using the built in GitBlamer:

b = Blaml.load `git blame -f file.yml`

b = Blaml.blame_file "file.yml"

Using a custom SCM blamer class:

# Note: First define SvnBlamer with the same interface as GitBlamer

# Explicitely use a different blamer:
b = Blaml.blame_file "file.yml", SvnBlamer

# Always use a different blamer:
Blaml.default_blamer = SvnBlamer
b = Blaml.blame_file "file.yml"

Working with the blamed data:

b.meta
# => Returns metadata hash for most recent change in this data structure.

b.keys.first.meta
# => Returns metadata hash for when this key was changed.

b[:key]
# => "value"

b[:key].meta
# => {:updated_at => 2010-10-28 22:43:33 +0000, :author => 'user', :line => 12, :commit => '25kjpp43', :file => 'file.yml'}

b[:key].class
# => Blaml::MetaNode

b[:key] == "value"
# => true

b[:key].value.class
# => String

b.to_value
# => Returns the full original data structure (not wrapped in meta classes)
# => {:key => "value"}

INSTALL:

$ gem install blaml

This task will install any missing dependencies, run the tests/specs, and generate the RDoc.

LICENSE:

(The MIT License)

Copyright © 2011 Jeremie Castagna

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.