Class: Sicily::Util::FileUtil
- Inherits:
-
Object
- Object
- Sicily::Util::FileUtil
- Defined in:
- lib/sicily/util/file_util.rb
Class Method Summary collapse
- .eval_dest_path(src_path, dest_path) ⇒ Object
- .extract_time(path) ⇒ Object
- .extract_time_from_file_stat(path) ⇒ Object
- .jpeg?(path) ⇒ Boolean
- .related?(maybe_parent_path, maybe_child_path) ⇒ Boolean
Class Method Details
.eval_dest_path(src_path, dest_path) ⇒ Object
16 17 18 19 |
# File 'lib/sicily/util/file_util.rb', line 16 def self.eval_dest_path(src_path, dest_path) time = extract_time(src_path) time.strftime(dest_path) end |
.extract_time(path) ⇒ Object
21 22 23 24 |
# File 'lib/sicily/util/file_util.rb', line 21 def self.extract_time(path) exif_time = jpeg?(path) && ExifUtil.extract_time_from_jpeg(path) exif_time || extract_time_from_file_stat(path) end |
.extract_time_from_file_stat(path) ⇒ Object
30 31 32 33 34 |
# File 'lib/sicily/util/file_util.rb', line 30 def self.extract_time_from_file_stat(path) File.birthtime(path) rescue NotImplementedError File.mtime(path) end |
.jpeg?(path) ⇒ Boolean
26 27 28 |
# File 'lib/sicily/util/file_util.rb', line 26 def self.jpeg?(path) %w[.jpg .jpeg].include? File.extname(path).downcase end |
.related?(maybe_parent_path, maybe_child_path) ⇒ Boolean
9 10 11 12 13 14 |
# File 'lib/sicily/util/file_util.rb', line 9 def self.(maybe_parent_path, maybe_child_path) = File.(maybe_parent_path) = File.(maybe_child_path) parent_path_expr = File.join(, '**') Pathname.new().fnmatch? parent_path_expr end |