Sha256: 04548a6604c8b0ae2ff3a13790781152bf69d77b823fc06ae83c88ac163d7907

Contents?: true

Size: 518 Bytes

Versions: 4

Compression:

Stored size: 518 Bytes

Contents

module Lookbook
  module PathUtils
    class << self
      def to_absolute(path)
        File.absolute_path(path.to_s, Rails.root)
      end

      def normalize_all(paths, allow_root: false)
        Array(paths).map do |path|
          full_path = to_absolute(path)
          if Dir.exist?(full_path)
            full_path if allow_root || !root_path?(full_path)
          end
        end.compact.uniq
      end

      def root_path?(path)
        Rails.application.root.to_s == path.to_s
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lookbook-1.3.4 lib/lookbook/support/utils/path_utils.rb
lookbook-1.3.3 lib/lookbook/support/utils/path_utils.rb
lookbook-1.3.1 lib/lookbook/support/utils/path_utils.rb
lookbook-1.3.0 lib/lookbook/support/utils/path_utils.rb