Skip to content

Instantly share code, notes, and snippets.

@wbzyl
Created July 6, 2011 22:03
Show Gist options
  • Save wbzyl/1068461 to your computer and use it in GitHub Desktop.
Save wbzyl/1068461 to your computer and use it in GitHub Desktop.
An example of Rails template file.
remove_file 'README'
create_file "README.md" do
"# Fortunka\n\nTODO"
end
remove_file "public/index.html"
gem "simple_form"
generate "simple_form:install"
generate :scaffold, "fortune body:text"
rake "db:migrate"
route "resources :fortunes"
route "root :to => 'fortunes#index'"
gsub_file "app/views/layouts/application.html.erb", /<body/ do |match|
match << " class='fortunes'"
end
gsub_file "app/assets/stylesheets/fortunes.css.scss", /Then, place scoped styles here.\s*\n/ do |match|
match.concat <<CSS
width: 640px;
margin: 1em auto;
padding: 1em 1em 2em 1em;
border: 1px solid black;
font-size: 16px;
line-height: 22px;
CSS
end
append_to_file "app/assets/stylesheets/fortunes.css.scss" do
background_color = ask("What is your preferred CSS background color?")
<<CSS
html {
background-color: #{background_color};
}
CSS
end
git :init
git :add => "."
git :commit => "-a -m 'Pierwsza wrzutka'"
@wbzyl
Copy link
Author

wbzyl commented Jul 12, 2011

Useful stuff. Copied from a RailsWizard.org recipe.

def say_wizard(text); say "\033[36m" + "wizard".rjust(10) + "\033[0m" + " #{text}" end 
@after_blocks = []
def after_bundler(&block); @after_blocks << block; end
# rails template
say_wizard "Running after Bundler callbacks."
@after_blocks.each{|b| b.call}

RDoc:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment