photo-helper 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/photo-helper/delete.rb +4 -4
- data/lib/photo-helper/smugmug.rb +46 -8
- data/lib/photo-helper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10d2b80093609775220a8b4055332e15afd40f95b43e7288546bf2aa7a3a44ba
|
4
|
+
data.tar.gz: 9b9985e0f5b79c92dc18f9f691340c39430df4846f3854b411058b87b798f89c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef04dbd4813b95654bf4ef9a8fee46ca5501ccdf10de91dd4bb9d3f676ffa4fe59c3be0a508366d03f41379ae1043c4c09ebf3a3cbdd3ef74ddadbf8cbe1dc2a
|
7
|
+
data.tar.gz: 8ef495f06581f0b2691e91d94543a85f9eddd1db471951744cf12f794afef890cfbd05e1eb915f718b24952e3d076d2d20dd322d14c59a36cd4f9b673d6ce4a6
|
data/Gemfile.lock
CHANGED
data/lib/photo-helper/delete.rb
CHANGED
@@ -12,7 +12,7 @@ module PhotoHelper
|
|
12
12
|
|
13
13
|
desc 'jpeg', 'delete jpegs that have an raw with same name'
|
14
14
|
method_option :folder, aliases: '-f', type: :string, default: '.'
|
15
|
-
method_option :
|
15
|
+
method_option :'soft-delete', aliases: '-s', type: :boolean, default: true
|
16
16
|
method_option :recursive, aliases: '-r', type: :boolean, default: false
|
17
17
|
def jpeg(folder = nil)
|
18
18
|
folder ||= options[:folder]
|
@@ -38,10 +38,10 @@ module PhotoHelper
|
|
38
38
|
next if FileHelper.ingore_file?(file)
|
39
39
|
puts file
|
40
40
|
|
41
|
-
if options[:
|
42
|
-
File.delete(file)
|
43
|
-
else
|
41
|
+
if options[:softdelete]
|
44
42
|
File.trash(file)
|
43
|
+
else
|
44
|
+
File.delete(file)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
data/lib/photo-helper/smugmug.rb
CHANGED
@@ -37,22 +37,60 @@ module PhotoHelper
|
|
37
37
|
|
38
38
|
desc 'albums', 'list albums with their weburl'
|
39
39
|
def albums
|
40
|
+
require 'pp'
|
41
|
+
|
40
42
|
@smugmug = SmugmugAPI.new
|
41
43
|
albums = @smugmug.albums_long
|
42
44
|
|
43
|
-
|
44
|
-
output = [
|
45
|
+
albums_tree = {}
|
46
|
+
output = ["# Photos"]
|
45
47
|
|
46
48
|
albums.each do |a|
|
47
|
-
|
48
|
-
next
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
parts = a[:path].split('/')
|
50
|
+
next if parts[0] == "Trash"
|
51
|
+
|
52
|
+
album_name = parts.pop
|
53
|
+
parts.each_with_index do |part, i|
|
54
|
+
if i == 0
|
55
|
+
albums_tree[part] ||= {}
|
56
|
+
else
|
57
|
+
parts[0..(i - 1)].inject(albums_tree, :fetch)[part] ||= {}
|
58
|
+
end
|
52
59
|
end
|
53
|
-
|
60
|
+
|
61
|
+
parts[0..-1].inject(albums_tree, :fetch)[album_name] = "[#{a[:name]}](#{a[:web_uri]})"
|
54
62
|
end
|
55
63
|
|
64
|
+
# depth first search
|
65
|
+
stack = albums_tree.keys.map { |a| [a] }
|
66
|
+
stack.sort_by! do |key|
|
67
|
+
next key.first.to_i if key.first =~ /^\d+$/
|
68
|
+
next Float::INFINITY
|
69
|
+
end
|
70
|
+
|
71
|
+
pp stack
|
72
|
+
|
73
|
+
until stack.empty?
|
74
|
+
key = stack.pop
|
75
|
+
item = key.inject(albums_tree, :fetch)
|
76
|
+
next if key.first == "dl"
|
77
|
+
|
78
|
+
if item.is_a?(Hash)
|
79
|
+
stack.concat(item.keys.map{|a| key.clone.push(a)})
|
80
|
+
output.push("#{'#'*key.count} #{key.last}")
|
81
|
+
next
|
82
|
+
end
|
83
|
+
|
84
|
+
begin
|
85
|
+
dl_item = ["dl"].concat(key).inject(albums_tree, :fetch)
|
86
|
+
output.push(" **Selects: ** #{item}\n **All: ** #{dl_item}")
|
87
|
+
rescue
|
88
|
+
output.push(item)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# pp albums_tree
|
93
|
+
|
56
94
|
puts output.join("\n\n")
|
57
95
|
end
|
58
96
|
end
|
data/lib/photo-helper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: photo-helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Caldwell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|