super_sync 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +1 -0
- data/TODO.md +13 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/bin/super_sync +37 -0
- data/lib/super_sync.rb +12 -0
- data/lib/super_sync/constants.rb +4 -0
- data/lib/super_sync/messages.rb +40 -0
- data/lib/super_sync/project.rb +88 -0
- data/lib/super_sync/utilities.rb +60 -0
- data/lib/super_sync/version.rb +3 -0
- data/super_sync.gemspec +27 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3ce189bf0440edf5d3846c709b8c3ef9d4b226dc
|
4
|
+
data.tar.gz: 29067ea0c6e4140a6219f0beeec30f208a0815a2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8429ecd2fefbd5d7c8f64a188e45903a1a006d1af93324d4456f9a40578fdf3f3fc4d0edeeb9f034953d50030fcf09425d8bb1afa565752eaeb6a1a0998bb0ad
|
7
|
+
data.tar.gz: 1a20d6825b539283686ce7b207f85ba6805e7439b4fdd3e90092b711864fa1396e70af74d971926c2f2884890a2a22d10d15defc20f0d33f85acfff5188a9c9d
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 ruvido
|
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,43 @@
|
|
1
|
+
# SuperSync
|
2
|
+
|
3
|
+
SuperSync is a super fast SD copying Ruby app to transfer entire photo shoots from multiple cards.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'super_sync'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install super_sync
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## TODO
|
32
|
+
|
33
|
+
Look at the [todo](TODO.md) page for a list of priorities.
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ruvido/SuperSync.
|
38
|
+
|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
43
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/TODO.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# TODO
|
2
|
+
|
3
|
+
## Check consistency
|
4
|
+
|
5
|
+
Make an initial check if the STORAGE folder and LIGHTROOM template folder exist or not. If NOT the process should be stopped since the destination storage folder is missing (e.g. external drive disconnected)
|
6
|
+
|
7
|
+
## Message consistency
|
8
|
+
|
9
|
+
Log progress bar is inside the project class, while initial output messages are defined in the Messages class
|
10
|
+
|
11
|
+
## Create a customizable import dialog
|
12
|
+
|
13
|
+
That is, a way to change the naming of the project folder (useful for family)
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "skeleton"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/bin/super_sync
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'super_sync'
|
3
|
+
|
4
|
+
STORAGE = '/Volumes/speed512/weddings'
|
5
|
+
# STORAGE = '/Users/ruvido/Desktop/weddings'
|
6
|
+
CONFIG = {
|
7
|
+
'storage' => File.join(STORAGE,'import'),
|
8
|
+
'lightroom' => File.join(STORAGE,'templates/lightroom'),
|
9
|
+
'target' => 'originals',
|
10
|
+
'raw_format'=> 'RAF',
|
11
|
+
'debug' => false
|
12
|
+
}
|
13
|
+
DEBUG=CONFIG['debug']
|
14
|
+
|
15
|
+
if DEBUG
|
16
|
+
wedding_data = {
|
17
|
+
'date' => '20051003',
|
18
|
+
'groom'=> 'Francesco',
|
19
|
+
'bride'=> 'Alessandra'
|
20
|
+
}
|
21
|
+
wedding_data ['title']="#{wedding_data['date']} #{wedding_data['groom']} e #{wedding_data['bride']}"
|
22
|
+
else
|
23
|
+
wedding_data = SuperSync::Utilities::CLIdata.fetch()
|
24
|
+
end
|
25
|
+
|
26
|
+
# Create a new project
|
27
|
+
project = SuperSync::Project.new CONFIG, wedding_data
|
28
|
+
messages = SuperSync::Messages.new project
|
29
|
+
|
30
|
+
# Detect attached cards
|
31
|
+
list_of_cards=SuperSync::Utilities::Cards.list("Volumes","DCIM")
|
32
|
+
messages.info_cards(list_of_cards)
|
33
|
+
|
34
|
+
# Start importing cards into the project
|
35
|
+
# (include log messages from progress bar)
|
36
|
+
project.import_from_cards(list_of_cards)
|
37
|
+
|
data/lib/super_sync.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "super_sync/version"
|
2
|
+
require "super_sync/constants"
|
3
|
+
require "super_sync/utilities"
|
4
|
+
require "super_sync/project"
|
5
|
+
require "super_sync/messages"
|
6
|
+
require 'ruby-progressbar'
|
7
|
+
require 'pathname'
|
8
|
+
require 'fileutils'
|
9
|
+
|
10
|
+
module SuperSync
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module SuperSync
|
2
|
+
|
3
|
+
class Messages
|
4
|
+
|
5
|
+
# ----------------------------------------------------
|
6
|
+
def initialize(project)
|
7
|
+
@title = project.title
|
8
|
+
@target = project.target
|
9
|
+
@raw_format = project.raw_format
|
10
|
+
no=SuperSync::Utilities::Folder.number_of_images(@target,@raw_format)
|
11
|
+
|
12
|
+
puts ""
|
13
|
+
puts ""
|
14
|
+
# printf "%40s :: %s\n", 'Project name', @title
|
15
|
+
# printf "%40s :: %5d images\n", '', no
|
16
|
+
printf "%40s :: %-5d images\n", @title, no
|
17
|
+
puts ""
|
18
|
+
# printf "%40s :: \n", ''
|
19
|
+
end
|
20
|
+
|
21
|
+
# ----------------------------------------------------
|
22
|
+
def info_cards(list)
|
23
|
+
noto=0
|
24
|
+
list.each do |cc|
|
25
|
+
no=SuperSync::Utilities::Folder.number_of_images(cc,@raw_format)
|
26
|
+
printf "%40s :: %-5d images\n", cc, no
|
27
|
+
noto+=no
|
28
|
+
end
|
29
|
+
printf "%40s :: %-5d images\n", 'Total', noto
|
30
|
+
puts ""
|
31
|
+
end
|
32
|
+
|
33
|
+
# def update_copying_status(card,slot)
|
34
|
+
# end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module SuperSync
|
2
|
+
|
3
|
+
class Project
|
4
|
+
|
5
|
+
attr_accessor :title
|
6
|
+
attr_accessor :root
|
7
|
+
attr_accessor :target
|
8
|
+
attr_accessor :raw_format
|
9
|
+
|
10
|
+
def initialize (config,wedding_data)
|
11
|
+
|
12
|
+
@title=wedding_data['title']
|
13
|
+
@root=File.join(config['storage'],@title)
|
14
|
+
@target=File.join(@root,config['target'])
|
15
|
+
@raw_format=config['raw_format']
|
16
|
+
|
17
|
+
if File.directory?(@root)
|
18
|
+
@update=true
|
19
|
+
else
|
20
|
+
@update=false
|
21
|
+
# Create project folder from template
|
22
|
+
FileUtils.cp_r config['lightroom'], @root
|
23
|
+
|
24
|
+
# Create target folder
|
25
|
+
Dir.mkdir(@target)
|
26
|
+
|
27
|
+
# Rename lightroom template catalog file
|
28
|
+
template_catalog=Dir.glob("#{@root}/*.#{SuperSync::LR_CATALOG}")[0]
|
29
|
+
catalog="#{@root}/#{wedding_data['title']}.#{SuperSync::LR_CATALOG}"
|
30
|
+
FileUtils.mv template_catalog, catalog
|
31
|
+
|
32
|
+
# Replace handles in lightroom smart collections
|
33
|
+
bride=wedding_data['bride']
|
34
|
+
groom=wedding_data['groom']
|
35
|
+
Dir.glob("#{@root}/**/*.#{SuperSync::LR_COLLECT}") do |file|
|
36
|
+
ff = File.read(file)
|
37
|
+
ff.gsub!("XGROOM", groom)
|
38
|
+
ff.gsub!("XBRIDE", bride)
|
39
|
+
of=open(file, 'w')
|
40
|
+
of.write(ff)
|
41
|
+
of.close()
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
def import_from_cards(list_of_cards)
|
48
|
+
|
49
|
+
# Count total number of images present on cards
|
50
|
+
total_number_of_images=0
|
51
|
+
list_of_cards.each do |card|
|
52
|
+
total_number_of_images+=SuperSync::Utilities::Folder.number_of_images(card,@raw_format)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Copy images on cards into the created card slot folder (see available_card_slot method)
|
56
|
+
progress_bar = ProgressBar.create(:format => '%a |%b>>%i| %p%% %t Processed: %c from %C',:total => total_number_of_images, :autofinish => false)
|
57
|
+
count=0
|
58
|
+
list_of_cards.each do |card|
|
59
|
+
slot=SuperSync::Utilities::Folder.available_card_slot(@target)
|
60
|
+
|
61
|
+
slot_basename = Pathname.new(slot).basename
|
62
|
+
# progress_bar.log "#{card} #{slot_basename}"
|
63
|
+
plog="%40s :: %s" % [card,slot_basename]
|
64
|
+
progress_bar.log plog
|
65
|
+
|
66
|
+
|
67
|
+
Dir.glob("#{card}/**/*.#{@raw_format}") do |file|
|
68
|
+
FileUtils.cp file, slot
|
69
|
+
count+=1
|
70
|
+
progress_bar.increment
|
71
|
+
end
|
72
|
+
end
|
73
|
+
progress_bar.log ""
|
74
|
+
plog="%40s :: %s" % ['Total imported',total_number_of_images]
|
75
|
+
progress_bar.log plog
|
76
|
+
|
77
|
+
noto=SuperSync::Utilities::Folder.number_of_images(@target,@raw_format)
|
78
|
+
plog="%40s :: %s" % ['Total',noto]
|
79
|
+
progress_bar.log plog
|
80
|
+
progress_bar.log "\n"
|
81
|
+
progress_bar.finish
|
82
|
+
puts ""
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module SuperSync
|
2
|
+
|
3
|
+
module Utilities
|
4
|
+
|
5
|
+
module Folder
|
6
|
+
def self.number_of_images(folder,file_extension)
|
7
|
+
cc=0
|
8
|
+
Dir.glob("#{folder}/**/*.#{file_extension}").each do |file|
|
9
|
+
cc+=1
|
10
|
+
end
|
11
|
+
return cc
|
12
|
+
end
|
13
|
+
def self.available_card_slot(folder)
|
14
|
+
ii=1
|
15
|
+
while 1 do
|
16
|
+
test_slot=File.join(folder,"card_#{ii}")
|
17
|
+
if File.directory?(test_slot)
|
18
|
+
ii+=1
|
19
|
+
else
|
20
|
+
slot = test_slot
|
21
|
+
# When missing it creates the parent folder containing all the imported cards (mkdir -p)
|
22
|
+
FileUtils.mkdir_p(slot)
|
23
|
+
return slot
|
24
|
+
break
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# -------------------------------------------------
|
31
|
+
module Cards
|
32
|
+
def self.list(volumes,images_folder)
|
33
|
+
dcim_list=[]
|
34
|
+
Dir.glob("/#{volumes}/*").each do |volname|
|
35
|
+
dcim=File.join(volname,images_folder)
|
36
|
+
if File.directory?(dcim)
|
37
|
+
dcim_list.push(dcim)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
return dcim_list
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# -------------------------------------------------
|
45
|
+
module CLIdata
|
46
|
+
def self.fetch()
|
47
|
+
cli_data = Hash.new
|
48
|
+
print "Date: "
|
49
|
+
cli_data[ "date" ] = gets.chomp
|
50
|
+
print "Groom: "
|
51
|
+
cli_data[ "groom" ] = gets.chomp
|
52
|
+
print "Bride: "
|
53
|
+
cli_data[ "bride" ] = gets.chomp
|
54
|
+
cli_data[ "title" ] = "#{cli_data['date']} #{cli_data['groom']} e #{cli_data['bride']}"
|
55
|
+
return cli_data
|
56
|
+
end
|
57
|
+
end
|
58
|
+
# -------------------------------------------------
|
59
|
+
end
|
60
|
+
end
|
data/super_sync.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'super_sync/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "super_sync"
|
8
|
+
spec.version = SuperSync::VERSION
|
9
|
+
spec.authors = ["ruvido"]
|
10
|
+
spec.email = ["ruvido@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Super Sync SD}
|
13
|
+
spec.description = %q{Super Sync SD}
|
14
|
+
spec.homepage = "https://github.com/ruvido/SuperSync"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake" #, "~> 10.0"
|
24
|
+
|
25
|
+
spec.add_dependency 'ruby-progressbar'
|
26
|
+
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: super_sync
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ruvido
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruby-progressbar
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Super Sync SD
|
56
|
+
email:
|
57
|
+
- ruvido@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- .travis.yml
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- TODO.md
|
69
|
+
- bin/console
|
70
|
+
- bin/setup
|
71
|
+
- bin/super_sync
|
72
|
+
- lib/super_sync.rb
|
73
|
+
- lib/super_sync/constants.rb
|
74
|
+
- lib/super_sync/messages.rb
|
75
|
+
- lib/super_sync/project.rb
|
76
|
+
- lib/super_sync/utilities.rb
|
77
|
+
- lib/super_sync/version.rb
|
78
|
+
- super_sync.gemspec
|
79
|
+
homepage: https://github.com/ruvido/SuperSync
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.0.14
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: Super Sync SD
|
103
|
+
test_files: []
|