Download:
Download(11.2 MB, 8:54)
Alternativer Download für iPod & Apple TV(11 MB, 8:54)
Resourcen:
Quellcode:
[bash]
thor help
thor list
thor setup:config
thor setup:config –force
thor setup:config private.yml –force
thor install lib/tasks/setup.thor
thor setup:populate
thor setup:populate –count 5
[/bash]
[ruby]
class Setup < Thor
desc "config [NAME]", "copy configuration files"
method_options :force => :boolean
def config(name = "*")
Dir["config/examples/#{name}"].each do |source|
destination = "config/#{File.basename(source)}"
FileUtils.rm(destination) if options[:force] && File.exist?(destination)
if File.exist?(destination)
puts "Skipping #{destination} because it already exists"
else
puts "Generating #{destination}"
FileUtils.cp(source, destination)
end
end
end
desc "populate", "generate records"
method_options :count => 10
def populate
require File.expand_path(‚config/environment.rb‘)
options[:count].times do |num|
puts "Generating article #{num}"
Article.create!(:name => "Article #{num}")
end
end
end
[/ruby]
It’s really a nice and helpful piece of information. I’m glad that you shared this helpful info with us. Please keep us informed like this. Thanks for sharing.