shrine-flickr 1.1.0 → 1.2.0

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
  SHA1:
3
- metadata.gz: 2a9b6f05a35d4800a0487a80a75442d07ff13ca1
4
- data.tar.gz: 067eb45830f966d722c48b53008d8bc6b0152854
3
+ metadata.gz: 5033c4e43af4a59e75d0daecec024a3d4cc326ef
4
+ data.tar.gz: 56f5e6f21361b16718530bc06264322b1dc95b17
5
5
  SHA512:
6
- metadata.gz: d4f4925219258f513686fc6ddbdbf956e835cd12245fe63fd52fff101855a53f547de779a4ed78d19a4a2530ed7cf91e9614f1ea9aff4c1bfe5c7652e0df756b
7
- data.tar.gz: 0f2dbd8b9564526d7918f734fa7ce65c6506c5bbeabd18995038b7a10fc7c265d44b5cea766f66825e16ff45172273cec633952e6d6c904f196a206bfc5a4671
6
+ metadata.gz: 6ddc342ea1686e004e30935a9bef11863d66ecb43fef7009450275fcc6acbd829ed62660943b55e8862b02d5839ab51ed80c5886302f01feb2369b92394a8db8
7
+ data.tar.gz: 07bcb095e9bc6b3a426775a3a1c2aaa342b3ab5cdb4af32c15ef0c5f4a1f3e8dbee779918f443c05923d3775a93303868307d2632bb30fd2075c238cbacab3ee
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # Shrine::Storage::Flickr
2
2
 
3
- Provides [Flickr] storage for [Shrine]. Flickr is a photo sharing service which
4
- automatically generates different sizes of uploaded photos.
3
+ Provides [Flickr] storage for [Shrine].
4
+
5
+ Flickr is a photo sharing service which automatically generates different sizes
6
+ of uploaded photos.
5
7
 
6
8
  ## Installation
7
9
 
@@ -78,6 +80,48 @@ class MyUploader < Shrine
78
80
  end
79
81
  ```
80
82
 
83
+ ### Storing info
84
+
85
+ After photo is uploaded, additional information about the photo are requested
86
+ from Flickr, in order to generate the ID. If you want to save those information
87
+ to metadata, you can set `:store_info`:
88
+
89
+ ```rb
90
+ Shrine::Storage::Flickr.new(store_info: true, **flickr_options)
91
+ ```
92
+ ```rb
93
+ photo = Photo.create(image: image_file)
94
+ photo.image.metadata["flickr"] #=>
95
+ # {
96
+ # "id" => "27169370821",
97
+ # "secret" => "ab85ddef07",
98
+ # "server" => "7754",
99
+ # "farm" => 8,
100
+ # "dateuploaded" => "1464170485",
101
+ # "rotation" => 0,
102
+ # "originalsecret" => "e77ebc5126",
103
+ # "originalformat" => "jpg",
104
+ # "owner" => {
105
+ # "nsid" => "78733179@N04",
106
+ # "username" => "@janko-m",
107
+ # "realname" => "Janko Marohnić",
108
+ # "location" => "Zagreb, Croatia",
109
+ # "iconserver" => "8033",
110
+ # "iconfarm" => 9,
111
+ # "path_alias" => nil
112
+ # },
113
+ # "title" => {"_content"=>"image"},
114
+ # "description" => {"_content"=>""},
115
+ # "dates" => {
116
+ # "posted" => "1464170485",
117
+ # "taken" => "2016-05-25 12:01:25",
118
+ # "takengranularity" => 0,
119
+ # "takenunknown" => "1",
120
+ # "lastupdate" => "1464170486"
121
+ # },
122
+ # }
123
+ ```
124
+
81
125
  ### Updating
82
126
 
83
127
  If you want to update the title and description of the photo, you can use the
@@ -9,10 +9,11 @@ class Shrine
9
9
  class Flickr
10
10
  attr_reader :person, :flickr, :upload_options, :album
11
11
 
12
- def initialize(user:, access_token:, album: nil, upload_options: {})
12
+ def initialize(user:, access_token:, album: nil, upload_options: {}, store_info: nil)
13
13
  @flickr = ::Flickr.new(*access_token)
14
14
  @person = @flickr.people.find(user)
15
15
  @upload_options = upload_options
16
+ @store_info = store_info
16
17
  @album = @flickr.sets.find(album) if album
17
18
  end
18
19
 
@@ -25,7 +26,8 @@ class Shrine
25
26
  album.add_photo(photo_id) if album
26
27
 
27
28
  photo = photo(photo_id).get_info!
28
- id.replace(generate_id(photo))
29
+ update_id!(photo, id)
30
+ update_metadata!(photo, shrine_metadata)
29
31
 
30
32
  photo.attributes
31
33
  end
@@ -103,9 +105,13 @@ class Shrine
103
105
  end
104
106
  end
105
107
 
106
- def generate_id(photo)
107
- "#{photo.farm}-#{photo.server}-#{photo.id}-#{photo.secret}" \
108
- "-#{photo["originalsecret"]}.#{photo["originalformat"]}"
108
+ def update_id!(photo, id)
109
+ info_id = "#{photo.farm}-#{photo.server}-#{photo.id}-#{photo.secret}-#{photo["originalsecret"]}.#{photo["originalformat"]}"
110
+ id.replace(info_id)
111
+ end
112
+
113
+ def update_metadata!(photo, metadata)
114
+ metadata["flickr"] = photo.attributes if @store_info
109
115
  end
110
116
 
111
117
  def photo_id(id)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "shrine-flickr"
3
- gem.version = "1.1.0"
3
+ gem.version = "1.2.0"
4
4
 
5
5
  gem.required_ruby_version = ">= 2.1"
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shrine-flickr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-19 00:00:00.000000000 Z
11
+ date: 2016-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shrine