Finish Rails-ifying the tree. Adds missing files and directories and
brings a few miscellaneous files up to date.
This commit is contained in:
parent
503aa99c63
commit
50343b79e8
15 changed files with 2776 additions and 338 deletions
19
script/benchmarker
Executable file
19
script/benchmarker
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/ruby1.8
|
||||
|
||||
if ARGV.empty?
|
||||
puts "Usage: benchmarker times 'Person.expensive_way' 'Person.another_expensive_way' ..."
|
||||
exit
|
||||
end
|
||||
|
||||
require File.dirname(__FILE__) + '/../config/environment'
|
||||
require 'benchmark'
|
||||
include Benchmark
|
||||
|
||||
# Don't include compilation in the benchmark
|
||||
ARGV[1..-1].each { |expression| eval(expression) }
|
||||
|
||||
bm(6) do |x|
|
||||
ARGV[1..-1].each_with_index do |expression, idx|
|
||||
x.report("##{idx + 1}") { ARGV[0].to_i.times { eval(expression) } }
|
||||
end
|
||||
end
|
7
script/destroy
Executable file
7
script/destroy
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/ruby1.8
|
||||
require File.dirname(__FILE__) + '/../config/environment'
|
||||
require 'rails_generator'
|
||||
require 'rails_generator/scripts/destroy'
|
||||
|
||||
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
||||
Rails::Generator::Scripts::Destroy.new.run(ARGV)
|
7
script/generate
Executable file
7
script/generate
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/ruby1.8
|
||||
require File.dirname(__FILE__) + '/../config/environment'
|
||||
require 'rails_generator'
|
||||
require 'rails_generator/scripts/generate'
|
||||
|
||||
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
||||
Rails::Generator::Scripts::Generate.new.run(ARGV)
|
34
script/profiler
Executable file
34
script/profiler
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/ruby1.8
|
||||
if ARGV.empty?
|
||||
$stderr.puts "Usage: profiler 'Person.expensive_method(10)' [times]"
|
||||
exit(1)
|
||||
end
|
||||
|
||||
# Keep the expensive require out of the profile.
|
||||
$stderr.puts 'Loading Rails...'
|
||||
require File.dirname(__FILE__) + '/../config/environment'
|
||||
|
||||
# Define a method to profile.
|
||||
if ARGV[1] and ARGV[1].to_i > 1
|
||||
eval "def profile_me() #{ARGV[1]}.times { #{ARGV[0]} } end"
|
||||
else
|
||||
eval "def profile_me() #{ARGV[0]} end"
|
||||
end
|
||||
|
||||
# Use the ruby-prof extension if available. Fall back to stdlib profiler.
|
||||
begin
|
||||
require 'prof'
|
||||
$stderr.puts 'Using the ruby-prof extension.'
|
||||
Prof.clock_mode = Prof::GETTIMEOFDAY
|
||||
Prof.start
|
||||
profile_me
|
||||
results = Prof.stop
|
||||
require 'rubyprof_ext'
|
||||
Prof.print_profile(results, $stderr)
|
||||
rescue LoadError
|
||||
$stderr.puts 'Using the standard Ruby profiler.'
|
||||
Profiler__.start_profile
|
||||
profile_me
|
||||
Profiler__.stop_profile
|
||||
Profiler__.print_profile($stderr)
|
||||
end
|
29
script/runner
Executable file
29
script/runner
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/ruby1.8
|
||||
require 'optparse'
|
||||
|
||||
options = { :environment => "development" }
|
||||
|
||||
ARGV.options do |opts|
|
||||
script_name = File.basename($0)
|
||||
opts.banner = "Usage: runner 'puts Person.find(1).name' [options]"
|
||||
|
||||
opts.separator ""
|
||||
|
||||
opts.on("-e", "--environment=name", String,
|
||||
"Specifies the environment for the runner to operate under (test/development/production).",
|
||||
"Default: development") { |options[:environment]| }
|
||||
|
||||
opts.separator ""
|
||||
|
||||
opts.on("-h", "--help",
|
||||
"Show this help message.") { puts opts; exit }
|
||||
|
||||
opts.parse!
|
||||
end
|
||||
|
||||
ENV["RAILS_ENV"] = options[:environment]
|
||||
|
||||
#!/usr/local/bin/ruby
|
||||
|
||||
require File.dirname(__FILE__) + '/../config/environment'
|
||||
eval(ARGV.first)
|
Loading…
Add table
Add a link
Reference in a new issue