Module: FlickRaw

Defined in:
lib/flickraw.rb,
lib/flickraw/api.rb,
lib/flickraw/error.rb,
lib/flickraw/oauth.rb,
lib/flickraw/request.rb,
lib/flickraw/response.rb

Defined Under Namespace

Classes: Error, FailedResponse, Flickr, FlickrAppNotConfigured, OAuthClient, Request, Response, ResponseList

Constant Summary collapse

VERSION =
'0.9.8'
USER_AGENT =
"FlickRaw/#{VERSION}"
END_POINT =
'http://api.flickr.com/services'.freeze
END_POINT2 =
'http://www.flickr.com/services'.freeze
END_POINT_SECURE =
'https://api.flickr.com/services'.freeze
FLICKR_OAUTH_REQUEST_TOKEN =
(END_POINT2 + '/oauth/request_token').freeze
FLICKR_OAUTH_AUTHORIZE =
(END_POINT2 + '/oauth/authorize').freeze
FLICKR_OAUTH_ACCESS_TOKEN =
(END_POINT2 + '/oauth/access_token').freeze
FLICKR_OAUTH_REQUEST_TOKEN_SECURE =
(END_POINT_SECURE + '/oauth/request_token').freeze
FLICKR_OAUTH_AUTHORIZE_SECURE =
(END_POINT_SECURE + '/oauth/authorize').freeze
FLICKR_OAUTH_ACCESS_TOKEN_SECURE =
(END_POINT_SECURE + '/oauth/access_token').freeze
REST_PATH =
(END_POINT + '/rest/').freeze
UPLOAD_PATH =
(END_POINT + '/upload/').freeze
REPLACE_PATH =
(END_POINT + '/replace/').freeze
REST_PATH_SECURE =
(END_POINT_SECURE + '/rest/').freeze
UPLOAD_PATH_SECURE =
(END_POINT_SECURE + '/upload/').freeze
REPLACE_PATH_SECURE =
(END_POINT_SECURE + '/replace/').freeze
PHOTO_SOURCE_URL =
'https://farm%s.staticflickr.com/%s/%s_%s%s.%s'.freeze
URL_PROFILE =
'https://www.flickr.com/people/'.freeze
URL_PHOTOSTREAM =
'https://www.flickr.com/photos/'.freeze
URL_SHORT =
'https://flic.kr/p/'.freeze
BASE58_ALPHABET =
"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ".freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Your flickr API key, see www.flickr.com/services/api/keys for more information


160
161
162
# File 'lib/flickraw/api.rb', line 160

def api_key
  @api_key
end

.ca_fileObject

Set path of a CA certificate file in PEM format (ssl connection only)


175
176
177
# File 'lib/flickraw/api.rb', line 175

def ca_file
  @ca_file
end

.ca_pathObject

Set path to a directory of CA certificate files in PEM format (ssl connection only)


178
179
180
# File 'lib/flickraw/api.rb', line 178

def ca_path
  @ca_path
end

.check_certificateObject

Check the server certificate (ssl connection only)


172
173
174
# File 'lib/flickraw/api.rb', line 172

def check_certificate
  @check_certificate
end

.proxyObject

Use a proxy


166
167
168
# File 'lib/flickraw/api.rb', line 166

def proxy
  @proxy
end

.secureObject

Use ssl connection


169
170
171
# File 'lib/flickraw/api.rb', line 169

def secure
  @secure
end

.shared_secretObject

The shared secret of api_key, see www.flickr.com/services/api/keys for more information


163
164
165
# File 'lib/flickraw/api.rb', line 163

def shared_secret
  @shared_secret
end

Class Method Details

.base58(id) ⇒ Object


181
182
183
184
185
186
187
188
189
190
# File 'lib/flickraw/api.rb', line 181

def base58(id)
  id = id.to_i
  alphabet = BASE58_ALPHABET.split(//)
  base = alphabet.length
  begin
    id, m = id.divmod(base)
    r = alphabet[m] + (r || '')
  end while id > 0
  r
end

.url(r) ⇒ Object


192
# File 'lib/flickraw/api.rb', line 192

def url(r);   PHOTO_SOURCE_URL % [r.farm, r.server, r.id, r.secret, "",   "jpg"]   end

.url_b(r) ⇒ Object


196
# File 'lib/flickraw/api.rb', line 196

def url_b(r); PHOTO_SOURCE_URL % [r.farm, r.server, r.id, r.secret, "_b", "jpg"] end

.url_c(r) ⇒ Object


200
# File 'lib/flickraw/api.rb', line 200

def url_c(r); PHOTO_SOURCE_URL % [r.farm, r.server, r.id, r.secret, "_c", "jpg"] end

.url_m(r) ⇒ Object


193
# File 'lib/flickraw/api.rb', line 193

def url_m(r); PHOTO_SOURCE_URL % [r.farm, r.server, r.id, r.secret, "_m", "jpg"] end

.url_n(r) ⇒ Object


199
# File 'lib/flickraw/api.rb', line 199

def url_n(r); PHOTO_SOURCE_URL % [r.farm, r.server, r.id, r.secret, "_n", "jpg"] end

.url_o(r) ⇒ Object


201
# File 'lib/flickraw/api.rb', line 201

def url_o(r); PHOTO_SOURCE_URL % [r.farm, r.server, r.id, r.originalsecret, "_o", r.originalformat] end

.url_photopage(r) ⇒ Object


203
# File 'lib/flickraw/api.rb', line 203

def url_photopage(r); url_photostream(r) + r.id end

.url_photoset(r) ⇒ Object


205
# File 'lib/flickraw/api.rb', line 205

def url_photoset(r); url_photosets(r) + r.id end

.url_photosets(r) ⇒ Object


204
# File 'lib/flickraw/api.rb', line 204

def url_photosets(r); url_photostream(r) + "sets/" end

.url_photostream(r) ⇒ Object


212
213
214
215
216
217
218
219
220
221
# File 'lib/flickraw/api.rb', line 212

def url_photostream(r)
  URL_PHOTOSTREAM +
    if r.respond_to?(:pathalias) and r.pathalias
      r.pathalias
    elsif r.owner.respond_to?(:nsid)
      r.owner.nsid
    else
      r.owner
    end + "/"
end

.url_profile(r) ⇒ Object


202
# File 'lib/flickraw/api.rb', line 202

def url_profile(r); URL_PROFILE + (r.owner.respond_to?(:nsid) ? r.owner.nsid : r.owner) + "/" end

.url_q(r) ⇒ Object


198
# File 'lib/flickraw/api.rb', line 198

def url_q(r); PHOTO_SOURCE_URL % [r.farm, r.server, r.id, r.secret, "_q", "jpg"] end

.url_s(r) ⇒ Object


194
# File 'lib/flickraw/api.rb', line 194

def url_s(r); PHOTO_SOURCE_URL % [r.farm, r.server, r.id, r.secret, "_s", "jpg"] end

.url_short(r) ⇒ Object


206
# File 'lib/flickraw/api.rb', line 206

def url_short(r); URL_SHORT + base58(r.id) end

.url_short_m(r) ⇒ Object


207
# File 'lib/flickraw/api.rb', line 207

def url_short_m(r); URL_SHORT + "img/" + base58(r.id) + "_m.jpg" end

.url_short_n(r) ⇒ Object


211
# File 'lib/flickraw/api.rb', line 211

def url_short_n(r); URL_SHORT + "img/" + base58(r.id) + "_n.jpg" end

.url_short_q(r) ⇒ Object


210
# File 'lib/flickraw/api.rb', line 210

def url_short_q(r); URL_SHORT + "img/" + base58(r.id) + "_q.jpg" end

.url_short_s(r) ⇒ Object


208
# File 'lib/flickraw/api.rb', line 208

def url_short_s(r); URL_SHORT + "img/" + base58(r.id) + ".jpg" end

.url_short_t(r) ⇒ Object


209
# File 'lib/flickraw/api.rb', line 209

def url_short_t(r); URL_SHORT + "img/" + base58(r.id) + "_t.jpg" end

.url_t(r) ⇒ Object


195
# File 'lib/flickraw/api.rb', line 195

def url_t(r); PHOTO_SOURCE_URL % [r.farm, r.server, r.id, r.secret, "_t", "jpg"] end

.url_z(r) ⇒ Object


197
# File 'lib/flickraw/api.rb', line 197

def url_z(r); PHOTO_SOURCE_URL % [r.farm, r.server, r.id, r.secret, "_z", "jpg"] end