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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0feaba25fffb7634e816f16e80f11666cd6b18add7654d49cbd94bee690038ff
4
- data.tar.gz: 6b76c47719929fe25c68373585ce2365a6d8b8e25606e4f3985e5ac8c1016f53
3
+ metadata.gz: 10d2b80093609775220a8b4055332e15afd40f95b43e7288546bf2aa7a3a44ba
4
+ data.tar.gz: 9b9985e0f5b79c92dc18f9f691340c39430df4846f3854b411058b87b798f89c
5
5
  SHA512:
6
- metadata.gz: e8051f0f5b37c43c75ecf88efffa7aa6e0aaecd10c699e1f596472b3372e87634348468e1241f935684d4b43bcc437f4c769f8c78a2980507c890a0720192d3b
7
- data.tar.gz: de34bb8a932d4714c830447655f9563817c4500705dd37360952a0f9f6f1fe0d912351d42fece858afbe71eaa4f76d89bb2f3274b6a09dbe043900ddf6d5a5f0
6
+ metadata.gz: ef04dbd4813b95654bf4ef9a8fee46ca5501ccdf10de91dd4bb9d3f676ffa4fe59c3be0a508366d03f41379ae1043c4c09ebf3a3cbdd3ef74ddadbf8cbe1dc2a
7
+ data.tar.gz: 8ef495f06581f0b2691e91d94543a85f9eddd1db471951744cf12f794afef890cfbd05e1eb915f718b24952e3d076d2d20dd322d14c59a36cd4f9b673d6ce4a6
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- photo-helper (0.5.2)
4
+ photo-helper (0.5.3)
5
5
  ejson
6
6
  mimemagic
7
7
  mini_magick
@@ -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 :hard, aliases: '-h', type: :boolean, default: false
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[:hard]
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
 
@@ -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
- current_month = albums.first[:path].split('/')[1]
44
- output = ['# Photos', "## #{current_month}"]
45
+ albums_tree = {}
46
+ output = ["# Photos"]
45
47
 
46
48
  albums.each do |a|
47
- month = a[:path].split('/')[1]
48
- next unless month
49
- if month != current_month
50
- current_month = month
51
- output.push("## #{current_month}")
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
- output.push("[#{a[:name]}](#{a[:web_uri].gsub('http://', 'https://')})")
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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module PhotoHelper
3
- VERSION = '0.5.2'
3
+ VERSION = '0.5.3'
4
4
  end
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.2
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-19 00:00:00.000000000 Z
11
+ date: 2018-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler