iphoto_backup 0.0.1
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 +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +5 -0
- data/bin/iphoto_backup +4 -0
- data/iphoto_backup.gemspec +28 -0
- data/lib/iphoto_backup.rb +5 -0
- data/lib/iphoto_backup/cli.rb +87 -0
- data/lib/iphoto_backup/version.rb +3 -0
- data/spec/lib/iphoto_backup/cli_spec.rb +21 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/support/meet_expectations_matcher.rb +7 -0
- metadata +147 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2ab4c53aa5fd307714a1cc1343943344de35c367
|
4
|
+
data.tar.gz: 6e07fda88244670e5e7887e2bbb0adcb98f40804
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ff8f154a1fbebe3baf811df3830e642a2d406327e790a0e9ed083ca86709fa26f91f438f1c94102cfc0501bcdb062179ff265fcf8c94bc1841767c1a547fc186
|
7
|
+
data.tar.gz: 12200098d14a2423850193173ac66034247014800d6a0eb0ee02bc5fb64c92db67bbbc15ec489dc7461524c1945e4dd7de14800f2a7ab16f15c65724e53b41c7
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p353
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Ryan Sonnek
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# IphotoBackup
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
[Originally implemented as a Python script](https://github.com/wireframe/dotfiles/blob/628b982d9fc4e7b4cc9e6ca806cae81b541f9bbd/home/bin/iphoto_export.py)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'iphoto_backup'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install iphoto_backup
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/iphoto_backup
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'iphoto_backup/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "iphoto_backup"
|
8
|
+
spec.version = IphotoBackup::VERSION
|
9
|
+
spec.authors = ["Ryan Sonnek"]
|
10
|
+
spec.email = ["ryan@codecrate.com"]
|
11
|
+
spec.description = %q{tool for backing up iPhoto files}
|
12
|
+
spec.summary = %q{copy files out of iPhoto into a backup directory}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'thor'
|
22
|
+
spec.add_dependency 'nokogiri'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency 'rspec'
|
27
|
+
spec.add_development_dependency 'pry'
|
28
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module IphotoBackup
|
6
|
+
class CLI < Thor
|
7
|
+
IPHOTO_ALBUM_PATH = "~/Pictures/iPhoto Library.photolibrary/AlbumData.xml"
|
8
|
+
DEFAULT_OUTPUT_DIRECTORY = "~/Google Drive/Dropbox"
|
9
|
+
|
10
|
+
desc "export iPhoto albums", "exports iPhoto albums into target directory"
|
11
|
+
option :filter, aliases: '-e', default: '.*'
|
12
|
+
option :output, aliases: '-o', default: DEFAULT_OUTPUT_DIRECTORY
|
13
|
+
def export
|
14
|
+
each_album do |folder_name, album_info|
|
15
|
+
say "\n\nProcessing Roll: #{folder_name}..."
|
16
|
+
|
17
|
+
album_images = value_for_dictionary_key('KeyList', album_info).css('string').map(&:content)
|
18
|
+
album_images.each do |image_id|
|
19
|
+
image_info = info_for_image image_id
|
20
|
+
source_path = value_for_dictionary_key('ImagePath', image_info).content
|
21
|
+
|
22
|
+
target_path = File.join(File.expand_path(options[:output]), folder_name, File.basename(source_path))
|
23
|
+
target_dir = File.dirname target_path
|
24
|
+
FileUtils.mkdir_p(target_dir) unless Dir.exists?(target_dir)
|
25
|
+
|
26
|
+
if FileUtils.uptodate?(source_path, [ target_path ])
|
27
|
+
say " copying #{source_path} to #{target_path}"
|
28
|
+
FileUtils.copy source_path, target_path, preserve: true
|
29
|
+
else
|
30
|
+
print '.'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
default_command :export
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def each_album(&block)
|
40
|
+
albums = value_for_dictionary_key("List of Rolls").children.select {|n| n.name == 'dict' }
|
41
|
+
albums.each do |album_info|
|
42
|
+
folder_name = value_for_dictionary_key('RollName', album_info).content
|
43
|
+
|
44
|
+
if folder_name.match(album_filter)
|
45
|
+
yield folder_name, album_info
|
46
|
+
else
|
47
|
+
say "\n\n#{folder_name} does not match the filter: #{album_filter.inspect}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def info_for_image(image_id)
|
53
|
+
value_for_dictionary_key image_id, master_images
|
54
|
+
end
|
55
|
+
|
56
|
+
def value_for_dictionary_key(key, dictionary = root_dictionary)
|
57
|
+
key_node = dictionary.children.find {|n| n.name == 'key' && n.content == key }
|
58
|
+
next_element key_node
|
59
|
+
end
|
60
|
+
|
61
|
+
# find next available sibling element
|
62
|
+
def next_element(node)
|
63
|
+
element_node = node
|
64
|
+
while element_node != nil do
|
65
|
+
element_node = element_node.next_sibling
|
66
|
+
break if element_node.element?
|
67
|
+
end
|
68
|
+
element_node
|
69
|
+
end
|
70
|
+
|
71
|
+
def album_filter
|
72
|
+
@album_filter ||= Regexp.new(options[:filter])
|
73
|
+
end
|
74
|
+
|
75
|
+
def master_images
|
76
|
+
@master_images ||= value_for_dictionary_key "Master Image List"
|
77
|
+
end
|
78
|
+
|
79
|
+
def root_dictionary
|
80
|
+
@root_dictionary ||= begin
|
81
|
+
file = File.expand_path IPHOTO_ALBUM_PATH
|
82
|
+
doc = Nokogiri.XML(File.read(file))
|
83
|
+
doc.child.children.find {|n| n.name == 'dict' }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe IphotoBackup::CLI do
|
4
|
+
let(:args) { [] }
|
5
|
+
let(:options) { {} }
|
6
|
+
let(:config) do
|
7
|
+
{
|
8
|
+
pretend: true
|
9
|
+
}
|
10
|
+
end
|
11
|
+
let(:cli) { IphotoBackup::CLI.new(args, options, config) }
|
12
|
+
|
13
|
+
describe '#export' do
|
14
|
+
before do
|
15
|
+
cli.export
|
16
|
+
end
|
17
|
+
it 'should run expected commands' do
|
18
|
+
should meet_expectations
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'pry'
|
4
|
+
require 'iphoto_backup/cli'
|
5
|
+
|
6
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
7
|
+
# in spec/support/ and its subdirectories.
|
8
|
+
Dir[File.join(__dir__, "support/**/*.rb")].each { |f| require f }
|
9
|
+
|
10
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
11
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
12
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
13
|
+
# loaded once.
|
14
|
+
#
|
15
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
18
|
+
config.run_all_when_everything_filtered = true
|
19
|
+
config.filter_run :focus
|
20
|
+
|
21
|
+
# Run specs in random order to surface order dependencies. If you find an
|
22
|
+
# order dependency and want to debug it, you can fix the order by providing
|
23
|
+
# the seed, which is printed after each run.
|
24
|
+
# --seed 1234
|
25
|
+
config.order = 'random'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: iphoto_backup
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Sonnek
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
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: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: tool for backing up iPhoto files
|
98
|
+
email:
|
99
|
+
- ryan@codecrate.com
|
100
|
+
executables:
|
101
|
+
- iphoto_backup
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- .gitignore
|
106
|
+
- .rspec
|
107
|
+
- .ruby-version
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- bin/iphoto_backup
|
113
|
+
- iphoto_backup.gemspec
|
114
|
+
- lib/iphoto_backup.rb
|
115
|
+
- lib/iphoto_backup/cli.rb
|
116
|
+
- lib/iphoto_backup/version.rb
|
117
|
+
- spec/lib/iphoto_backup/cli_spec.rb
|
118
|
+
- spec/spec_helper.rb
|
119
|
+
- spec/support/meet_expectations_matcher.rb
|
120
|
+
homepage: ''
|
121
|
+
licenses:
|
122
|
+
- MIT
|
123
|
+
metadata: {}
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 2.0.14
|
141
|
+
signing_key:
|
142
|
+
specification_version: 4
|
143
|
+
summary: copy files out of iPhoto into a backup directory
|
144
|
+
test_files:
|
145
|
+
- spec/lib/iphoto_backup/cli_spec.rb
|
146
|
+
- spec/spec_helper.rb
|
147
|
+
- spec/support/meet_expectations_matcher.rb
|