Skip to content

Instantly share code, notes, and snippets.

@smith
Last active October 16, 2015 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smith/60233700a88b0ec3ee4a to your computer and use it in GitHub Desktop.
Save smith/60233700a88b0ec3ee4a to your computer and use it in GitHub Desktop.
Greenspun's tenth rule
# See https://github.com/coderanger/chef-dialects-testbed, https://github.com/chef/chef-rfc/blob/master/rfc036-dialects.md
require "edn"
require "json"
open("recipe.rb", "w") do |f|
EDN.read("(#{open('recipe.edn').read})").each do |resource|
type = resource.shift.to_s
name = resource.shift.to_s
properties = resource.shift || {}
f.write "#{type} '#{name}' do\n"
properties.each do |property, value|
f.write " #{property} #{value.to_json}\n"
end
f.write "\nend\n"
end
end
(file "hello.txt" {
:content "hello, world!"
})
(directory "hello")
file 'hello.txt' do
content "hello, world!"
end
directory 'hello' do
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment