phtools 0.3.0.pre.alpha → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Guardfile +23 -9
- data/History.md +1 -1
- data/README.md +47 -4
- data/TODO.md +6 -0
- data/exe/phls +2 -2
- data/exe/phmove +36 -0
- data/lib/phls.rb +12 -9
- data/lib/phmove.rb +51 -0
- data/lib/phtools/runner.rb +11 -1
- data/lib/phtools/version.rb +1 -1
- data/lib/phtools.rb +3 -2
- data/phtools.gemspec +0 -1
- metadata +7 -18
- data/lib/pharrange.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 921ff0d0c9821c060f63be602f1ac915100cd08c
|
4
|
+
data.tar.gz: bd7b1d4d522b91cbf0e968660efc2cedafb27e0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f76752ffec443ad1cfd8eed65ba440d83b2511f8152cf9c7bbf6e16d6cda16529729357189fce04888039e18761aaa5f327f98efefc880030259e0aee0bc29d
|
7
|
+
data.tar.gz: 87ac9775742fb7840b69e7a71d9c322c7d9f6184f4cb02e48a267728bcf6308b39fa47c183048e65dc17cb6e7808a3983a735dd704e5eadd58e119ea0ca01d0b
|
data/Guardfile
CHANGED
@@ -5,16 +5,30 @@ notification :terminal_notifier, app_name: "phtools"
|
|
5
5
|
# notification :terminal_title
|
6
6
|
# notification :tmux, display_message: false
|
7
7
|
|
8
|
-
guard 'cucumber', notification: true do
|
9
|
-
watch(%r{^features/.+\.feature$})
|
10
|
-
watch(%r{^features/support/.+$}) { 'features' }
|
11
|
-
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/{m[1]}.feature")][0] || 'features' }
|
12
|
-
watch(%r{^bin/(.+)$}) { |m| "features/#{m[1]}.feature" }
|
13
|
-
end
|
14
|
-
|
15
8
|
guard :rspec, cmd: "bundle exec rspec" do
|
16
9
|
watch(%r{^spec/.+_spec\.rb$})
|
17
10
|
watch(%r{^bin/(.+)$}) { |m| "spec/#{m[1]}_spec.rb" }
|
18
|
-
watch(%r{^lib/(.+)\.rb$})
|
19
|
-
watch('spec/spec_helper.rb')
|
11
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
12
|
+
watch('spec/spec_helper.rb') { "spec" }
|
13
|
+
end
|
14
|
+
|
15
|
+
cucumber_options = {
|
16
|
+
# Below are examples overriding defaults
|
17
|
+
# cmd: 'bundle exec cucumber',
|
18
|
+
# cmd_additional_args: '--profile guard',
|
19
|
+
# all_after_pass: false,
|
20
|
+
# all_on_start: false,
|
21
|
+
# keep_failed: false,
|
22
|
+
# feature_sets: ['features/frontend', 'features/experimental'],
|
23
|
+
# run_all: { cmd_additional_args: '--profile guard_all' },
|
24
|
+
# focus_on: { 'wip' }, # @wip
|
25
|
+
notification: true
|
26
|
+
}
|
27
|
+
|
28
|
+
guard 'cucumber', cucumber_options do
|
29
|
+
watch(%r{^features/.+\.feature$})
|
30
|
+
watch(%r{^features/support/.+$}) { 'features' }
|
31
|
+
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/{m[1]}.feature")][0] || 'features' }
|
32
|
+
watch(%r{^exe/(.+)$}) { |m| "features/#{m[1]}.feature" }
|
33
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "features/#{m[1]}.feature" }
|
20
34
|
end
|
data/History.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# RELEASED
|
2
2
|
|
3
|
-
## [v0.3.0
|
3
|
+
## [v0.3.0.pre.alpha](https://github.com/andrewbiz/phtools/compare/v0.2.4...v0.3.0.pre.alpha)
|
4
4
|
|
5
5
|
* Improved phtools - now it supports DIRs and FILEMASKs parameters
|
6
6
|
* Added aruba (cucumber) tests for phls
|
data/README.md
CHANGED
@@ -1,6 +1,49 @@
|
|
1
|
-
|
1
|
+
[](https://rubygems.org/gems/phtools)
|
2
|
+
# PHTOOLS by ANB
|
3
|
+
A bundle of small CLI tools for arranging, renaming, tagging of the photo and video files. Helps keep photo-video assets in order.
|
2
4
|
|
3
|
-
|
5
|
+
##Installation
|
6
|
+
### Install for usage
|
7
|
+
Get the latest [ruby](https://www.ruby-lang.org/) (>= 2.3) installed.
|
4
8
|
|
5
|
-
|
6
|
-
|
9
|
+
Install ExifTool by Phil Harvey (http://www.sno.phy.queensu.ca/~phil/exiftool/)
|
10
|
+
```
|
11
|
+
gem install phtools
|
12
|
+
```
|
13
|
+
### Install for development
|
14
|
+
Fork or download from GitHub.
|
15
|
+
|
16
|
+
```sh
|
17
|
+
bundle install
|
18
|
+
```
|
19
|
+
Develop, test:
|
20
|
+
```sh
|
21
|
+
bundle exec rspec
|
22
|
+
bundle exec cucumber
|
23
|
+
```
|
24
|
+
... or do testing automatically to get real Test Driven Development:
|
25
|
+
```sh
|
26
|
+
bundle exec guard
|
27
|
+
```
|
28
|
+
|
29
|
+
## PHTOOLS Use cases
|
30
|
+
### Use Case 1. Collect photos, videos, raw-photos from different sources into one place (for further processing)
|
31
|
+
|
32
|
+
####Given
|
33
|
+
I have copies of SD Cards with photos, videos taken with DSLR camera on my Hard Disk in `~/path/to/copy/SDCard1` and in `~/path/to/copy/SDCard2`.
|
34
|
+
|
35
|
+
And I have empty folder `~/Desktop/assets_staging` I would like to collect all the photo-files to.
|
36
|
+
|
37
|
+
####When
|
38
|
+
I run:
|
39
|
+
```sh
|
40
|
+
cd ~/Desktop/assets_staging
|
41
|
+
phls -R ~/path/to/copy/SDCard1 ~/path/to/copy/SDCard2 | phmove -a
|
42
|
+
```
|
43
|
+
|
44
|
+
####Then
|
45
|
+
I get all photos moved to `~/Desktop/assets_staging`.
|
46
|
+
|
47
|
+
And all videos are moved to `~/Desktop/assets_staging/VIDEO`.
|
48
|
+
|
49
|
+
And all raw photo-files are moved to `~/Desktop/assets_staging/RAW`.
|
data/TODO.md
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
- [x] core - runner.rb: print class instance variables in debug mode
|
2
|
+
- [x] phls: use init method to initialize variables
|
3
|
+
- [x] phls: change -r to -R
|
4
|
+
- [x] phmove: create phmove tool based on ftarrange code (see ftools repo)
|
5
|
+
- [ ] phmove: make parameters to set photo, video, raw folder names
|
6
|
+
- [ ] phmove: -a (--arrange) parameter means to put photo, video, raw files into separate folders inside target. If -a is not set all files are moved to target directory (plain collection of files)
|
data/exe/phls
CHANGED
@@ -24,13 +24,13 @@ Example: #{tool_name} abc '*aaa*' | phrename -a anb => scans 'abc' folder and
|
|
24
24
|
sends all found phtools friendly files filtered with *aaa* to phrename command.
|
25
25
|
|
26
26
|
Usage:
|
27
|
-
#{tool_name} [-D] [-
|
27
|
+
#{tool_name} [-D] [-R] [DIR_OR_FILEMASK...]
|
28
28
|
#{tool_name} -h | --help
|
29
29
|
#{tool_name} -v | --version
|
30
30
|
|
31
31
|
Options:
|
32
32
|
-D --debug Turn on debugging (verbose) mode
|
33
|
-
-
|
33
|
+
-R --recursive Recursively scan directories
|
34
34
|
-h --help Show this screen.
|
35
35
|
-v --version Show version.
|
36
36
|
DOCOPT
|
data/exe/phmove
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
# (c) ANB Andrew Bizyaev
|
4
|
+
|
5
|
+
module PhTools
|
6
|
+
tool_name = File.basename(__FILE__)
|
7
|
+
require "#{tool_name}"
|
8
|
+
|
9
|
+
file_type = FILE_TYPE_IMAGE + FILE_TYPE_VIDEO + FILE_TYPE_AUDIO
|
10
|
+
usage = <<DOCOPT
|
11
|
+
***************************************************
|
12
|
+
phtools - *Keep Your Photos In Order* (c) ANB
|
13
|
+
***************************************************
|
14
|
+
#{tool_name} moves input file(s) into WORKING_FOLDER
|
15
|
+
separating photo files, RAW photo files and VIDEO files in corresponding
|
16
|
+
subfolders.
|
17
|
+
phtools friendly files: #{file_type * ','}
|
18
|
+
|
19
|
+
Optimized to be used with other *phtools* via pipes.
|
20
|
+
Example: phls | phrename -a anb | #{tool_name}
|
21
|
+
|
22
|
+
Usage:
|
23
|
+
#{tool_name} [-w WORKING_FOLDER] [-D]
|
24
|
+
#{tool_name} -h | --help
|
25
|
+
#{tool_name} -v | --version
|
26
|
+
|
27
|
+
Options:
|
28
|
+
-w FLD --working_folder=FLD Folder the input files to be
|
29
|
+
moved to [default: .]
|
30
|
+
-D --debug Turn on debugging (verbose) mode
|
31
|
+
-h --help Show this screen.
|
32
|
+
-v --version Show version.
|
33
|
+
DOCOPT
|
34
|
+
|
35
|
+
PhTools.const_get(tool_name.capitalize).new(usage, file_type).run!
|
36
|
+
end
|
data/lib/phls.rb
CHANGED
@@ -12,15 +12,8 @@ module PhTools
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def run!
|
15
|
-
dirs_to_scan
|
16
|
-
|
17
|
-
@options_cli['DIR_OR_FILEMASK'].each do |item|
|
18
|
-
File.directory?(item) ? dirs_to_scan << item : filemasks << item
|
19
|
-
end
|
20
|
-
dirs_to_scan = ['.'] if dirs_to_scan.empty?
|
21
|
-
filemasks = ['*.*'] if filemasks.empty?
|
22
|
-
dirs_to_scan.each do |dir|
|
23
|
-
fmask = File.join(dir, @options_cli['--recursive'] ? '**' : '', "{#{filemasks * ','}}")
|
15
|
+
@dirs_to_scan.each do |dir|
|
16
|
+
fmask = File.join(dir, @options_cli['--recursive'] ? '**' : '', "{#{@filemasks * ','}}")
|
24
17
|
Dir.glob(fmask, File::FNM_CASEFOLD).each { |f| output_file(f) if File.file?(f) }
|
25
18
|
end
|
26
19
|
|
@@ -34,6 +27,16 @@ module PhTools
|
|
34
27
|
|
35
28
|
private
|
36
29
|
|
30
|
+
def validate_options
|
31
|
+
@dirs_to_scan = []
|
32
|
+
@filemasks = []
|
33
|
+
@options_cli['DIR_OR_FILEMASK'].each do |item|
|
34
|
+
File.directory?(item) ? @dirs_to_scan << item : @filemasks << item
|
35
|
+
end
|
36
|
+
@dirs_to_scan = ['.'] if @dirs_to_scan.empty?
|
37
|
+
@filemasks = ['*.*'] if @filemasks.empty?
|
38
|
+
end
|
39
|
+
|
37
40
|
def output_file(file)
|
38
41
|
ftype = File.extname(file).empty? ? '' : File.extname(file).slice(1..-1).downcase
|
39
42
|
@os.output(File.join(File.dirname(file), File.basename(file))) if @file_type.include?(ftype)
|
data/lib/phmove.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
# (c) ANB Andrew Bizyaev
|
4
|
+
|
5
|
+
require 'phtools/runner'
|
6
|
+
|
7
|
+
module PhTools
|
8
|
+
class Phmove < Runner
|
9
|
+
def self.about
|
10
|
+
"moves input files into working folder"
|
11
|
+
end
|
12
|
+
private
|
13
|
+
|
14
|
+
def validate_options
|
15
|
+
@working_folder = @options_cli['--working_folder'] || ''
|
16
|
+
@raw_folder = File.join(@working_folder, 'RAW')
|
17
|
+
@video_folder = File.join(@working_folder, 'VIDEO')
|
18
|
+
end
|
19
|
+
|
20
|
+
def process_before
|
21
|
+
fail PhTools::Error, "#{@working_folder} does not exist" unless File.exist?(@working_folder)
|
22
|
+
fail PhTools::Error, "#{@working_folder} is not a directory" unless File.directory?(@working_folder)
|
23
|
+
begin
|
24
|
+
Dir.mkdir @raw_folder unless Dir.exist?(@raw_folder)
|
25
|
+
Dir.mkdir @video_folder unless Dir.exist?(@video_folder)
|
26
|
+
rescue
|
27
|
+
raise PhTools::Error, "Unable to make dir inside '#{@working_folder}'"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def process_file(ftfile)
|
32
|
+
ftfile_out = ftfile.clone
|
33
|
+
file_type = ftfile.extname.slice(1..-1).downcase
|
34
|
+
case
|
35
|
+
when FILE_TYPE_IMAGE_NORMAL.include?(file_type)
|
36
|
+
ftfile_out.dirname = @working_folder
|
37
|
+
when FILE_TYPE_IMAGE_RAW.include?(file_type)
|
38
|
+
ftfile_out.dirname = @raw_folder
|
39
|
+
when FILE_TYPE_VIDEO.include?(file_type)
|
40
|
+
ftfile_out.dirname = @video_folder
|
41
|
+
when FILE_TYPE_AUDIO.include?(file_type)
|
42
|
+
ftfile_out.dirname = @working_folder
|
43
|
+
end
|
44
|
+
|
45
|
+
FileUtils.mv(ftfile.filename, ftfile_out.filename) unless ftfile == ftfile_out
|
46
|
+
ftfile_out
|
47
|
+
rescue SystemCallError => e
|
48
|
+
raise PhTools::Error, 'file moving - ' + e.message
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/phtools/runner.rb
CHANGED
@@ -27,10 +27,14 @@ module PhTools
|
|
27
27
|
@options_cli = Docopt.docopt(usage, version: "v#{PhTools::VERSION}")
|
28
28
|
@file_type = file_type
|
29
29
|
PhTools.debug = true if @options_cli['--debug']
|
30
|
-
PhTools.puts_error "OPTIONS = #{@options_cli}" if PhTools.debug
|
31
30
|
|
32
31
|
validate_options
|
33
32
|
|
33
|
+
if PhTools.debug
|
34
|
+
STDERR.puts "Instance Variables: "
|
35
|
+
STDERR.puts context
|
36
|
+
end
|
37
|
+
|
34
38
|
rescue Docopt::Exit => e
|
35
39
|
STDERR.puts e.message
|
36
40
|
exit 0
|
@@ -79,5 +83,11 @@ module PhTools
|
|
79
83
|
|
80
84
|
def process_after
|
81
85
|
end
|
86
|
+
|
87
|
+
def context
|
88
|
+
self.instance_variables.map do |item|
|
89
|
+
{ item => self.instance_variable_get(item) }
|
90
|
+
end
|
91
|
+
end
|
82
92
|
end
|
83
93
|
end
|
data/lib/phtools/version.rb
CHANGED
data/lib/phtools.rb
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
# encoding: UTF-8
|
3
3
|
# (c) ANB Andrew Bizyaev
|
4
4
|
require 'phtools/version'
|
5
|
-
require 'pharrange'
|
6
5
|
require 'phbackup'
|
7
6
|
require 'phclname'
|
8
7
|
require 'phevent'
|
9
8
|
require 'phfixdate'
|
10
9
|
require 'phfixfmd'
|
11
10
|
require 'phls'
|
11
|
+
require 'phmove'
|
12
12
|
require 'phmtags'
|
13
13
|
require 'phrename'
|
14
14
|
require 'phtagset'
|
@@ -19,7 +19,7 @@ module PhTools
|
|
19
19
|
phtools v#{VERSION} is a bundle of small CLI tools for arranging, renaming, tagging
|
20
20
|
of the photo and video files. Helps to keep your photo-video assets in order.
|
21
21
|
Please run phtools in a terminal via CLI commands:
|
22
|
-
|
22
|
+
phmove\t(#{Phmove::about}),
|
23
23
|
phbackup\t(#{Phbackup::about}),
|
24
24
|
phclname\t(#{Phclname::about}),
|
25
25
|
phevent\t(#{Phevent::about}),
|
@@ -30,6 +30,7 @@ Please run phtools in a terminal via CLI commands:
|
|
30
30
|
phrename \t(#{Phrename::about}),
|
31
31
|
phtagset\t(#{Phtagset::about}).
|
32
32
|
For more information run these commands with -h option.
|
33
|
+
General info about phtools usage see at https://github.com/AndrewBiz/phtools.git
|
33
34
|
TEXT
|
34
35
|
end
|
35
36
|
end
|
data/phtools.gemspec
CHANGED
@@ -33,7 +33,6 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency 'cucumber', '~> 2.0'
|
34
34
|
spec.add_development_dependency 'aruba', '~> 0.14'
|
35
35
|
spec.add_development_dependency 'fuubar'
|
36
|
-
spec.add_development_dependency 'rubocop'
|
37
36
|
spec.add_development_dependency 'guard'
|
38
37
|
spec.add_development_dependency 'guard-rspec'
|
39
38
|
spec.add_development_dependency 'guard-cucumber'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phtools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.0
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Bizyaev
|
@@ -108,20 +108,6 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rubocop
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: guard
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -254,6 +240,7 @@ email:
|
|
254
240
|
- andrew.bizyaev@gmail.com
|
255
241
|
executables:
|
256
242
|
- phls
|
243
|
+
- phmove
|
257
244
|
- phtools
|
258
245
|
extensions: []
|
259
246
|
extra_rdoc_files: []
|
@@ -267,18 +254,20 @@ files:
|
|
267
254
|
- LICENSE.txt
|
268
255
|
- README.md
|
269
256
|
- Rakefile
|
257
|
+
- TODO.md
|
270
258
|
- bin/console
|
271
259
|
- bin/setup
|
272
260
|
- bin/stmux
|
273
261
|
- exe/phls
|
262
|
+
- exe/phmove
|
274
263
|
- exe/phtools
|
275
|
-
- lib/pharrange.rb
|
276
264
|
- lib/phbackup.rb
|
277
265
|
- lib/phclname.rb
|
278
266
|
- lib/phevent.rb
|
279
267
|
- lib/phfixdate.rb
|
280
268
|
- lib/phfixfmd.rb
|
281
269
|
- lib/phls.rb
|
270
|
+
- lib/phmove.rb
|
282
271
|
- lib/phmtags.rb
|
283
272
|
- lib/phrename.rb
|
284
273
|
- lib/phtagset.rb
|
@@ -310,9 +299,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
310
299
|
version: 2.0.0
|
311
300
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
312
301
|
requirements:
|
313
|
-
- - "
|
302
|
+
- - ">="
|
314
303
|
- !ruby/object:Gem::Version
|
315
|
-
version:
|
304
|
+
version: '0'
|
316
305
|
requirements:
|
317
306
|
- ExifTool by Phil Harvey (http://www.sno.phy.queensu.ca/~phil/exiftool/)
|
318
307
|
rubyforge_project:
|