Sha256: e6d52f019f4aa6ffcaa3e821a3d5dfa3b4df4b8050a5c62bc2a13f012ce78d7c

Contents?: true

Size: 490 Bytes

Versions: 6

Compression:

Stored size: 490 Bytes

Contents

# frozen_string_literal: true

require 'pathname'

module LokaliseRails
  # Util methods
  module Utils
    class << self
      # Current project root
      def root
        Pathname.new(rails_root || Dir.getwd)
      end

      # Tries to get Rails root if Rails is defined
      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
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lokalise_rails-7.0.0 lib/lokalise_rails/utils.rb
lokalise_rails-6.0.0 lib/lokalise_rails/utils.rb
lokalise_rails-5.2.0 lib/lokalise_rails/utils.rb
lokalise_rails-5.1.0 lib/lokalise_rails/utils.rb
lokalise_rails-5.0.1 lib/lokalise_rails/utils.rb
lokalise_rails-5.0.0 lib/lokalise_rails/utils.rb