Created
October 24, 2013 02:01
-
-
Save flaccid/7130089 to your computer and use it in GitHub Desktop.
lightweight ruby class to parse Cheffiles
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 'net/http' | |
require 'uri' | |
class LibrarianChefDSLParser | |
attr_accessor :site, :cookbooks | |
def initialize(cheffile, &data) | |
@cheffile = cheffile | |
@cookbooks = [] | |
data = false | |
uri = URI.parse(cheffile) | |
if %w( http https ).include?(uri.scheme) | |
data = Net::HTTP.get(uri) | |
else | |
data = File.read(cheffile) | |
end | |
instance_eval data | |
end | |
def cheffile | |
@cheffile | |
end | |
def site(*val) | |
@site = val | |
end | |
def cookbook(name, options) | |
cookbook = { "name" => name, "options" => options } | |
@cookbooks.push(cookbook) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment