aperture 0.3.2 → 0.3.3
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.
- data/CHANGELOG +12 -0
- data/VERSION +1 -1
- data/aperture.gemspec +3 -2
- data/lib/aperture/library.rb +51 -7
- metadata +3 -2
data/CHANGELOG
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
== 0.3.3 / 2009-12-20
|
2
|
+
* Added verbose output on Library#parse, optional dependency on ruby-progressbar
|
3
|
+
|
4
|
+
== 0.3.2 / 2009-12-16
|
5
|
+
* Added plist dependency to gemspec
|
6
|
+
* Added find_by_keyword to PhotoSet
|
7
|
+
|
8
|
+
== 0.3.1 / 2009-12-16
|
9
|
+
* Updated rdocs
|
10
|
+
|
11
|
+
== 0.3.0 / 2008-12-16
|
12
|
+
* First public release
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.3
|
data/aperture.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{aperture}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kyle Burckhard"]
|
12
|
-
s.date = %q{2009-12-
|
12
|
+
s.date = %q{2009-12-20}
|
13
13
|
s.description = %q{Parses out the files from a Aperture Photo Library to give useful figures and check consistancy of the Library itself.}
|
14
14
|
s.email = %q{kyle.burckhard@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
21
|
".gitignore",
|
22
|
+
"CHANGELOG",
|
22
23
|
"LICENSE",
|
23
24
|
"README.rdoc",
|
24
25
|
"Rakefile",
|
data/lib/aperture/library.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
require 'find'
|
2
|
+
begin
|
3
|
+
require 'progressbar'
|
4
|
+
rescue LoadError
|
5
|
+
end
|
2
6
|
|
3
7
|
module Aperture
|
4
8
|
|
@@ -7,7 +11,9 @@ module Aperture
|
|
7
11
|
# photo library. From the object you can access information about the Versions, Photos,
|
8
12
|
# Albums and Projects contained in the Library.
|
9
13
|
#
|
10
|
-
#
|
14
|
+
# There is an optional second argument for parse the enable more verbose output.
|
15
|
+
#
|
16
|
+
# *Note:* Depending on the size of the Aperture photo library parsing it into ruby objects
|
11
17
|
# may take serveral minutes.
|
12
18
|
class Library
|
13
19
|
attr_reader :root, :photos, :albums, :projects, :versions
|
@@ -23,36 +29,67 @@ module Aperture
|
|
23
29
|
|
24
30
|
# This the key method for parsing the library, it requires the path of where the library
|
25
31
|
# exists on disk. It returns a fully parsed Library object.
|
26
|
-
|
32
|
+
# The second arugment makes the method give more verbose output while it is processing.
|
33
|
+
# Using the ProgressBar gem, to install use: <tt>[sudo] gem install ruby-progressbar</tt>
|
34
|
+
#
|
35
|
+
# http://github.com/nex3/ruby-progressbar
|
36
|
+
def self.parse(root_path, verbose=false)
|
27
37
|
library = new(root_path)
|
38
|
+
pb = nil
|
28
39
|
files = []
|
40
|
+
|
41
|
+
if verbose
|
42
|
+
print "Finding metadata files in library: "
|
43
|
+
st = Time.now
|
44
|
+
end
|
45
|
+
|
29
46
|
Find.find(library.root) do |path|
|
30
47
|
files << path
|
31
48
|
end
|
32
49
|
|
50
|
+
puts "#{(Time.now - st)} seconds"
|
51
|
+
|
33
52
|
# Projects
|
34
|
-
files.select {|p| p =~ /\.approject$/ }
|
53
|
+
files_projects = files.select {|p| p =~ /\.approject$/ }
|
54
|
+
# puts files_projects.size
|
55
|
+
pb = ProgressBar.new("projects", files_projects.size) if defined?(ProgressBar) && verbose
|
56
|
+
files_projects.each do |path|
|
35
57
|
project = Project.new
|
36
58
|
project.attributes = Plist::parse_xml(File.join(path, 'Info.apfolder'))
|
37
59
|
library.projects[project.attributes['uuid']] = project
|
60
|
+
pb.inc if pb
|
38
61
|
end
|
62
|
+
pb.finish if pb
|
39
63
|
|
40
64
|
# Photo Masters
|
41
|
-
files.select {|p| p =~ /Info\.apmaster$/}
|
65
|
+
files_masters = files.select {|p| p =~ /Info\.apmaster$/}
|
66
|
+
# puts files_masters.size
|
67
|
+
pb = ProgressBar.new("photo masters", files_masters.size) if defined?(ProgressBar) && verbose
|
68
|
+
files_masters.each do |path|
|
42
69
|
photo = Photo.new(File.dirname(path))
|
43
70
|
photo.master_attributes = Plist::parse_xml(path)
|
44
71
|
photo.master_attributes['path']
|
45
72
|
library.photos << photo
|
73
|
+
pb.inc if pb
|
46
74
|
end
|
75
|
+
pb.finish if pb
|
47
76
|
|
48
77
|
# Photo Files
|
49
|
-
files.select {|p| p =~ /\.apfile$/}
|
78
|
+
files_files = files.select {|p| p =~ /\.apfile$/}
|
79
|
+
# puts files_files.size
|
80
|
+
pb = ProgressBar.new("photo files", files_files.size) if defined?(ProgressBar) && verbose
|
81
|
+
files_files.each do |path|
|
50
82
|
file_attributes = Plist::parse_xml(path)
|
51
83
|
library.photos[file_attributes['masterUuid']].file_attributes = file_attributes
|
84
|
+
pb.inc if pb
|
52
85
|
end
|
86
|
+
pb.finish if pb
|
53
87
|
|
54
88
|
# Versions
|
55
|
-
files.select {|p| p =~ /Version-.+\.apversion$/}
|
89
|
+
files_versions = files.select {|p| p =~ /Version-.+\.apversion$/}
|
90
|
+
# puts files_versions.size
|
91
|
+
pb = ProgressBar.new("versions", files_projects.size) if defined?(ProgressBar) && verbose
|
92
|
+
files_versions.each do |path|
|
56
93
|
directory, filename = File.dirname(path), File.basename(path)
|
57
94
|
attributes = Plist::parse_xml(path)
|
58
95
|
|
@@ -70,10 +107,15 @@ module Aperture
|
|
70
107
|
|
71
108
|
# add version's photo to project
|
72
109
|
library.projects[version.attributes['projectUuid']].photos << version.photo
|
110
|
+
pb.inc if pb
|
73
111
|
end
|
112
|
+
pb.finish if pb
|
74
113
|
|
75
114
|
# Albums
|
76
|
-
files.select {|p| p =~ /\.apalbum/ }
|
115
|
+
files_albums = files.select {|p| p =~ /\.apalbum/ }
|
116
|
+
# puts files_albums.size
|
117
|
+
pb = ProgressBar.new("albums", files_albums.size) if defined?(ProgressBar) && verbose
|
118
|
+
files_albums.each do |path|
|
77
119
|
attributes = Plist::parse_xml(path)
|
78
120
|
attributes['directory'] = File.dirname(path)
|
79
121
|
attributes['filename'] = File.basename(path)
|
@@ -87,7 +129,9 @@ module Aperture
|
|
87
129
|
library.versions[id].photo.albums << album unless library.versions[id].photo.albums.include?(album)
|
88
130
|
end
|
89
131
|
end
|
132
|
+
pb.inc if pb
|
90
133
|
end
|
134
|
+
pb.finish if pb
|
91
135
|
|
92
136
|
return library
|
93
137
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aperture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Burckhard
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-20 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -34,6 +34,7 @@ extra_rdoc_files:
|
|
34
34
|
files:
|
35
35
|
- .document
|
36
36
|
- .gitignore
|
37
|
+
- CHANGELOG
|
37
38
|
- LICENSE
|
38
39
|
- README.rdoc
|
39
40
|
- Rakefile
|