Created
February 6, 2010 23:47
-
-
Save snusnu/297059 to your computer and use it in GitHub Desktop.
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
# ----------------------------------------------------------------------------- | |
# thor actions | |
# ----------------------------------------------------------------------------- | |
# Copies recursively the files from source directory to root directory. | |
# If any of the files finishes with .tt, it's considered to be a template | |
# and is placed in the destination without the extension .tt. If any | |
# empty directory is found, it's copied and all .empty_directory files are | |
# ignored. Remember that file paths can also be encoded, let's suppose a doc | |
# directory with the following files: | |
# | |
# directory "doc" | |
# directory "doc", "docs", :recursive => false | |
# | |
directory(source, destination=nil, config={}, &block) | |
# empty_directory "doc" | |
# | |
empty_directory(destination, config={}) | |
# create_file "lib/fun_party.rb" do | |
# hostname = ask("What is the virtual hostname I should use?") | |
# "vhost.name = #{hostname}" | |
# end | |
# | |
# create_file "config/apach.conf", "your apache config" | |
# | |
create_file(destination, data=nil, config={}, &block) | |
alias :add_file :create_file | |
# copy_file "README", "doc/README" | |
# | |
# copy_file "doc/README" | |
# | |
copy_file(source, destination=nil, config={}, &block) | |
# get "http://gist.github.com/103208", "doc/README" | |
# | |
# get "http://gist.github.com/103208" do |content| | |
# content.split("\n").first | |
# end | |
# | |
get(source, destination=nil, config={}, &block) | |
# template "README", "doc/README" | |
# | |
# template "doc/README" | |
# | |
template(source, destination=nil, config={}, &block) | |
# chmod "script/*", 0755 | |
# | |
chmod(path, mode, config={}) | |
# prepend_file 'config/environments/test.rb', 'config.gem "rspec"' | |
# | |
# prepend_file 'config/environments/test.rb' do | |
# 'config.gem "rspec"' | |
# end | |
# | |
prepend_file(path, *args, &block) | |
# append_file 'config/environments/test.rb', 'config.gem "rspec"' | |
# | |
# append_file 'config/environments/test.rb' do | |
# 'config.gem "rspec"' | |
# end | |
# | |
append_file(path, *args, &block) | |
# inject_into_class "app/controllers/application_controller.rb", " filter_parameter :password\n" | |
# | |
# inject_into_class "app/controllers/application_controller.rb", ApplicationController do | |
# " filter_parameter :password\n" | |
# end | |
# | |
inject_into_class(path, klass, *args, &block) | |
# gsub_file 'app/controllers/application_controller.rb', /#\s*(filter_parameter_logging :password)/, '\1' | |
# | |
# gsub_file 'README', /rake/, :green do |match| | |
# match << " no more. Use thor!" | |
# end | |
# | |
gsub_file(path, flag, *args, &block) | |
# remove_file 'README' | |
# remove_file 'app/controllers/application_controller.rb' | |
# | |
remove_file(path, config={}) | |
# ----------------------------------------------------------------------------- | |
# rails actions | |
# ----------------------------------------------------------------------------- | |
# plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git' | |
# plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :branch => 'stable' | |
# plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git', :submodule => true | |
# plugin 'restful-authentication', :svn => 'svn://svnhub.com/technoweenie/restful-authentication/trunk' | |
# plugin 'restful-authentication', :svn => 'svn://svnhub.com/technoweenie/restful-authentication/trunk', :revision => 1234 | |
# | |
plugin(name, options) | |
# gem "rspec", :env => :test | |
# gem "technoweenie-restful-authentication", :lib => "restful-authentication", :source => "http://gems.github.com/" | |
# gem "rails", "3.0", :git => "git://github.com/rails/rails" | |
# | |
gem(*args) | |
# source "http://gems.github.com/" | |
# | |
add_source(source, options={}) | |
# Adds a line inside the Initializer block for config/environment.rb. | |
# | |
# If options :env is specified, the line is appended to the corresponding | |
# file in config/environments. | |
# | |
environment(data=nil, options={}, &block) | |
# Run a command in git. | |
# | |
# ==== Examples | |
# | |
# git :init | |
# git :add => "this.file that.rb" | |
# git :add => "onefile.rb", :rm => "badfile.cxx" | |
# | |
git(command={}) | |
# vendor("sekrit.rb") do | |
# sekrit_salt = "#{Time.now}--#{3.years.ago}--#{rand}--" | |
# "salt = '#{sekrit_salt}'" | |
# end | |
# | |
# vendor("foreign.rb", "# Foreign code is fun") | |
# | |
vendor(filename, data=nil, &block) | |
# lib("crypto.rb") do | |
# "crypted_special_value = '#{rand}--#{Time.now}--#{rand(1337)}--'" | |
# end | |
# | |
# lib("foreign.rb", "# Foreign code is fun") | |
# | |
lib(filename, data=nil, &block) | |
# Create a new Rakefile with the provided code (either in a block or a string). | |
# | |
# ==== Examples | |
# | |
# rakefile("bootstrap.rake") do | |
# project = ask("What is the UNIX name of your project?") | |
# | |
# <<-TASK | |
# namespace :#{project} do | |
# task :bootstrap do | |
# puts "i like boots!" | |
# end | |
# end | |
# TASK | |
# end | |
# | |
# rakefile("seed.rake", "puts 'im plantin ur seedz'") | |
# | |
rakefile(filename, data=nil, &block) | |
# Create a new initializer with the provided code (either in a block or a string). | |
# | |
# ==== Examples | |
# | |
# initializer("globals.rb") do | |
# data = "" | |
# | |
# ['MY_WORK', 'ADMINS', 'BEST_COMPANY_EVAR'].each do | |
# data << "#{const} = :entp" | |
# end | |
# | |
# data | |
# end | |
# | |
# initializer("api.rb", "API_KEY = '123456'") | |
# | |
initializer(filename, data=nil, &block) | |
# Generate something using a generator from Rails or a plugin. | |
# The second parameter is the argument string that is passed to | |
# the generator or an Array that is joined. | |
# | |
# ==== Example | |
# | |
# generate(:authenticated, "user session") | |
# | |
generate(what, *args) | |
# Runs the supplied rake task | |
# | |
# ==== Example | |
# | |
# rake("db:migrate") | |
# rake("db:migrate", :env => "production") | |
# rake("gems:install", :sudo => true) | |
# | |
rake(command, options={}) | |
# Just run the capify command in root | |
# | |
# ==== Example | |
# | |
# capify! | |
# | |
capify! | |
# Make an entry in Rails routing file conifg/routes.rb | |
# | |
# === Example | |
# | |
# route "root :to => 'welcome'" | |
# | |
route(routing_code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment