lentil 0.2.1 → 0.2.2

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: 1eedb412866c22824ea3454b1988e1e1ad5d7511
4
- data.tar.gz: 7637990fc33cec6f64cad9150cda02b138e6f9ed
3
+ metadata.gz: 1c1b643648b334074ffad7cf8fa4a4c43da2349e
4
+ data.tar.gz: 4dd47933ed6539c5e3f713799a40de83f07af2c6
5
5
  SHA512:
6
- metadata.gz: c565046bd60a22dc4712e0d9c7ad18892fb438ab5771647bfc469c3825558157091d009a638dd6c69e6f0280cfa36ee9d93ae3ae933b19f8a6ea90e88e9f5df2
7
- data.tar.gz: a5a6463f9281ea17e9b85dc7f3f78b945171f6bb47a526cdc45228ed5f49bf07a9b0f8ececa91fd0852028a79566b6e7d18b578e8de86aab540b1a59dd18c80d
6
+ metadata.gz: 279aafee90f754a2506770cabec444429e59427dc74a59fa71902b2316f5c07e454a716380c888cec641cf07537ed8703aacdc6c7588ecf9df07214d5260bf99
7
+ data.tar.gz: df60455eee158f1520ae8383a71129be50a37cee7e62a4e20ca6880bfc40d24e6cf61f52bbc3a74ccb9a446a59761946775d6a2bc6e1b5054d9bb770a4221e49
@@ -154,16 +154,28 @@ class Lentil::Image < ActiveRecord::Base
154
154
  url.sub(/^http:/, '').sub(/\/\/instagr\.am/, '//instagram.com')
155
155
  end
156
156
 
157
- def large_url
158
- protocol_relative_url + 'media/?size=l'
157
+ def large_url(protocol_relative = true)
158
+ if protocol_relative
159
+ protocol_relative_url + 'media/?size=l'
160
+ else
161
+ url + 'media/?size=l'
162
+ end
159
163
  end
160
164
 
161
- def medium_url
162
- protocol_relative_url + 'media/?size=m'
165
+ def medium_url(protocol_relative = true)
166
+ if protocol_relative
167
+ protocol_relative_url + 'media/?size=m'
168
+ else
169
+ url + 'media/?size=m'
170
+ end
163
171
  end
164
172
 
165
- def thumbnail_url
166
- protocol_relative_url + 'media/?size=t'
173
+ def thumbnail_url(protocol_relative = true)
174
+ if protocol_relative
175
+ protocol_relative_url + 'media/?size=t'
176
+ else
177
+ url + 'media/?size=t'
178
+ end
167
179
  end
168
180
 
169
181
  States = {
@@ -54,6 +54,30 @@ module Lentil
54
54
  Instagram.tag_recent_media(tag, :count=>100)
55
55
  end
56
56
 
57
+ def fetch_recent_images_by_tag_with_args(tag = nil, args = {:count=>100})
58
+ configure_connection
59
+ tag ||= Lentil::Engine::APP_CONFIG["default_image_search_tag"]
60
+ Instagram.tag_recent_media(tag, args)
61
+ end
62
+
63
+ def recursive_fetch(tag=nil, max_tag_id=nil, total=0)
64
+ case max_tag_id
65
+ when nil
66
+ instagram_metadata = fetch_recent_images_by_tag_with_args(tag)
67
+ else
68
+ instagram_metadata = fetch_recent_images_by_tag_with_args(tag, {:max_tag_id=>max_tag_id})
69
+ end
70
+ total += save_instagram_load(instagram_metadata).size
71
+ next_max_id = instagram_metadata.pagination.next_max_id
72
+ case next_max_id
73
+ when nil
74
+ puts "nil next_max_id. Previous next_max_id: " + max_tag_id.to_s
75
+ else
76
+ subtotal = recursive_fetch(tag, next_max_id, total)
77
+ total += subtotal.nil? ? 0 : subtotal
78
+ end
79
+ total
80
+ end
57
81
 
58
82
  # Queries the Instagram API for the image metadata associated with a given ID.
59
83
  #
@@ -202,7 +226,7 @@ module Lentil
202
226
  #
203
227
  # @return [String] Binary image data
204
228
  def harvest_image_data(image)
205
- response = Typhoeus.get(image.large_url, followlocation: true)
229
+ response = Typhoeus.get(image.large_url(false), followlocation: true)
206
230
 
207
231
  if response.success?
208
232
  raise "Invalid content type: " + response.headers['Content-Type'] unless (response.headers['Content-Type'] == 'image/jpeg')
@@ -226,7 +250,7 @@ module Lentil
226
250
  #
227
251
  # @return [Boolean] Whether the image request was successful
228
252
  def test_remote_image(image)
229
- response = Typhoeus.get(image.thumbnail_url, followlocation: true)
253
+ response = Typhoeus.get(image.thumbnail_url(false), followlocation: true)
230
254
 
231
255
  if response.success?
232
256
  true
@@ -1,3 +1,3 @@
1
1
  module Lentil
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lentil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Casden
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-04-29 00:00:00.000000000 Z
14
+ date: 2014-05-27 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rails
@@ -19,14 +19,14 @@ dependencies:
19
19
  requirements:
20
20
  - - "~>"
21
21
  - !ruby/object:Gem::Version
22
- version: 3.2.17
22
+ version: 3.2.18
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: 3.2.17
29
+ version: 3.2.18
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: jquery-rails
32
32
  requirement: !ruby/object:Gem::Requirement