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=a20d9bfe62947451e8b17296abea08fc3762b7e7;hb=437aa336c44c74a30aeea16a06743c32747ed661;hp=0000000000000000000000000000000000000000;hpb=97a0772b06264134cfe38e7494f9427efe0840a0;p=feedcatcher.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..a20d9bf --- /dev/null +++ b/vendor/rails/railties/builtin/rails_info/rails/info.rb @@ -0,0 +1,129 @@ +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 frameworks + %w( active_record action_pack active_resource action_mailer active_support ) + end + + def framework_version(framework) + require "#{framework}/version" + "#{framework.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)} |