grabz_it 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/grabz_it.rb +6 -0
- data/lib/grabz_it/client.rb +29 -0
- data/lib/grabz_it/image.rb +4 -0
- data/lib/grabz_it/version.rb +1 -1
- metadata +2 -2
data/lib/grabz_it.rb
CHANGED
data/lib/grabz_it/client.rb
CHANGED
@@ -16,6 +16,11 @@ module GrabzIt
|
|
16
16
|
def initialize(app_key, app_secret)
|
17
17
|
@app_key = app_key
|
18
18
|
@app_secret = app_secret
|
19
|
+
|
20
|
+
if GrabzIt.logger
|
21
|
+
GrabzIt.logger.info "Initialized client with [#{app_key}] and [#{app_secret}]"
|
22
|
+
end
|
23
|
+
|
19
24
|
raise(ArgumentError, "You must provide app_key and app_secret") unless @app_key && @app_secret
|
20
25
|
end
|
21
26
|
|
@@ -66,6 +71,11 @@ module GrabzIt
|
|
66
71
|
elsif status.available?
|
67
72
|
image = get_picture(response.screenshot_id)
|
68
73
|
image.save(target_path)
|
74
|
+
|
75
|
+
if GrabzIt.logger
|
76
|
+
GrabzIt.logger.info "[Client][save_picture] Image was created with screenshot_id of [#{image.screenshot_id}]"
|
77
|
+
end
|
78
|
+
|
69
79
|
break
|
70
80
|
end
|
71
81
|
|
@@ -73,6 +83,9 @@ module GrabzIt
|
|
73
83
|
if iterations <= (5 * 60)
|
74
84
|
sleep(1)
|
75
85
|
else
|
86
|
+
if GrabzIt.logger
|
87
|
+
GrabzIt.logger.error "[Client][save_picture] Attempting to retrieve the screenshot timed out after 5 minutes"
|
88
|
+
end
|
76
89
|
raise Timeout::Error
|
77
90
|
end
|
78
91
|
end
|
@@ -115,6 +128,10 @@ module GrabzIt
|
|
115
128
|
parse_options(options)
|
116
129
|
action = "takepicture.ashx"
|
117
130
|
res = query_api(action, generate_params)
|
131
|
+
if GrabzIt.logger
|
132
|
+
GrabzIt.logger.info "[Client][take_picture] Request: #{generate_params}"
|
133
|
+
GrabzIt.logger.info "[Client][take_picture] Response: #{res.body}"
|
134
|
+
end
|
118
135
|
response = Response.new(res.body)
|
119
136
|
raise response.message if response.message
|
120
137
|
response
|
@@ -134,6 +151,10 @@ module GrabzIt
|
|
134
151
|
def get_status(screenshot_id)
|
135
152
|
action = "getstatus.ashx"
|
136
153
|
response_body = query_api(action, { :id => screenshot_id })
|
154
|
+
if GrabzIt.logger
|
155
|
+
GrabzIt.logger.info "[Client][get_status] Request: #{{ :id => screenshot_id }}"
|
156
|
+
GrabzIt.logger.info "[Client][get_status] Response: #{response_body}"
|
157
|
+
end
|
137
158
|
status = Status.new(response_body)
|
138
159
|
raise status.message if status.message
|
139
160
|
status
|
@@ -159,6 +180,10 @@ module GrabzIt
|
|
159
180
|
:sig => sig
|
160
181
|
}
|
161
182
|
res = query_api(action, params)
|
183
|
+
if GrabzIt.logger
|
184
|
+
GrabzIt.logger.info "[Client][get_cookie_jar] Request: #{params}"
|
185
|
+
GrabzIt.logger.info "[Client][get_cookie_jar] Response: #{res.body}"
|
186
|
+
end
|
162
187
|
cookie_jar = CookieJar.new(res.body)
|
163
188
|
raise cookie_jar.message if cookie_jar.message
|
164
189
|
cookie_jar
|
@@ -198,6 +223,10 @@ module GrabzIt
|
|
198
223
|
action = "getpicture.ashx"
|
199
224
|
res = query_api(action, { :id => screenshot_id })
|
200
225
|
image = Image.new(res)
|
226
|
+
if GrabzIt.logger
|
227
|
+
GrabzIt.logger.info "[Client][get_picture] Request: #{{ :id => screenshot_id }}"
|
228
|
+
GrabzIt.logger.info "[Client][get_picture] Response: #{image.to_s}"
|
229
|
+
end
|
201
230
|
image
|
202
231
|
end
|
203
232
|
|
data/lib/grabz_it/image.rb
CHANGED
data/lib/grabz_it/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grabz_it
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|