Created
April 29, 2014 20:17
-
-
Save milesmatthias/9b3b73e287a63d310f71 to your computer and use it in GitHub Desktop.
part of a rake task to create an index and thank you page from given title and primary color
This file contains hidden or 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
desc "given a name and primary color, build static index and thank you pages, returning directory path of files" | |
task :build, :site_id, :name, :primary_color do |t, args| | |
dirname = DateTime.now.to_s | |
dirname += '_' + args[:site_id] if args[:site_id].length > 0 | |
dirpath = Rails.root.join("tmp/static_builds", dirname) | |
system("mkdir -p #{ dirpath.to_path }") | |
system("cp -r #{ Rails.root }/static/* #{ dirpath.to_path }") | |
puts("name = #{ args[:name] }") | |
puts("primary_color = #{ args[:primary_color] }") | |
puts("dirpath = #{ dirpath }") | |
Dir.glob(dirpath.to_path + "/*").each do |fn| | |
IO.write(fn, File.open(fn){|f| | |
f.read | |
.gsub('__MVP__NAME__', args[:name]) | |
.gsub('__MVP__PRIMARY_COLOR__', args[:primary_color]) | |
}) | |
end | |
dirpath.to_path | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is from manualviableproduct.com.