Module: LokaliseRails::Utils
- Defined in:
- lib/lokalise_rails/utils.rb
Overview
Utility methods for LokaliseRails
Class Method Summary collapse
-
.rails_root ⇒ String?
Determines the root directory of a Rails project.
-
.root ⇒ Pathname
Retrieves the root directory of the current project.
Class Method Details
.rails_root ⇒ String?
Determines the root directory of a Rails project.
-
Uses ‘Rails.root` if available.
-
Falls back to ‘RAILS_ROOT` for older Rails versions.
-
Returns ‘nil` if Rails is not present.
26 27 28 29 30 31 |
# File 'lib/lokalise_rails/utils.rb', line 26 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 |
.root ⇒ Pathname
Retrieves the root directory of the current project.
If Rails is available, it returns ‘Rails.root`. Otherwise, it defaults to the current working directory.
15 16 17 |
# File 'lib/lokalise_rails/utils.rb', line 15 def root Pathname.new(rails_root || Dir.getwd) end |