grin 0.9.1 → 0.9.2

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.
@@ -27,5 +27,13 @@ module Grin
27
27
  post("albums/#{id}/photos.json", { :photo => { :image => image_data } })
28
28
  end
29
29
 
30
+ def find_or_create_photo(filename, image_data)
31
+ if photo = photos.select { |p| p.filename == filename }.pop
32
+ return photo
33
+ else
34
+ create_photo(image_data)
35
+ end
36
+ end
37
+
30
38
  end
31
39
  end
@@ -26,6 +26,14 @@ module Grin
26
26
  end
27
27
  end
28
28
 
29
+ def find_or_create_album(title, category_id = nil)
30
+ if album = albums.select { |a| a.title == title }.pop
31
+ return album
32
+ else
33
+ create_album(title, category_id)
34
+ end
35
+ end
36
+
29
37
  private
30
38
 
31
39
  def get(path)
@@ -2,14 +2,16 @@ require 'rubygems'
2
2
  require 'grin'
3
3
  require 'smirk'
4
4
 
5
- smug = Smirk::Client.new("teamwylie@hotmail.com", "carter")
6
- smug_album = smug.find_album(id, key)
7
- smug_album.images(true).each do |image|
8
- `curl #{image.originalurl} -o #{image.filename}`
9
- end
5
+ # smug = Smirk::Client.new("teamwylie@hotmail.com", "carter")
6
+ # smug_album = smug.find_album(id, key)
7
+ # smug_album.images(true).each do |image|
8
+ # `curl #{image.originalurl} -o #{image.filename}`
9
+ # end
10
10
 
11
11
  fotogger = Grin::Client.new("amp", "witty@bensie.com", "littlebuddy")
12
12
  #album = fotogger.create_album("Test")
13
- album = fotogger.album(15)
13
+ #album = fotogger.album(15)
14
+ puts fotogger.find_or_create_album("Dorman Family").inspect
15
+ #puts fotogger.albums.select { |a| a.title == "Dorman Family"}.pop.inspect
14
16
 
15
- puts album.create_photo(File.open("/Users/jkmiller/Desktop/Rome/Italy 2010-8157.jpg"))
17
+ #puts album.create_photo(File.open("/Users/jkmiller/Desktop/Rome/Italy 2010-8157.jpg"))
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grin
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
4
+ hash: 63
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 1
10
- version: 0.9.1
9
+ - 2
10
+ version: 0.9.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Miller
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-14 00:00:00 -07:00
18
+ date: 2010-07-16 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency