Module: Lookbook::PathUtils
- Defined in:
- lib/lookbook/support/utils/path_utils.rb
Class Method Summary collapse
- .normalize_all(paths, allow_root: false) ⇒ Object
- .root_path?(path) ⇒ Boolean
- .to_absolute(path) ⇒ Object
Class Method Details
.normalize_all(paths, allow_root: false) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/lookbook/support/utils/path_utils.rb', line 8 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 |
.root_path?(path) ⇒ Boolean
17 18 19 |
# File 'lib/lookbook/support/utils/path_utils.rb', line 17 def root_path?(path) Rails.application.root.to_s == path.to_s end |
.to_absolute(path) ⇒ Object
4 5 6 |
# File 'lib/lookbook/support/utils/path_utils.rb', line 4 def to_absolute(path) File.absolute_path(path.to_s, Rails.root) end |