Sha256: d6455f266afbfacc21a3d0d6eb01124c86061975366761d88c0537f9cf699981
Contents?: true
Size: 1.1 KB
Versions: 10
Compression:
Stored size: 1.1 KB
Contents
require 'pathname' module SitemapGenerator class Application def is_rails? !!defined?(Rails::VERSION) end # Returns a boolean indicating whether this environment is Rails 3 # # @return [Boolean] def is_at_least_rails3? is_rails? && Rails.version.to_f >= 3 rescue false # Rails.version defined in 2.1.0 end def root Pathname.new(rails_root || Dir.getwd) end protected # Returns the root of the Rails application, # if this is running in a Rails context. # Returns `nil` if no such root is defined. # # @return [String, nil] def rails_root return ::Rails.root.to_s if defined?(::Rails.root) && ::Rails.root return RAILS_ROOT.to_s if defined?(RAILS_ROOT) nil end # Returns the environment of the Rails application, # if this is running in a Rails context. # Returns `nil` if no such environment is defined. # # @return [String, nil] def rails_env return ::Rails.env.to_s if defined?(::Rails.env) return RAILS_ENV.to_s if defined?(RAILS_ENV) nil end end end
Version data entries
10 entries across 10 versions & 2 rubygems