photein 0.1.2 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 808d8afeddb75b1ec710f2335b5e1f51d9d6ffec91b1cb5a2cd2c1d8950486ca
4
- data.tar.gz: b45b43586500db69c52fcc2a046063b90e1e375dd4d5ef41a042eef0a2a5a984
3
+ metadata.gz: 4a6e9370cd73bb024486ffb10e0a2aa17dce4262d7602e6b978e4019aeb23f55
4
+ data.tar.gz: e523c18ea04dfa84afa666b9a928a0ea761e5aca98b5dbd8a634f4fe5edd72ae
5
5
  SHA512:
6
- metadata.gz: d9c2de4bf1b3e0433dbee191e44ef80c2d910a1416c02ccc0bd44fda3acc583282b2a07f2745a1c2345d39a83d055c270604858163b83c39ba7e8e519ae28c2b
7
- data.tar.gz: bde27862fbeb2b281cb23f8504bb16fe603ff59ed4401765128566b46e024a3afc66684f88ff07c4c0932de08f83fde35d7b5e3f03c1665c799e0733959cb60f
6
+ metadata.gz: 702e7a3f7c626ec9d57e2c41bd2ba04076b769c4aca27ae0be29d2807a738307cca34ed315eca62356a7991ac68e847994e096b0671c81587eef66d200623e16
7
+ data.tar.gz: b19a618fc185ceb0aa52399fe60c87d13437bcc2edc919738f002a2266fd9f4fd203d32aeabb4ebd475d291805c8f77ddd040cf9c1fd36524c2848b8cc420c60
data/lib/photein/image.rb CHANGED
@@ -85,8 +85,8 @@ module Photein
85
85
  Time.strptime(filename, 'IMG-%Y%m%d-WA%M%S')
86
86
  when /^IMG_\d{8}_\d{6}_\d{3}$/ # Telegram: datetime in milliseconds (at download)
87
87
  Time.strptime(filename, 'IMG_%Y%m%d_%H%M%S_%L')
88
- when /^signal-\d{4}-\d{2}-\d{2}-\d{6}( \(\d+\))?$/ # Signal: datetime + optional counter (at receipt)
89
- Time.strptime(filename[0, 24], 'signal-%F-%H%M%S')
88
+ when /^signal-\d{4}(-\d{2}){5}[-\d]*$/ # Signal: datetime + optional counter (at receipt)
89
+ Time.strptime(filename[0, 26], 'signal-%F-%H-%M-%S')
90
90
  when /^\d{13}$/ # LINE: UNIX time in milliseconds (at download)
91
91
  Time.strptime(filename[0..-4], '%s')
92
92
  else
@@ -54,7 +54,7 @@ module Photein
54
54
  FileUtils.chmod('-x', dest_path, noop: Photein::Config.dry_run)
55
55
  end
56
56
  end
57
- end.each(&:join)
57
+ end.compact.each(&:join)
58
58
 
59
59
  FileUtils.rm(path, noop: Photein::Config.dry_run || Photein::Config.keep)
60
60
  end
@@ -132,7 +132,7 @@ module Photein
132
132
  file = Pathname(file)
133
133
  raise Errno::ENOENT, "#{file}" unless file.exist?
134
134
 
135
- [Image, Video].find { |type| type::SUPPORTED_FORMATS.include?(file.extname) }
135
+ [Image, Video].find { |type| type::SUPPORTED_FORMATS.include?(file.extname.downcase) }
136
136
  .tap { |type| raise ArgumentError, "#{file}: Invalid media file" if type.nil? }
137
137
  .then { |type| type.new(file) }
138
138
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Photein
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.5'
5
5
  end
data/lib/photein.rb CHANGED
@@ -11,10 +11,13 @@ module Photein
11
11
  class << self
12
12
  def run
13
13
  [Photein::Image, Photein::Video].each do |media_type|
14
+ # Why not use Dir.glob? It refuses to do case-insensitive matching on Linux
15
+ ftype_regex = /(#{media_type::SUPPORTED_FORMATS.join('|').gsub('.', '\.')})$/i
16
+
14
17
  Pathname(Photein::Config.source)
15
- .join(Photein::Config.recursive ? '**' : '')
16
- .join("*{#{media_type::SUPPORTED_FORMATS.join(',')}}")
17
- .then { |glob| Dir.glob(glob, File::FNM_CASEFOLD).sort }
18
+ .join(Photein::Config.recursive ? '**' : '', '*')
19
+ .then(&Dir.method(:glob)).sort
20
+ .select { |file| file.match?(ftype_regex) }
18
21
  .map(&media_type.method(:new))
19
22
  .each(&:import)
20
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: photein
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Lue
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-10 00:00:00.000000000 Z
11
+ date: 2022-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mediainfo
@@ -144,7 +144,7 @@ licenses:
144
144
  - MIT
145
145
  metadata:
146
146
  source_code_uri: https://github.com/rlue/photein
147
- post_install_message:
147
+ post_install_message:
148
148
  rdoc_options: []
149
149
  require_paths:
150
150
  - lib
@@ -159,8 +159,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  requirements: []
162
- rubygems_version: 3.2.3
163
- signing_key:
162
+ rubygems_version: 3.3.7
163
+ signing_key:
164
164
  specification_version: 4
165
165
  summary: Import/rename photos & videos from one directory to another.
166
166
  test_files: []