vera 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1e86fe32c2e677bcbb2698233d57b5c5007974d2ec987f533604f053c6f129db
4
+ data.tar.gz: 9fc1f1cc5d427a686eb67c5f43af0564a906776e6a26ced826e72403447e2c36
5
+ SHA512:
6
+ metadata.gz: 956eef3b90af82883d70184024507d6fe4262c9aaee24eac6eb4d2036a264a691b3c9d84da6a08bd53072965e5282531e55281f603fe3dc05b05406092169398
7
+ data.tar.gz: e1748beacb712484086ee161ac905b88f35ac8507c317e0384928e03de78a8fd8cf170ced48c9d29331833799e6f2ccd7ab9a1861f5e8dc834c2a82c0059c14a
data/1 ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in vera.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,59 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ vera (0.1.0)
5
+ commander
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ commander (4.5.2)
12
+ highline (~> 2.0.0)
13
+ diff-lcs (1.4.4)
14
+ highline (2.0.3)
15
+ parallel (1.20.1)
16
+ parser (3.0.0.0)
17
+ ast (~> 2.4.1)
18
+ rainbow (3.0.0)
19
+ rake (13.0.3)
20
+ regexp_parser (2.1.0)
21
+ rexml (3.2.4)
22
+ rspec (3.10.0)
23
+ rspec-core (~> 3.10.0)
24
+ rspec-expectations (~> 3.10.0)
25
+ rspec-mocks (~> 3.10.0)
26
+ rspec-core (3.10.1)
27
+ rspec-support (~> 3.10.0)
28
+ rspec-expectations (3.10.1)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.10.0)
31
+ rspec-mocks (3.10.2)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.10.0)
34
+ rspec-support (3.10.2)
35
+ rubocop (1.10.0)
36
+ parallel (~> 1.10)
37
+ parser (>= 3.0.0.0)
38
+ rainbow (>= 2.2.2, < 4.0)
39
+ regexp_parser (>= 1.8, < 3.0)
40
+ rexml
41
+ rubocop-ast (>= 1.2.0, < 2.0)
42
+ ruby-progressbar (~> 1.7)
43
+ unicode-display_width (>= 1.4.0, < 3.0)
44
+ rubocop-ast (1.4.1)
45
+ parser (>= 2.7.1.5)
46
+ ruby-progressbar (1.11.0)
47
+ unicode-display_width (2.0.0)
48
+
49
+ PLATFORMS
50
+ x86_64-darwin-19
51
+
52
+ DEPENDENCIES
53
+ rake (~> 13.0)
54
+ rspec (~> 3.0)
55
+ rubocop (~> 1.7)
56
+ vera!
57
+
58
+ BUNDLED WITH
59
+ 2.2.7
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 David Cortés
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ ![vera](vera.jpg)
2
+
3
+ Vera is a CLI tool to manage and organize your photos and video files. I created it to automatize my current workflow for editing photos and videos. If you want to automatize yours keep reading.
4
+
5
+ ## Installation
6
+
7
+ Vera requires `exiftool` to work. You can use this script to install all the dependencies and Vera all together.
8
+
9
+ ```bash
10
+ bash <(curl -Ls https://git.io/JtbuH)
11
+ ```
12
+
13
+ You can also install it manually before you install the gem:
14
+
15
+ ```bash
16
+ brew install exiftool
17
+ gem install vera
18
+ ```
19
+
20
+ Once you have it installed you can use any of the following commands.
21
+
22
+ ## Available Commands
23
+
24
+ ### Timestamp
25
+
26
+ This command fixes the created date and the modified date of the media files. Run the following command in the folder where you have your photos and videos:
27
+
28
+ ```bash
29
+ vera timestamp
30
+ ```
31
+
32
+ This command works on JPG, MOV, HEIC and ARW files.
33
+
34
+ If you want to add more commands, feel free to contribute with a PR to Vera. In the next section I explain how to start working on it.
35
+
36
+ ## Developement
37
+
38
+ After checking out the repo, run `install.sh` to install dependencies. Then, run `rake spec` to run the tests.
39
+
40
+ To install this gem onto your local machine, run `bundle exec rake install`.
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/davebcn87/vera.
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/vera ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+ #!/usr/bin/env ruby
3
+
4
+ require 'rubygems'
5
+ require 'commander/import'
6
+
7
+ require_relative '../lib/vera'
8
+
9
+ program :name, 'vera'
10
+ program :version, Vera::VERSION
11
+ program :description, 'Organize media files'
12
+
13
+ command :timestamp do |c|
14
+ c.syntax = 'vera rename, [options]'
15
+ c.summary = 'Fix the timestamp of current folder\'s media'
16
+ c.description = 'Uses picture/movie creation date to change the created and modified date of the media file'
17
+ c.example 'description', 'vera timestamp'
18
+ c.action do |_args, options|
19
+ Vera::Timestamp.execute(options)
20
+ end
21
+ end
data/install.sh ADDED
@@ -0,0 +1,31 @@
1
+ # RESULT=$(which exiftool)
2
+ # if [ "$RESULT" != "exiftool not found" ]; then
3
+ # echo "Dependencies already installed and work correctly."
4
+ # exit
5
+ # fi
6
+
7
+ VERSION=Image-ExifTool-12.19
8
+
9
+ echo "Downloading dependencies... exiftool"
10
+ curl -s https://exiftool.org/$VERSION.tar.gz --output /tmp/$VERSION.tar.gz >/dev/null
11
+
12
+ echo "Installing dependencies... exiftool"
13
+ tar -xzf /tmp/$VERSION.tar.gz -C /tmp >/dev/null
14
+ mv /tmp/$VERSION/lib /usr/local/bin
15
+ mv /tmp/$VERSION/exiftool /usr/local/bin/exiftool
16
+
17
+ echo "Cleaning up..."
18
+ rm /tmp/$VERSION.tar.gz
19
+ rm -rf /tmp/$VERSION
20
+
21
+ echo "Testing dependencies..."
22
+ RESULT=$(which exiftool)
23
+ if [ "$RESULT" != "exiftool not found" ]; then
24
+ echo "Dependencies installed correctly."
25
+ else
26
+ echo "Error installing dependencies. Please install exiftool manually."
27
+ exit 1
28
+ fi;
29
+
30
+ echo "Installing gem...vera"
31
+ gem install vera
data/lib/vera.rb ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'vera/lister'
4
+ require_relative 'vera/timestamp'
5
+ require_relative 'vera/version'
6
+ require_relative 'vera/exiftool'
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vera
4
+ class Exiftool
5
+ def self.change_timestamp(date_property, files_string)
6
+ `exiftool "-FileCreateDate<#{date_property}" "-FileModifyDate<#{date_property}" #{files_string} 2>/dev/null`
7
+ end
8
+
9
+ def self.is_installed?
10
+ !`which exiftool 2>1`.include?("not found")
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vera
4
+ class Lister
5
+ def self.all_files(path, ext)
6
+ Dir.entries(path)
7
+ .map { |file| { path: "#{path}/#{file}", filename: file } }
8
+ .select { |file| ext == File.extname(file[:filename]).gsub('.', '') }
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vera
4
+ class Timestamp
5
+ def self.execute(options)
6
+ unless Exiftool.is_installed?
7
+ puts """
8
+ You need to install exiftool to use vera. You can run the following command to do it:
9
+ bash <(curl -Ls https://git.io/JtbuH)
10
+ """
11
+ return
12
+ end
13
+ path = options.path
14
+ path = Dir.pwd if options.path.nil?
15
+ path = File.expand_path(path)
16
+ fix_timestamp_in path
17
+ end
18
+
19
+ def self.fix_timestamp_in(path)
20
+ rename_files_with_date path, 'ARW', 'DateTimeOriginal'
21
+ rename_files_with_date path, 'JPG', 'DateTimeOriginal'
22
+ rename_files_with_date path, 'HEIC', 'DateTimeOriginal'
23
+ rename_files_with_date path, 'MOV', 'CreationDate'
24
+ end
25
+
26
+ def self.rename_files_with_date(path, ext, date_property)
27
+ files = Lister.all_files(path, ext)
28
+ if files.empty?
29
+ puts 'Nothing to do here'
30
+ return
31
+ end
32
+ puts "✅ Correcting timestamp for #{files.length} #{ext} files..."
33
+ files_string = files.map { |f| "\"#{f[:path]}\"" }.join(' ')
34
+ Exiftool.change_timestamp date_property, files_string
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vera
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'vera'
4
+
5
+ RSpec.configure do |config|
6
+ # Enable flags like --only-failures and --next-failure
7
+ config.example_status_persistence_file_path = '.rspec_status'
8
+
9
+ # Disable RSpec exposing methods globally on `Module` and `main`
10
+ config.disable_monkey_patching!
11
+
12
+ config.expect_with :rspec do |c|
13
+ c.syntax = :expect
14
+ end
15
+ end
data/spec/vera_spec.rb ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ostruct'
4
+ require 'spec_helper'
5
+
6
+ RSpec.describe Vera::Lister do
7
+ it 'lists files of a specific extension' do
8
+ expect(Dir).to receive(:entries) {
9
+ ['some.jpg', 'other.avi', 'video.mov']
10
+ }
11
+ expect(Vera::Lister.all_files('some/example/path',
12
+ 'jpg')).to eq [{ filename: 'some.jpg', path: 'some/example/path/some.jpg' }]
13
+ end
14
+ end
15
+
16
+ RSpec.describe Vera::Timestamp do
17
+ it 'runs exiftool with the list of files' do
18
+ expect(Vera::Lister).to receive(:all_files)
19
+ .exactly(4).times
20
+ .with(anything, anything) {
21
+ [
22
+ { filename: 'some.jpg', path: 'example/some.jpg' },
23
+ { filename: 'other.jpg', path: 'example/other.jpg' }
24
+ ]
25
+ }
26
+ files = '"example/some.jpg" "example/other.jpg"'
27
+ expect(Vera::Exiftool).to receive(:change_timestamp)
28
+ .exactly(4).times
29
+ .with(anything, files)
30
+ options = OpenStruct.new({ path: 'example' })
31
+ Vera::Timestamp.execute(options)
32
+ end
33
+ end
data/vera-0.1.0.gem ADDED
Binary file
data/vera.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/vera/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'vera'
7
+ spec.version = Vera::VERSION
8
+ spec.authors = ['David Cortés']
9
+ spec.email = ['david.cortes.18@gmail.com']
10
+
11
+ spec.summary = 'CLI tool to organize and manage media files'
12
+ spec.description = 'Vera helps you automatize the process of organizing, cleaning and sorting your photo and video files.'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
15
+ spec.homepage = 'https://github.com/davebcn87/vera'
16
+
17
+ spec.require_paths = ['lib']
18
+
19
+ spec.add_dependency 'commander'
20
+
21
+ spec.add_development_dependency 'rake', '~> 13.0'
22
+ spec.add_development_dependency 'rspec', '~> 3.0'
23
+ spec.add_development_dependency 'rubocop', '~> 1.7'
24
+
25
+ spec.files = Dir['./**/*'].reject { |file| file =~ %r{\./(bin|log|pkg|script|spec|test|vendor)} }
26
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
+ spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
28
+ end
data/vera.jpg ADDED
Binary file
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vera
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - David Cortés
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: commander
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.7'
69
+ description: Vera helps you automatize the process of organizing, cleaning and sorting
70
+ your photo and video files.
71
+ email:
72
+ - david.cortes.18@gmail.com
73
+ executables:
74
+ - vera
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - "./1"
79
+ - "./Gemfile"
80
+ - "./Gemfile.lock"
81
+ - "./LICENSE.txt"
82
+ - "./README.md"
83
+ - "./Rakefile"
84
+ - "./install.sh"
85
+ - "./lib/vera.rb"
86
+ - "./lib/vera/exiftool.rb"
87
+ - "./lib/vera/lister.rb"
88
+ - "./lib/vera/timestamp.rb"
89
+ - "./lib/vera/version.rb"
90
+ - "./vera-0.1.0.gem"
91
+ - "./vera.gemspec"
92
+ - "./vera.jpg"
93
+ - bin/vera
94
+ - spec/spec_helper.rb
95
+ - spec/vera_spec.rb
96
+ homepage: https://github.com/davebcn87/vera
97
+ licenses:
98
+ - MIT
99
+ metadata: {}
100
+ post_install_message:
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: 2.4.0
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubygems_version: 3.0.1
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: CLI tool to organize and manage media files
119
+ test_files:
120
+ - spec/spec_helper.rb
121
+ - spec/vera_spec.rb