Skip to content

Commit

Permalink
Project templating system
Browse files Browse the repository at this point in the history
  • Loading branch information
avh4 committed Oct 21, 2011
0 parents commit 642baaa
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
36 changes: 36 additions & 0 deletions init.rb
@@ -0,0 +1,36 @@
#!/usr/bin/env ruby
require 'liquid'
require 'yaml'

# Open the properties file
properties_file = File.open "properties.yaml"
properties_yaml = properties_file.read
puts properties_yaml
puts
# Ask the user if the properties are correct
puts "Are these properties correct?"
reply = gets
if reply[0] != "y" then
puts "Aborting. Edit properties.yaml to make changes."
exit
end

# Load the properties
properties = YAML::load(properties_yaml)

# process the files
files = [ "pom.xml" ]
files.each do |file|
puts "Processing #{file}..."
# read the file
template = File.open(file, "r").read
# process the file
rendering = Liquid::Template.parse(template).render properties
# write the file
File.open(file, "w").write(rendering)
end

puts "Successful. Removing init.rb..."
File.delete "init.rb"

puts "Done!"
3 changes: 3 additions & 0 deletions properties.yaml
@@ -0,0 +1,3 @@
---
project : my-project
description : ~

0 comments on commit 642baaa

Please sign in to comment.