From 71b032a0a6a4f68354db7cb41e77443aa091580b Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Sat, 5 Nov 2005 14:30:47 +0000 Subject: 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 --- railties/lib/info.rb | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'railties/lib/info.rb') diff --git a/railties/lib/info.rb b/railties/lib/info.rb index 74cb41e8bc..2104f4d6e6 100644 --- a/railties/lib/info.rb +++ b/railties/lib/info.rb @@ -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 -- cgit v1.2.3