Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 117 lines (97 sloc) 3.076 kB
4fa8716 @wycats Get Railties passing again
wycats authored
1 require "cgi"
2
1f6b09f @sstephenson Added Rails::Info to catalog assorted information about a Rails appli…
sstephenson authored
3 module Rails
4 module Info
5 mattr_accessor :properties
71b032a @sstephenson Added script/about to display formatted Rails::Info output
sstephenson authored
6 class << (@@properties = [])
7 def names
4fa8716 @wycats Get Railties passing again
wycats authored
8 map {|val| val.first }
71b032a @sstephenson Added script/about to display formatted Rails::Info output
sstephenson authored
9 end
11a75f9 @jeremy Ruby 1.9 compat: Update idiosyncratic block variable usage. Closes #1…
jeremy authored
10
71b032a @sstephenson Added script/about to display formatted Rails::Info output
sstephenson authored
11 def value_for(property_name)
16c3ec7 @jeremy Simplify some rails info methods
jeremy authored
12 if property = assoc(property_name)
11a75f9 @jeremy Ruby 1.9 compat: Update idiosyncratic block variable usage. Closes #1…
jeremy authored
13 property.last
14 end
71b032a @sstephenson Added script/about to display formatted Rails::Info output
sstephenson authored
15 end
16 end
11a75f9 @jeremy Ruby 1.9 compat: Update idiosyncratic block variable usage. Closes #1…
jeremy authored
17
1f6b09f @sstephenson Added Rails::Info to catalog assorted information about a Rails appli…
sstephenson authored
18 class << self #:nodoc:
19 def property(name, value = nil)
20 value ||= yield
16c3ec7 @jeremy Simplify some rails info methods
jeremy authored
21 properties << [name, value] if value
1f6b09f @sstephenson Added Rails::Info to catalog assorted information about a Rails appli…
sstephenson authored
22 rescue Exception
23 end
24
a5870d4 @jeremy Rename Rails::Info.components to frameworks
jeremy authored
25 def frameworks
f1637bf @sikachu Remove Active Resource source files from the repository
sikachu authored
26 %w( active_record action_pack action_mailer active_support )
1f6b09f @sstephenson Added Rails::Info to catalog assorted information about a Rails appli…
sstephenson authored
27 end
16c3ec7 @jeremy Simplify some rails info methods
jeremy authored
28
a5870d4 @jeremy Rename Rails::Info.components to frameworks
jeremy authored
29 def framework_version(framework)
cc1efe7 @gbuesing Rails::Info doesn't require version for unwanted frameworks
gbuesing authored
30 if Object.const_defined?(framework.classify)
31 require "#{framework}/version"
f0e6ab5 @charliesome remove references to *::VERSION, replace with *.version
charliesome authored
32 framework.classify.constantize.version.to_s
cc1efe7 @gbuesing Rails::Info doesn't require version for unwanted frameworks
gbuesing authored
33 end
1f6b09f @sstephenson Added Rails::Info to catalog assorted information about a Rails appli…
sstephenson authored
34 end
16c3ec7 @jeremy Simplify some rails info methods
jeremy authored
35
71b032a @sstephenson Added script/about to display formatted Rails::Info output
sstephenson authored
36 def to_s
37 column_width = properties.names.map {|name| name.length}.max
391f254 @josevalim Properly show middlewares on rake about.
josevalim authored
38 info = properties.map do |name, value|
39 value = value.join(", ") if value.is_a?(Array)
40 "%-#{column_width}s %s" % [name, value]
41 end
42 info.unshift "About your application's environment"
43 info * "\n"
71b032a @sstephenson Added script/about to display formatted Rails::Info output
sstephenson authored
44 end
45
46 alias inspect to_s
16c3ec7 @jeremy Simplify some rails info methods
jeremy authored
47
b661c96 @sstephenson Added an omnipresent RailsInfoController with a properties action tha…
sstephenson authored
48 def to_html
02902e0 @amatsuda use tap with block parameter
amatsuda authored
49 '<table>'.tap do |table|
b661c96 @sstephenson Added an omnipresent RailsInfoController with a properties action tha…
sstephenson authored
50 properties.each do |(name, value)|
23fa039 @seckar Fix Rails info controller for postgres; Closes #4469.
seckar authored
51 table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>)
cad3e8b @mschuerig Show installed middleware in builtin rails info (/rails/info/properti…
mschuerig authored
52 formatted_value = if value.kind_of?(Array)
53 "<ul>" + value.map { |v| "<li>#{CGI.escapeHTML(v.to_s)}</li>" }.join + "</ul>"
54 else
55 CGI.escapeHTML(value.to_s)
56 end
57 table << %(<td class="value">#{formatted_value}</td></tr>)
b661c96 @sstephenson Added an omnipresent RailsInfoController with a properties action tha…
sstephenson authored
58 end
59 table << '</table>'
60 end
61 end
1f6b09f @sstephenson Added Rails::Info to catalog assorted information about a Rails appli…
sstephenson authored
62 end
63
64 # The Ruby version and platform, e.g. "1.8.2 (powerpc-darwin8.2.0)".
65 property 'Ruby version', "#{RUBY_VERSION} (#{RUBY_PLATFORM})"
66
67 # The RubyGems version, if it's installed.
68 property 'RubyGems version' do
69 Gem::RubyGemsVersion
70 end
16c3ec7 @jeremy Simplify some rails info methods
jeremy authored
71
1120563 @josh Add Rack version to Rails info
josh authored
72 property 'Rack version' do
73 ::Rack.release
74 end
75
55fab64 @sstephenson Move info.rb to rails_info.rb and load Rails::Info after initialization
sstephenson authored
76 # The Rails version.
77 property 'Rails version' do
f0e6ab5 @charliesome remove references to *::VERSION, replace with *.version
charliesome authored
78 Rails.version.to_s
55fab64 @sstephenson Move info.rb to rails_info.rb and load Rails::Info after initialization
sstephenson authored
79 end
16c3ec7 @jeremy Simplify some rails info methods
jeremy authored
80
f63f0ba @dhh Add JavaScript Runtime name to the Rails Info properties (thanks Sam …
dhh authored
81 property 'JavaScript Runtime' do
82 ExecJS.runtime.name
83 end
84
a5870d4 @jeremy Rename Rails::Info.components to frameworks
jeremy authored
85 # Versions of each Rails framework (Active Record, Action Pack,
f1637bf @sikachu Remove Active Resource source files from the repository
sikachu authored
86 # Action Mailer, and Active Support).
a5870d4 @jeremy Rename Rails::Info.components to frameworks
jeremy authored
87 frameworks.each do |framework|
88 property "#{framework.titlecase} version" do
89 framework_version(framework)
1f6b09f @sstephenson Added Rails::Info to catalog assorted information about a Rails appli…
sstephenson authored
90 end
91 end
16c3ec7 @jeremy Simplify some rails info methods
jeremy authored
92
cad3e8b @mschuerig Show installed middleware in builtin rails info (/rails/info/properti…
mschuerig authored
93 property 'Middleware' do
d283ca3 @dhh Fix deprecation message on info screen
dhh authored
94 Rails.configuration.middleware.map(&:inspect)
cad3e8b @mschuerig Show installed middleware in builtin rails info (/rails/info/properti…
mschuerig authored
95 end
96
71b032a @sstephenson Added script/about to display formatted Rails::Info output
sstephenson authored
97 # The application's location on the filesystem.
55fab64 @sstephenson Move info.rb to rails_info.rb and load Rails::Info after initialization
sstephenson authored
98 property 'Application root' do
2110a52 Deprecate RAILS_ROOT in favor of Rails.root (which proxies to the app…
Carl Lerche authored
99 File.expand_path(Rails.root)
55fab64 @sstephenson Move info.rb to rails_info.rb and load Rails::Info after initialization
sstephenson authored
100 end
101
1f6b09f @sstephenson Added Rails::Info to catalog assorted information about a Rails appli…
sstephenson authored
102 # The current Rails environment (development, test, or production).
103 property 'Environment' do
1a27573 @josevalim Set deprecation warnings for RAILS_ENV and RAILS_DEFAULT_LOGGER.
josevalim authored
104 Rails.env
1f6b09f @sstephenson Added Rails::Info to catalog assorted information about a Rails appli…
sstephenson authored
105 end
16c3ec7 @jeremy Simplify some rails info methods
jeremy authored
106
1f6b09f @sstephenson Added Rails::Info to catalog assorted information about a Rails appli…
sstephenson authored
107 # The name of the database adapter for the current environment.
108 property 'Database adapter' do
1a27573 @josevalim Set deprecation warnings for RAILS_ENV and RAILS_DEFAULT_LOGGER.
josevalim authored
109 ActiveRecord::Base.configurations[Rails.env]['adapter']
1f6b09f @sstephenson Added Rails::Info to catalog assorted information about a Rails appli…
sstephenson authored
110 end
2f9442c @dhh Added tracking of database and framework versions in script/about #40…
dhh authored
111
112 property 'Database schema version' do
113 ActiveRecord::Migrator.current_version rescue nil
114 end
1f6b09f @sstephenson Added Rails::Info to catalog assorted information about a Rails appli…
sstephenson authored
115 end
116 end
Something went wrong with that request. Please try again.