public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
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
sstephenson (author)
Sat Nov 05 06:30:47 -0800 2005
commit  71b032a0a6a4f68354db7cb41e77443aa091580b
tree    acd7a0246f7919fa791d74224432ee98cf7968ad
parent  1f6b09f67c7d15e4db5960a09ad3b724a1e01d7f
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Added script/about to display formatted Rails::Info output [Sam Stephenson]
0
+
0
 * Added Rails::Info to catalog assorted information about a Rails application's environment [Sam Stephenson]
0
 
0
 * Tail the logfile when running script/lighttpd in the foreground [Sam Stephenson]
...
37
38
39
40
 
41
42
43
...
37
38
39
 
40
41
42
43
0
@@ -37,7 +37,7 @@ LOG_FILES = %w( server.log development.log test.log production.log )
0
 HTML_FILES = %w( 404.html 500.html index.html robots.txt favicon.ico
0
                    javascripts/prototype.js
0
                    javascripts/effects.js javascripts/dragdrop.js javascripts/controls.js )
0
-BIN_FILES = %w( breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/spinner runner server lighttpd plugin )
0
+BIN_FILES = %w( about breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/spinner runner server lighttpd plugin )
0
 
0
 VENDOR_LIBS = %w( actionpack activerecord actionmailer activesupport actionwebservice railties )
0
 
...
1
2
3
4
 
 
 
 
 
 
 
 
 
5
6
7
...
19
20
21
22
 
23
24
25
 
 
 
 
 
 
 
 
 
26
27
28
...
53
54
55
 
 
 
56
57
58
...
1
2
3
 
4
5
6
7
8
9
10
11
12
13
14
15
...
27
28
29
 
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
...
70
71
72
73
74
75
76
77
78
0
@@ -1,7 +1,15 @@
0
 module Rails
0
   module Info
0
     mattr_accessor :properties
0
- @@properties = []
0
+ class << (@@properties = [])
0
+ def names
0
+ map {|(name, )| name}
0
+ end
0
+
0
+ def value_for(property_name)
0
+ find {|(name, )| name == property_name}.last rescue nil
0
+ end
0
+ end
0
   
0
     class << self #:nodoc:
0
       def property(name, value = nil)
0
@@ -19,10 +27,19 @@ module Rails
0
         require "#{component}/version"
0
         "#{component.classify}::Version::STRING".constantize
0
       end
0
-
0
+
0
       def edge_rails_revision
0
         svn_info[/^Revision: (\d+)/, 1] || 'unknown'
0
       end
0
+
0
+ def to_s
0
+ column_width = properties.names.map {|name| name.length}.max
0
+ ["About your application's environment", *properties.map do |property|
0
+ "%-#{column_width}s %s" % property
0
+ end] * "\n"
0
+ end
0
+
0
+ alias inspect to_s
0
       
0
     protected
0
       def svn_info
0
@@ -53,6 +70,9 @@ module Rails
0
       edge_rails_revision
0
     end
0
   
0
+ # The application's location on the filesystem.
0
+ property 'Application root', File.expand_path(RAILS_ROOT)
0
+
0
     # The current Rails environment (development, test, or production).
0
     property 'Environment' do
0
       RAILS_ENV
...
49
50
51
52
 
53
54
55
...
49
50
51
 
52
53
54
55
0
@@ -49,7 +49,7 @@ class AppGenerator < Rails::Generator::Base
0
       m.file "environments/test.rb", "config/environments/test.rb"
0
 
0
       # Scripts
0
- %w( breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/spinner runner server lighttpd plugin ).each do |file|
0
+ %w( about breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/spinner runner server lighttpd plugin ).each do |file|
0
         m.file "bin/#{file}", "script/#{file}", script_options
0
       end
0
 
...
57
58
59
60
61
 
 
62
63
64
65
66
67
 
68
69
 
70
71
72
73
74
75
 
76
77
78
...
57
58
59
 
 
60
61
62
 
 
 
 
 
63
64
 
65
66
67
68
69
70
 
71
72
73
74
0
@@ -57,21 +57,17 @@ class InfoTest < Test::Unit::TestCase
0
   end
0
 
0
 protected
0
- def property_names
0
- Rails::Info.properties.map {|(name, )| name}
0
+ def properties
0
+ Rails::Info.properties
0
   end
0
-
0
- def property_value(property_name)
0
- Rails::Info.properties.find {|(name, )| property_name == name}.last
0
- end
0
-
0
+
0
   def property_defined?(property_name)
0
- property_names.include? property_name
0
+ properties.names.include? property_name
0
   end
0
   
0
   def assert_property(property_name, value)
0
     raise "Property #{property_name.inspect} not defined" unless
0
       property_defined? property_name
0
- assert_equal value, property_value(property_name)
0
+ assert_equal value, properties.value_for(property_name)
0
   end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.