mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Added script/about to display formatted Rails::Info output
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2883 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
1f6b09f67c
commit
71b032a0a6
7 changed files with 36 additions and 13 deletions
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Added script/about to display formatted Rails::Info output [Sam Stephenson]
|
||||
|
||||
* Added Rails::Info to catalog assorted information about a Rails application's environment [Sam Stephenson]
|
||||
|
||||
* Tail the logfile when running script/lighttpd in the foreground [Sam Stephenson]
|
||||
|
|
|
@ -37,7 +37,7 @@ LOG_FILES = %w( server.log development.log test.log production.log )
|
|||
HTML_FILES = %w( 404.html 500.html index.html robots.txt favicon.ico
|
||||
javascripts/prototype.js
|
||||
javascripts/effects.js javascripts/dragdrop.js javascripts/controls.js )
|
||||
BIN_FILES = %w( breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/spinner runner server lighttpd plugin )
|
||||
BIN_FILES = %w( about breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/spinner runner server lighttpd plugin )
|
||||
|
||||
VENDOR_LIBS = %w( actionpack activerecord actionmailer activesupport actionwebservice railties )
|
||||
|
||||
|
|
3
railties/bin/about
Normal file
3
railties/bin/about
Normal file
|
@ -0,0 +1,3 @@
|
|||
#!/usr/local/bin/ruby
|
||||
require File.dirname(__FILE__) + '/../config/boot'
|
||||
require 'commands/about'
|
2
railties/lib/commands/about.rb
Normal file
2
railties/lib/commands/about.rb
Normal file
|
@ -0,0 +1,2 @@
|
|||
require 'environment'
|
||||
puts Rails::Info
|
|
@ -1,7 +1,15 @@
|
|||
module Rails
|
||||
module Info
|
||||
mattr_accessor :properties
|
||||
@@properties = []
|
||||
class << (@@properties = [])
|
||||
def names
|
||||
map {|(name, )| name}
|
||||
end
|
||||
|
||||
def value_for(property_name)
|
||||
find {|(name, )| name == property_name}.last rescue nil
|
||||
end
|
||||
end
|
||||
|
||||
class << self #:nodoc:
|
||||
def property(name, value = nil)
|
||||
|
@ -19,10 +27,19 @@ module Rails
|
|||
require "#{component}/version"
|
||||
"#{component.classify}::Version::STRING".constantize
|
||||
end
|
||||
|
||||
|
||||
def edge_rails_revision
|
||||
svn_info[/^Revision: (\d+)/, 1] || 'unknown'
|
||||
end
|
||||
|
||||
def to_s
|
||||
column_width = properties.names.map {|name| name.length}.max
|
||||
["About your application's environment", *properties.map do |property|
|
||||
"%-#{column_width}s %s" % property
|
||||
end] * "\n"
|
||||
end
|
||||
|
||||
alias inspect to_s
|
||||
|
||||
protected
|
||||
def svn_info
|
||||
|
@ -53,6 +70,9 @@ module Rails
|
|||
edge_rails_revision
|
||||
end
|
||||
|
||||
# The application's location on the filesystem.
|
||||
property 'Application root', File.expand_path(RAILS_ROOT)
|
||||
|
||||
# The current Rails environment (development, test, or production).
|
||||
property 'Environment' do
|
||||
RAILS_ENV
|
||||
|
|
|
@ -49,7 +49,7 @@ class AppGenerator < Rails::Generator::Base
|
|||
m.file "environments/test.rb", "config/environments/test.rb"
|
||||
|
||||
# Scripts
|
||||
%w( breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/spinner runner server lighttpd plugin ).each do |file|
|
||||
%w( about breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/spinner runner server lighttpd plugin ).each do |file|
|
||||
m.file "bin/#{file}", "script/#{file}", script_options
|
||||
end
|
||||
|
||||
|
|
|
@ -57,21 +57,17 @@ class InfoTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
protected
|
||||
def property_names
|
||||
Rails::Info.properties.map {|(name, )| name}
|
||||
def properties
|
||||
Rails::Info.properties
|
||||
end
|
||||
|
||||
def property_value(property_name)
|
||||
Rails::Info.properties.find {|(name, )| property_name == name}.last
|
||||
end
|
||||
|
||||
|
||||
def property_defined?(property_name)
|
||||
property_names.include? property_name
|
||||
properties.names.include? property_name
|
||||
end
|
||||
|
||||
def assert_property(property_name, value)
|
||||
raise "Property #{property_name.inspect} not defined" unless
|
||||
property_defined? property_name
|
||||
assert_equal value, property_value(property_name)
|
||||
assert_equal value, properties.value_for(property_name)
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue