imagebackup 0.3.1 → 0.3.2

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: c4a1d4dd786b4165fd4812dea1de48ef9ad9ad9040e2b4c572f633117e7147f9
4
- data.tar.gz: 67d0e990a7491fee092a0b58386b218a52635ae1f68a79608dca347c791d8814
3
+ metadata.gz: adbf3e8724183017c88e48e354363cbe74c985d3585cb9665346f32516a5338e
4
+ data.tar.gz: 7b74e6acd3b81d47af8cbbe0aca1620d8eab1af475aed59954457671eb0cb021
5
5
  SHA512:
6
- metadata.gz: 9b0b396b58101630b0c8390e9b0a6b8e139774b29d775136518becc866157bc66245682be814fc299b79095147f00c53d15a13079017fdc73b2973a8148aa511
7
- data.tar.gz: d6c1d1dadc59c952dfca3d99f559fc69538459cde68d6268914a5e25bb4668fe5ec05d8e4f6e4d6914744cc91623331c79556bc3fbfc3b96c33d7322a9b7e38f
6
+ metadata.gz: af4f028e7386a4e42d2cf3fa29d9526af6757e77de10a04d677863f2137cc47babc849aa1c6b39c51a81bf96a3ecb2ea9a9df7164e205e0526c7c3663d2be7a0
7
+ data.tar.gz: e65c8cf849463f16aaaaa165c5ede4b0d649736272215c65d90797431bfb3e028069f4dd2c3113aadbb7615beb0eab357805cc7ee74aa45c9920d9ec05cee673
data/.gitignore CHANGED
@@ -6,6 +6,6 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
-
9
+ README_assessment.md
10
10
  # rspec failure tracking
11
11
  .rspec_status
data/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  ### A simple terminal app to crawl a folder (usually a camera card's DCIM folder) for pictures and videos, and pop them in dated folders to your destination folder of choice. Uses exif data when available, creation_time, or the file's own creation date if nothing better is present.
6
6
  ### Will also copy over any xmp sidecar files found, not overwriting.
7
7
 
8
+ Source is available here: [https://github.com/adrian-sal-kennedy/imagebackup]()
8
9
 
9
10
  ## Options:
10
11
  -n, --dry-run
@@ -72,13 +73,15 @@ This mode can be useful if you want to operate on the files in one place but kee
72
73
  ## Dependencies:
73
74
 
74
75
  **Ruby** v2.3.0 or greater, plus gems:
75
- - exiv2
76
- - ffprober
76
+ - [exiv2](https://rubygems.org/gems/exiv2/versions/0.0.8) to retrieve EXIF date/time.
77
+ - [ffprober](https://github.com/beanieboi/ffprober) to retrieve video container date/time tags if present.
78
+ - [colorize](https://github.com/fazibear/colorize) to make output a little more readable and engaging.
77
79
 
78
80
  Ruby modules:
79
- - fileutils.rb
81
+ - [fileutils](https://ruby-doc.org/stdlib-2.4.1/libdoc/fileutils/rdoc/FileUtils.html) to manage file operations (get attributes, copy, move, link).
82
+ - [csv](https://ruby-doc.org/stdlib-2.6.1/libdoc/csv/rdoc/CSV.html) to process the list of available file types.
80
83
 
81
84
  Bundler should handle all these dependencies. If for some reason it doesn't you can run this in terminal:
82
85
  ```bash
83
- $ gem install exiv2 ffprober
84
- ```
86
+ $ gem install exiv2 ffprober colorize
87
+ ```
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ['lib']
31
31
 
32
+ spec.add_dependency 'colorize'
32
33
  spec.add_dependency 'exiv2'
33
34
  spec.add_dependency 'ffprober'
34
35
  end
@@ -1,4 +1,3 @@
1
- require 'csv'
2
1
 
3
2
  # FileTypes is a very simple file class to store and retrieve the list of files
4
3
  # we are interested in backing up.
@@ -8,9 +8,11 @@ require_relative 'methods/get_dates'
8
8
  require_relative 'methods/copy_pic'
9
9
  require_relative 'methods/display_help'
10
10
 
11
+ require 'colorize'
11
12
  require 'exiv2'
12
13
  require 'fileutils'
13
14
  require 'ffprober'
15
+ require 'csv'
14
16
 
15
17
  def main_loop(dest, dryrun = true, file_op = 'copy')
16
18
  file_types = FileTypes.list
@@ -23,6 +25,7 @@ def main_loop(dest, dryrun = true, file_op = 'copy')
23
25
 
24
26
  copy_pic(file, outfile, destpath, dryrun, file_op)
25
27
  end
28
+ puts "\nFinished!\n".colorize(:light_green)
26
29
  end
27
30
 
28
31
  dryrun = true
@@ -42,16 +45,17 @@ if ARGV.include?('-a')
42
45
  ext = ARGV[ARGV.index('-a') + 1]
43
46
  type = ARGV[ARGV.index('-a') + 2]
44
47
  ARGV.slice!(ARGV.index('-a')..ARGV.index('-a') + 2)
48
+ FileTypes.add(ext, type)
45
49
  end
46
50
  if ARGV.include?('--add-filetype')
47
51
  ext = ARGV[ARGV.index('--add-filetype') + 1]
48
52
  type = ARGV[ARGV.index('--add-filetype') + 2]
49
53
  ARGV.slice!(ARGV.index('--add-filetype')..ARGV.index('--add-filetype') + 2)
54
+ FileTypes.add(ext, type)
50
55
  end
51
- FileTypes.add(ext, type) if ext
52
56
  if (ARGV & ['-n', '--dry-run']).any?
53
57
  dryrun = true
54
- puts 'Doing a dry run - no operations will happen.'
58
+ puts 'Doing a dry run - no operations will happen.'.colorize(:light_magenta)
55
59
  sleep 1
56
60
  ARGV.delete('-n')
57
61
  ARGV.delete('--dry-run')
@@ -59,7 +63,7 @@ else
59
63
  dryrun = false
60
64
  end
61
65
 
62
- display_help if (ARGV & ['-h', '--help', '-?']).any?
66
+ display_help("Exited normally",:light_green) if (ARGV & ['-h', '--help', '-?']).any?
63
67
 
64
68
  if ARGV[0].to_s == ''
65
69
  display_help
@@ -67,7 +71,7 @@ elsif File.exist?(ARGV[0])
67
71
  main_loop(ARGV[0], dryrun, file_op)
68
72
  elsif ARGV[0][0] == '-'
69
73
  puts "Invalid option!\n-----\n\n"
70
- display_help
74
+ display_help("\n-----\nInvalid option: \"#{ARGV[0]}\"!\n\n",:red)
71
75
  else
72
76
  puts 'Specified destination does not exist. Please create this folder first.'
73
77
  end
@@ -1,3 +1,3 @@
1
1
  module Imagebackup
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
@@ -1,21 +1,18 @@
1
1
  def process_file(file, outfile, dryrun = nil, file_op = 'cp')
2
2
  if dryrun
3
- puts "pretending to #{file_op} \"#{file} to #{outfile}\""
3
+ puts "#{"pretending to ".colorize(:light_green)}#{file_op} \"#{file}\"#{" to ".colorize(:light_green)}\"#{outfile}\""
4
4
  else
5
5
  puts "#{file_op}-ing \"#{file} to #{outfile}\"..."
6
6
  FileUtils.public_send(file_op, file, outfile)
7
- FileUtils.public_send(file_op, "#{file}.xmp", outfile, force: true)
8
- if file_op == 'cp'
9
- FileUtils.public_send(file_op, "#{file}.xmp", outfile)
10
- else
11
- FileUtils.public_send(file_op, "#{file}.xmp", outfile, force: true)
7
+ if File.exist?("#{file}.xmp")
8
+ FileUtils.public_send(file_op, "#{file}.xmp", "#{outfile}.xmp")
12
9
  end
13
10
  end
14
11
  end
15
12
 
16
13
  def copy_pic(file, outfile, destpath, dryrun = nil, file_op = 'cp')
17
14
  if File.exist?(outfile)
18
- puts "\"#{outfile}\" already exists. Skipping..."
15
+ puts "\"#{outfile}\" #{"already exists. Skipping...".colorize(:light_blue)}."
19
16
  else
20
17
  unless dryrun
21
18
  unless File.exist?(destpath)
@@ -1,4 +1,4 @@
1
- def display_help
1
+ def display_help(err=nil,color=nil)
2
2
  print <<~HELPFILE
3
3
  ===== ImageBackup =====
4
4
 
@@ -22,7 +22,7 @@ def display_help
22
22
  but ensure there's a blank line at the end or this program
23
23
  may behave badly.
24
24
 
25
- -m will move (deleting the original), which is probably not a
25
+ -m Will move (deleting the original), which is probably not a
26
26
  good idea in most cases but still useful at times.
27
27
 
28
28
  Usage:
@@ -63,20 +63,7 @@ def display_help
63
63
  $ imagebackup.rb --link ~/Photos/raw
64
64
 
65
65
  This mode can be useful if you want to operate on the files in one place but keep them on their media. Particularly useful for large movie files.
66
-
67
- Dependencies:
68
-
69
- Ruby v2.3.0 or greater, plus gems:
70
- - exiv2
71
- - ffprober
72
-
73
- Ruby modules:
74
- - fileutils
75
-
76
- Bundler should handle all these dependencies. If for some reason it doesn't you can run this in terminal:
77
- $ gem install exiv2 ffprober
78
-
79
66
  HELPFILE
80
-
67
+ puts err.to_s.colorize(color)
81
68
  exit(0)
82
69
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imagebackup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - adrian-sal-kennedy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-12 00:00:00.000000000 Z
11
+ date: 2020-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colorize
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'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: exiv2
15
29
  requirement: !ruby/object:Gem::Requirement