X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=vendor%2Frails%2Frailties%2Fbuiltin%2Frails_info%2Frails%2Finfo.rb;fp=vendor%2Frails%2Frailties%2Fbuiltin%2Frails_info%2Frails%2Finfo.rb;h=4cbd2cca4a3d82bc92eb8c4ecd7d5989b7169259;hb=d115f2e23823271635bad69229a42cd8ac68debe;hp=0000000000000000000000000000000000000000;hpb=37cb670bf3ddde90b214e591f100ed4446469484;p=depot.git diff --git a/vendor/rails/railties/builtin/rails_info/rails/info.rb b/vendor/rails/railties/builtin/rails_info/rails/info.rb new file mode 100644 index 0000000..4cbd2cc --- /dev/null +++ b/vendor/rails/railties/builtin/rails_info/rails/info.rb @@ -0,0 +1,125 @@ +module Rails + module Info + mattr_accessor :properties + class << (@@properties = []) + def names + map &:first + end + + def value_for(property_name) + if property = assoc(property_name) + property.last + end + end + end + + class << self #:nodoc: + def property(name, value = nil) + value ||= yield + properties << [name, value] if value + rescue Exception + end + + def components + %w( active_record action_pack active_resource action_mailer active_support ) + end + + def component_version(component) + require "#{component}/version" + "#{component.classify}::VERSION::STRING".constantize + end + + def edge_rails_revision(info = git_info) + info[/commit ([a-z0-9-]+)/, 1] || freeze_edge_version + end + + def freeze_edge_version + if File.exist?(rails_vendor_root) + begin + Dir[File.join(rails_vendor_root, 'REVISION_*')].first.scan(/_(\d+)$/).first.first + rescue + Dir[File.join(rails_vendor_root, 'TAG_*')].first.scan(/_(.+)$/).first.first rescue 'unknown' + end + end + 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 + + def to_html + returning table = '
#{CGI.escapeHTML(name.to_s)} | ) + table << %(#{CGI.escapeHTML(value.to_s)} |