browshot 1.12.0 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +2 -13
- data/Rakefile +4 -49
- data/lib/browshot.rb +181 -56
- data/test/test_browshot.rb +68 -68
- metadata +93 -149
- data/Gemfile.lock +0 -24
- data/LICENSE.txt +0 -20
- data/README.rdoc +0 -37
- data/VERSION +0 -1
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 51442cd950b03b0460cc2688dc05836ee21988a5
|
4
|
+
data.tar.gz: 8beba4478dc66aa0723ee3a1511dba76d9b51f5c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 547ad76a3d2ab3f6d12df58b6fb33c0f4587e8f4d8c9621f347eb699f594b4fbf3bfcece97f10de75360279d606a20ad7058a96ecdce3503fb94710e887a2ffd
|
7
|
+
data.tar.gz: 008bf622b3d388335f9c4e590264154d1bb3c9e755696c86599c14f564b2fa265535540417edf6da8ee8b6ddab4f4eab9c05784269e12ed63885d61330934e4f
|
data/Gemfile
CHANGED
@@ -1,17 +1,6 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
# Dependencies required to use browshot
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
gem "url", ">= 0"
|
7
|
-
end
|
4
|
+
gem "json", ">= 0"
|
5
|
+
gem "url", ">= 0"
|
8
6
|
|
9
|
-
# Dependencies to develop browshot.
|
10
|
-
group :development do
|
11
|
-
gem "json", ">= 0"
|
12
|
-
gem "url", ">= 0"
|
13
|
-
gem "shoulda", ">= 0"
|
14
|
-
gem "bundler", "~> 1.0.0"
|
15
|
-
gem "jeweler", "~> 1.6.4"
|
16
|
-
gem "rcov", ">= 0"
|
17
|
-
end
|
data/Rakefile
CHANGED
@@ -1,53 +1,8 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'bundler'
|
5
|
-
begin
|
6
|
-
Bundler.setup(:default, :development)
|
7
|
-
rescue Bundler::BundlerError => e
|
8
|
-
$stderr.puts e.message
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
-
exit e.status_code
|
11
|
-
end
|
12
|
-
require 'rake'
|
13
|
-
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.name = "browshot"
|
18
|
-
gem.homepage = "http://github.com/juliensobrier/browshot-ruby"
|
19
|
-
gem.license = "MIT"
|
20
|
-
gem.summary = "Ruby library for Browshot (L<http://www.browshot.com/>), a web service to create website screenshots."
|
21
|
-
gem.description = "Browshot (http://www.browshot.com/) is a web service to easily make screenshots of web pages in any screen size, as any device: iPhone, iPad, Android, Nook©, PC, etc. The latest API version is detailed at http://browshot.com/api/documentation."
|
22
|
-
gem.email = "julien@sobrier.net"
|
23
|
-
gem.authors = ["Julien Sobrier"]
|
24
|
-
# dependencies defined in Gemfile
|
25
|
-
end
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
27
|
-
|
28
1
|
require 'rake/testtask'
|
29
|
-
Rake::TestTask.new(:test) do |test|
|
30
|
-
test.libs << 'lib' << 'test'
|
31
|
-
test.pattern = 'test/**/test_*.rb'
|
32
|
-
test.verbose = true
|
33
|
-
end
|
34
2
|
|
35
|
-
|
36
|
-
|
37
|
-
test.libs << 'test'
|
38
|
-
test.pattern = 'test/**/test_*.rb'
|
39
|
-
test.verbose = true
|
40
|
-
test.rcov_opts << '--exclude "gems/*"'
|
3
|
+
Rake::TestTask.new do |t|
|
4
|
+
t.libs << 'test'
|
41
5
|
end
|
42
6
|
|
43
|
-
|
44
|
-
|
45
|
-
require 'rake/rdoctask'
|
46
|
-
Rake::RDocTask.new do |rdoc|
|
47
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
-
|
49
|
-
rdoc.rdoc_dir = 'rdoc'
|
50
|
-
rdoc.title = "browshot #{version}"
|
51
|
-
rdoc.rdoc_files.include('README*')
|
52
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
-
end
|
7
|
+
desc "Run tests"
|
8
|
+
task :default => :test
|
data/lib/browshot.rb
CHANGED
@@ -4,28 +4,32 @@
|
|
4
4
|
# See README.rdoc for more information abouth Browshot
|
5
5
|
# and this library.
|
6
6
|
#
|
7
|
-
#
|
7
|
+
# @author Julien Sobrier (mailto:jsobrier@browshot.com)
|
8
8
|
# Copyright:: Copyright (c) 2013 Browshot
|
9
9
|
# License:: Distributes under the same terms as Ruby
|
10
10
|
|
11
|
+
require 'rubygems'
|
11
12
|
require 'url'
|
12
13
|
require 'json'
|
13
14
|
require 'net/http'
|
14
15
|
require 'net/https'
|
15
16
|
|
16
17
|
class Browshot
|
18
|
+
# @!attribute [r]
|
17
19
|
# API key
|
18
20
|
attr_reader :key
|
21
|
+
# @!attribute [r]
|
19
22
|
# Base URL for all API requests. You should use the default base provided by the library. Be careful if you decide to use HTTP instead of HTTPS as your API key could be sniffed and your account could be used without your consent.
|
20
23
|
attr_reader :base
|
24
|
+
# @!attribute [r]
|
21
25
|
# print debug output to the standard output
|
22
26
|
attr_reader :debug
|
23
27
|
|
24
28
|
# New client
|
25
29
|
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
30
|
+
# @param key [String] API key
|
31
|
+
# @param base [String] Base URL for all API requests. You should use the default base provided by the library. Be careful if you decide to use HTTP instead of HTTPS as your API key could be sniffed and your account could be used without your consent.
|
32
|
+
# @param debug [Boolean] Set to true to print debug output to the standard output. false (disabled) by default.
|
29
33
|
def initialize(key='', base='https://api.browshot.com/api/v1/', debug=false)
|
30
34
|
@key = key || ''
|
31
35
|
@base = base || 'http://127.0.0.1:3000/api/v1/'
|
@@ -34,12 +38,12 @@ class Browshot
|
|
34
38
|
|
35
39
|
# Return the API version handled by the library. Note that this library can usually handle new arguments in requests without requiring an update.
|
36
40
|
def api_version()
|
37
|
-
return "1.
|
41
|
+
return "1.14"
|
38
42
|
end
|
39
43
|
|
40
|
-
# Retrieve a screenshot with one call. See
|
44
|
+
# Retrieve a screenshot with one call. See {https://browshot.com/api/documentation#simple} for the full list of possible arguments.
|
41
45
|
#
|
42
|
-
#
|
46
|
+
# @return [Array<Symbol, Symbol>] !{:code => 200, :png => <content>} in case of success
|
43
47
|
def simple(parameters={})
|
44
48
|
begin
|
45
49
|
url = make_url('simple', parameters)
|
@@ -56,11 +60,11 @@ class Browshot
|
|
56
60
|
end
|
57
61
|
end
|
58
62
|
|
59
|
-
# Save a screenshot to a file with one call, and save it to a file. See
|
63
|
+
# Save a screenshot to a file with one call, and save it to a file. See {https://browshot.com/api/documentation#simple} for the full list of possible arguments.
|
60
64
|
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
65
|
+
# @param file [String] Local file name to write to.
|
66
|
+
# @param parameters [Array<Symbol, Symbol>] Additional options
|
67
|
+
# @return [Array<Symbol, Symbol>] !{:code => 200, :file => <file_name>} in case of success
|
64
68
|
def simple_file(file='', parameters={})
|
65
69
|
data = self.simple(parameters)
|
66
70
|
if (data[:png].length > 0)
|
@@ -78,7 +82,7 @@ class Browshot
|
|
78
82
|
|
79
83
|
# Return the details of an instance. See http://browshot.com/api/documentation#instance_info for the response format.
|
80
84
|
#
|
81
|
-
#
|
85
|
+
# @param id [Integer] Instance ID
|
82
86
|
def instance_info(id=0)
|
83
87
|
return return_reply('instance/info', { 'id' => id })
|
84
88
|
end
|
@@ -95,7 +99,7 @@ class Browshot
|
|
95
99
|
|
96
100
|
# Return the details of a browser. See http://browshot.com/api/documentation#browser_info for the response format.
|
97
101
|
#
|
98
|
-
#
|
102
|
+
# @param id [Integer] Browser ID
|
99
103
|
def browser_info(id=0)
|
100
104
|
return return_reply('browser/info', { 'id' => id })
|
101
105
|
end
|
@@ -107,7 +111,7 @@ class Browshot
|
|
107
111
|
|
108
112
|
# Request a screenshot. See http://browshot.com/api/documentation#screenshot_create for the response format.
|
109
113
|
#
|
110
|
-
#
|
114
|
+
# @param url [String] URL of the website to create a screenshot of.
|
111
115
|
def screenshot_create(url='', parameters={})
|
112
116
|
parameters[:url] = url
|
113
117
|
return return_reply('screenshot/create', parameters)
|
@@ -115,7 +119,7 @@ class Browshot
|
|
115
119
|
|
116
120
|
# Get information about a screenshot requested previously. See http://browshot.com/api/documentation#screenshot_info for the response format.
|
117
121
|
#
|
118
|
-
#
|
122
|
+
# @param id [Integer] screenshot ID
|
119
123
|
def screenshot_info(id=0, parameters={})
|
120
124
|
parameters[:id] = id
|
121
125
|
return return_reply('screenshot/info', parameters)
|
@@ -128,8 +132,8 @@ class Browshot
|
|
128
132
|
|
129
133
|
# Retrieve the screenshot, or a thumbnail. See http://browshot.com/api/documentation#screenshot_thumbnails for the response format.
|
130
134
|
#
|
131
|
-
#
|
132
|
-
#
|
135
|
+
# @eturn an empty string if the image could not be retrieved.
|
136
|
+
# @param id [Integer] screenshot ID
|
133
137
|
def screenshot_thumbnail(id=0, parameters={})
|
134
138
|
parameters[:id] = id
|
135
139
|
|
@@ -150,8 +154,8 @@ class Browshot
|
|
150
154
|
|
151
155
|
# Hot a screenshot or thumbnail. See http://browshot.com/api/documentation#screenshot_host for the response format.
|
152
156
|
#
|
153
|
-
#
|
154
|
-
#
|
157
|
+
# @param id [Integer] screenshot ID
|
158
|
+
# @param hosting ['s3', 'browshot'] hosting option: s3 or browshot
|
155
159
|
def screenshot_host(id=0, hosting='browshot', parameters={})
|
156
160
|
parameters[:id] = id
|
157
161
|
parameters[:hosting] = hosting
|
@@ -160,7 +164,7 @@ class Browshot
|
|
160
164
|
|
161
165
|
# Share a screenshot. See http://browshot.com/api/documentation#screenshot_share for the response format.
|
162
166
|
#
|
163
|
-
#
|
167
|
+
# @param id [Integer] screenshot ID
|
164
168
|
def screenshot_share(id=0, parameters={})
|
165
169
|
parameters[:id] = id
|
166
170
|
return return_reply('screenshot/share', parameters)
|
@@ -168,7 +172,7 @@ class Browshot
|
|
168
172
|
|
169
173
|
# Delete details of a screenshot. See http://browshot.com/api/documentation#screenshot_delete for the response format.
|
170
174
|
#
|
171
|
-
#
|
175
|
+
# @param id [Integer] screenshot ID
|
172
176
|
def screenshot_delete(id=0, parameters={})
|
173
177
|
parameters[:id] = id
|
174
178
|
return return_reply('screenshot/delete', parameters)
|
@@ -176,7 +180,7 @@ class Browshot
|
|
176
180
|
|
177
181
|
# Get details about screenshots requested. See http://browshot.com/api/documentation#screenshot_search for the response format.
|
178
182
|
#
|
179
|
-
#
|
183
|
+
# @param url [String] URL string to match
|
180
184
|
def screenshot_search(url='', parameters={})
|
181
185
|
parameters[:url] = url
|
182
186
|
return return_reply('screenshot/search', parameters)
|
@@ -185,10 +189,10 @@ class Browshot
|
|
185
189
|
|
186
190
|
# Retrieve the screenshot, or a thumbnail, and save it to a file. See http://browshot.com/api/documentation#screenshot_thumbnails for the response format.
|
187
191
|
#
|
188
|
-
# See http://browshot.com/api/documentation#
|
192
|
+
# See http://browshot.com/api/documentation#screenshot_thumbnails for the full list of possible arguments.
|
189
193
|
#
|
190
|
-
#
|
191
|
-
#
|
194
|
+
# @param id [Integer] screenshot ID
|
195
|
+
# @param file [String] Local file name to write to.
|
192
196
|
def screenshot_thumbnail_file(id=0, file='', parameters={})
|
193
197
|
content = screenshot_thumbnail(id, parameters);
|
194
198
|
|
@@ -200,8 +204,57 @@ class Browshot
|
|
200
204
|
return ''
|
201
205
|
end
|
202
206
|
end
|
207
|
+
|
208
|
+
|
209
|
+
# Get the HTML code of the rendered page. See http://browshot.com/api/documentation#screenshot_html for the response format.
|
210
|
+
#
|
211
|
+
# See http://browshot.com/api/documentation#screenshot_html for the full list of possible arguments.
|
212
|
+
#
|
213
|
+
# @param id [Integer] screenshot ID
|
214
|
+
def screenshot_html(id=0, parameters={})
|
215
|
+
parameters[:id] = id
|
216
|
+
|
217
|
+
return return_string('screenshot/html', parameters)
|
218
|
+
end
|
219
|
+
|
220
|
+
|
221
|
+
# Request multiple screenshots. See http://browshot.com/api/documentation#screenshot_multiple for the response format.
|
222
|
+
#
|
223
|
+
# See http://browshot.com/api/documentation#screenshot_multiple for the full list of possible arguments.
|
224
|
+
#
|
225
|
+
# @param url [String] URL of the website to create a screenshot of
|
226
|
+
def screenshot_multiple(url='', parameters={})
|
227
|
+
parameters[:url] = url
|
203
228
|
|
204
|
-
|
229
|
+
return return_reply('screenshot/multiple', parameters)
|
230
|
+
end
|
231
|
+
|
232
|
+
# Request multiple screenshots from a text file. See http://browshot.com/api/documentation#batch_create for the response format.
|
233
|
+
#
|
234
|
+
# See http://browshot.com/api/documentation#batch_create for the full list of possible arguments.
|
235
|
+
#
|
236
|
+
# @param id [Integer] Instance ID
|
237
|
+
# @param file [String] Path to the text file which contains the list of URLs
|
238
|
+
def batch_create(id=0, file='', parameters={})
|
239
|
+
parameters[:id] = id
|
240
|
+
parameters[:file] = file
|
241
|
+
|
242
|
+
return return_post_reply('batch/create', parameters)
|
243
|
+
end
|
244
|
+
|
245
|
+
# Get information about a screenshot batch requested previously. See {https://browshot.com/api/documentation#batch_info} for the response format.
|
246
|
+
#
|
247
|
+
# See http://browshot.com/api/documentation#batch_info for the full list of possible arguments.
|
248
|
+
#
|
249
|
+
# @param id [Integer] Batch ID
|
250
|
+
def batch_info(id=0, parameters={})
|
251
|
+
parameters[:id] = id
|
252
|
+
|
253
|
+
return return_reply('batch/info', parameters)
|
254
|
+
end
|
255
|
+
|
256
|
+
|
257
|
+
# Return information about the user account. See {https://browshot.com/api/documentation#account_info} for the response format.
|
205
258
|
def account_info(parameters={})
|
206
259
|
return return_reply('account/info', parameters)
|
207
260
|
end
|
@@ -223,16 +276,58 @@ class Browshot
|
|
223
276
|
|
224
277
|
def return_reply(action='', parameters={})
|
225
278
|
begin
|
226
|
-
|
279
|
+
content = return_string(action, parameters)
|
280
|
+
|
281
|
+
json_decode = JSON.parse(content)
|
282
|
+
return json_decode
|
283
|
+
rescue Exception => e
|
284
|
+
puts "{e.message}" if (@debug)
|
285
|
+
raise e
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
def return_post_reply(action='', parameters={})
|
290
|
+
begin
|
291
|
+
content = return_post_string(action, parameters)
|
292
|
+
|
293
|
+
json_decode = JSON.parse(content)
|
294
|
+
return json_decode
|
295
|
+
rescue Exception => e
|
296
|
+
puts "{e.message}" if (@debug)
|
297
|
+
raise e
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
def return_string(action='', parameters={})
|
302
|
+
begin
|
303
|
+
url = make_url(action, parameters)
|
227
304
|
|
228
305
|
response = url.get
|
229
306
|
|
230
|
-
if (response.success?)
|
231
|
-
json_decode = JSON.parse(response.response.body)
|
232
|
-
return json_decode
|
233
|
-
else
|
307
|
+
if (response.success? == false)
|
234
308
|
puts "Error from #{url}: #{response.code}" if (@debug)
|
235
|
-
|
309
|
+
end
|
310
|
+
return response.response.body
|
311
|
+
rescue Exception => e
|
312
|
+
puts "{e.message}" if (@debug)
|
313
|
+
raise e
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
def return_post_string(action='', parameters={})
|
318
|
+
begin
|
319
|
+
file = parameters[:file]
|
320
|
+
parameters.delete(:file)
|
321
|
+
url = make_url(action, parameters)
|
322
|
+
|
323
|
+
response = post(url.to_s,file)
|
324
|
+
|
325
|
+
case response
|
326
|
+
when Net::HTTPSuccess then
|
327
|
+
return response.response.body
|
328
|
+
else
|
329
|
+
puts "Error from #{url}: #{response.code}" if (@debug)
|
330
|
+
return response.response.body
|
236
331
|
end
|
237
332
|
rescue Exception => e
|
238
333
|
puts "{e.message}" if (@debug)
|
@@ -240,28 +335,58 @@ class Browshot
|
|
240
335
|
end
|
241
336
|
end
|
242
337
|
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
338
|
+
def fetch(url, limit=32)
|
339
|
+
raise ArgumentError, 'HTTP redirect too deep' if (limit == 0)
|
340
|
+
|
341
|
+
uri = URI.parse(url)
|
342
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
343
|
+
http.open_timeout = 240
|
344
|
+
http.read_timeout = 240
|
345
|
+
|
346
|
+
request = Net::HTTP::Get.new(uri.request_uri, {'User-Agent' => 'Browshot Ruby 1.14'})
|
347
|
+
if (uri.scheme == 'https')
|
348
|
+
http.use_ssl = true
|
349
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
350
|
+
end
|
351
|
+
response = http.request(request)
|
352
|
+
|
353
|
+
case response
|
354
|
+
when Net::HTTPRedirection then
|
355
|
+
path = response['location']
|
356
|
+
url = URL.new( URI.join(@base, path).to_s )
|
357
|
+
return fetch(url.to_s, limit - 1)
|
358
|
+
else
|
359
|
+
return response
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
def post(url, file='')
|
364
|
+
raise ArgumentError, 'Missing file to upload' if (file == '')
|
365
|
+
|
366
|
+
uri = URI.parse(url)
|
367
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
368
|
+
http.open_timeout = 240
|
369
|
+
http.read_timeout = 240
|
370
|
+
|
371
|
+
boundary = "AaB03x"
|
372
|
+
|
373
|
+
post_body = []
|
374
|
+
post_body << "--#{boundary}\r\n"
|
375
|
+
post_body << "Content-Disposition: form-data; name=\"file\"; filename=\"#{File.basename(file)}\"\r\n"
|
376
|
+
post_body << "Content-Type: text/plain\r\n"
|
377
|
+
post_body << "\r\n"
|
378
|
+
post_body << File.read(file)
|
379
|
+
post_body << "\r\n--#{boundary}--\r\n"
|
380
|
+
|
381
|
+
request = Net::HTTP::Post.new(uri.request_uri, {'User-Agent' => 'Browshot Ruby 1.14'})
|
382
|
+
request.body = post_body.join
|
383
|
+
request["Content-Type"] = "multipart/form-data, boundary=#{boundary}"
|
384
|
+
|
385
|
+
if (uri.scheme == 'https')
|
386
|
+
http.use_ssl = true
|
387
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
388
|
+
end
|
389
|
+
|
390
|
+
return http.request(request)
|
391
|
+
end
|
267
392
|
end
|
data/test/test_browshot.rb
CHANGED
@@ -14,7 +14,7 @@ class TestBrowshot < Test::Unit::TestCase
|
|
14
14
|
end
|
15
15
|
|
16
16
|
should "get the API version" do
|
17
|
-
assert_equal '1.
|
17
|
+
assert_equal '1.14', @browshot.api_version()
|
18
18
|
end
|
19
19
|
|
20
20
|
should "get a screenshot with the simple method" do
|
@@ -68,7 +68,7 @@ class TestBrowshot < Test::Unit::TestCase
|
|
68
68
|
assert_equal free['id'], instance['id'], "Mismatch instance ID"
|
69
69
|
assert_equal free['width'], instance['width'], "Mismatch instance screen width"
|
70
70
|
assert_equal free['height'], instance['height'], "Mismatch instance screen height"
|
71
|
-
|
71
|
+
# assert_equal free['load'], instance['load'], "Mismatch instance load"
|
72
72
|
assert_equal free['browser']['id'], instance['browser']['id'], "Mismatch instance browser ID"
|
73
73
|
assert_equal free['browser']['name'], instance['browser']['name'], "Mismatch instance browser name"
|
74
74
|
assert_equal free['browser']['javascript'], instance['browser']['javascript'],"Mismatch instance browser javascript capability"
|
@@ -223,73 +223,73 @@ class TestBrowshot < Test::Unit::TestCase
|
|
223
223
|
end
|
224
224
|
end
|
225
225
|
|
226
|
-
should "
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
226
|
+
should "retrieve a screenshot with details==0" do
|
227
|
+
screenshot = @browshot.screenshot_create('http://browshot.com/')
|
228
|
+
info = @browshot.screenshot_info(screenshot['id'], { 'details' => 0 })
|
229
|
+
|
230
|
+
assert_equal false, info['id'].nil?, "Screenshot ID should be present"
|
231
|
+
assert_equal false, info['status'].nil?, "Screenshot status should be present"
|
232
|
+
assert_equal false, info['priority'].nil?, "Screenshot priority should be present"
|
233
|
+
assert_equal false, info['cost'].nil?, "Screenshot cost should be present"
|
234
|
+
|
235
|
+
if (info['status'] == 'finished')
|
236
|
+
assert_equal false, info['screenshot_url'].nil?, "Screenshot screenshot_url should be present"
|
237
|
+
assert_equal false, info['url'].nil?, "Screenshot url should be present"
|
238
|
+
assert_equal false, info['size'].nil?, "Screenshot size should be present"
|
239
|
+
assert_equal false, info['width'].nil?, "Screenshot width should be present"
|
240
|
+
assert_equal false, info['height'].nil?, "Screenshot height should be present"
|
241
|
+
assert_equal false, info['instance_id'].nil?, "Screenshot instance_id should be present"
|
242
|
+
assert_equal false, info['final_url'].nil?, "Screenshot final_url should be present"
|
243
|
+
assert_equal false, info['scale'].nil?, "Screenshot scale should be present"
|
244
|
+
|
245
|
+
# assert_equal true, info['response_code'].nil?, "Screenshot response_code should NOT be present"
|
246
|
+
# assert_equal true, info['content_type'].nil?, "Screenshot content_type should NOT be present"
|
247
|
+
|
248
|
+
# assert_equal true, info['started'].nil?, "Screenshot started should NOT be present"
|
249
|
+
# assert_equal true, info['finished'].nil?, "Screenshot finished should NOT be present"
|
250
|
+
# assert_equal true, info['load'].nil?, "Screenshot load should NOT be present"
|
251
|
+
# assert_equal true, info['request_time'].nil?, "Screenshot request_time should NOT be present"
|
252
|
+
# assert_equal true, info['content'].nil?, "Screenshot content should NOT be present"
|
253
|
+
|
254
|
+
# assert_equal true, info['images'].nil?, "Screenshot images should NOT be present"
|
255
|
+
end
|
255
256
|
end
|
256
|
-
end
|
257
|
-
|
258
|
-
should "to retrieve a screenshot with details==1" do
|
259
|
-
screenshot = @browshot.screenshot_create('http://browshot.com/')
|
260
|
-
info = @browshot.screenshot_info(screenshot['id'], { 'details' => 1 })
|
261
257
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
258
|
+
should "retrieve a screenshot with details==1" do
|
259
|
+
screenshot = @browshot.screenshot_create('http://browshot.com/')
|
260
|
+
info = @browshot.screenshot_info(screenshot['id'], { 'details' => 1 })
|
261
|
+
|
262
|
+
assert_equal false, info['id'].nil?, "Screenshot ID should be present"
|
263
|
+
assert_equal false, info['status'].nil?, "Screenshot status should be present"
|
264
|
+
assert_equal false, info['priority'].nil?, "Screenshot priority should be present"
|
265
|
+
assert_equal false, info['cost'].nil?, "Screenshot cost should be present"
|
266
|
+
|
267
|
+
if (info['status'] == 'finished')
|
268
|
+
assert_equal false, info['screenshot_url'].nil?, "Screenshot screenshot_url should be present"
|
269
|
+
assert_equal false, info['url'].nil?, "Screenshot url should be present"
|
270
|
+
assert_equal false, info['size'].nil?, "Screenshot size should be present"
|
271
|
+
assert_equal false, info['width'].nil?, "Screenshot width should be present"
|
272
|
+
assert_equal false, info['height'].nil?, "Screenshot height should be present"
|
273
|
+
assert_equal false, info['instance_id'].nil?, "Screenshot instance_id should be present"
|
274
|
+
assert_equal false, info['final_url'].nil?, "Screenshot final_url should be present"
|
275
|
+
assert_equal false, info['scale'].nil?, "Screenshot scale should be present"
|
276
|
+
|
277
|
+
assert_equal false, info['response_code'].nil?, "Screenshot response_code should be present"
|
278
|
+
assert_equal false, info['content_type'].nil?, "Screenshot content_type should be present"
|
279
|
+
|
280
|
+
# assert_equal true, info['started'].nil?, "Screenshot started should NOT be present"
|
281
|
+
# assert_equal true, info['finished'].nil?, "Screenshot finished should NOT be present"
|
282
|
+
# assert_equal true, info['load'].nil?, "Screenshot load should NOT be present"
|
283
|
+
# assert_equal true, info['request_time'].nil?, "Screenshot request_time should NOT be present"
|
284
|
+
# assert_equal true, info['content'].nil?, "Screenshot content should NOT be present"
|
285
|
+
|
286
|
+
# assert_equal true, info['images'].nil?, "Screenshot images should NOT be present"
|
287
|
+
end
|
288
|
+
end
|
289
289
|
|
290
290
|
should "to retrieve a screenshot with details==2" do
|
291
291
|
screenshot = @browshot.screenshot_create('http://browshot.com/')
|
292
|
-
|
292
|
+
info = @browshot.screenshot_info(screenshot['id'], { 'details' => 2 })
|
293
293
|
|
294
294
|
assert_equal false, info['id'].nil?, "Screenshot ID should be present"
|
295
295
|
assert_equal false, info['status'].nil?, "Screenshot status should be present"
|
@@ -317,7 +317,7 @@ class TestBrowshot < Test::Unit::TestCase
|
|
317
317
|
|
318
318
|
assert_equal true, info['images'].nil?, "Screenshot images should NOT be present"
|
319
319
|
end
|
320
|
-
|
320
|
+
end
|
321
321
|
|
322
322
|
# Details = 2 by default
|
323
323
|
# should "to retrieve a screenshot with details==3" do
|
@@ -354,7 +354,7 @@ class TestBrowshot < Test::Unit::TestCase
|
|
354
354
|
# assert_equal false, info['iframes'].nil?, "Screenshot iframes should be present"
|
355
355
|
# assert_equal false, info['embeds'].nil?, "Screenshot embeds should be present"
|
356
356
|
# end
|
357
|
-
|
357
|
+
# end
|
358
358
|
|
359
359
|
should "retrieve the list of screenshots" do
|
360
360
|
screenshots = @browshot.screenshot_list()
|
@@ -461,13 +461,13 @@ class TestBrowshot < Test::Unit::TestCase
|
|
461
461
|
assert_equal false, screenshot['cost'].nil?, "Screenshot cost should be present"
|
462
462
|
end
|
463
463
|
|
464
|
-
should "
|
464
|
+
should "retrieve account information" do
|
465
465
|
account = @browshot.account_info()
|
466
466
|
assert_equal false, account['balance'].nil?, "Account balance should be present"
|
467
467
|
assert_equal 0, account['balance'].to_i, "Balance should be empty"
|
468
468
|
assert_equal false, account['active'].nil?, "Account active should be present"
|
469
469
|
assert_equal 1, account['active'].to_i, "Accountshould be active"
|
470
|
-
|
470
|
+
# assert_equal false, account['instances'].nil?, "Account instances should be present"
|
471
471
|
end
|
472
472
|
|
473
473
|
should "refuse invalid key" do
|
metadata
CHANGED
@@ -1,191 +1,135 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: browshot
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 12
|
9
|
-
- 0
|
10
|
-
version: 1.12.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.14.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Julien Sobrier
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
22
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
-
none: false
|
24
|
-
requirements:
|
25
|
-
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
hash: 3
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
version: "0"
|
31
|
-
type: :runtime
|
32
|
-
prerelease: false
|
11
|
+
date: 2014-01-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
33
14
|
name: json
|
34
|
-
|
35
|
-
|
36
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
-
none: false
|
38
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
39
17
|
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
|
42
|
-
segments:
|
43
|
-
- 0
|
44
|
-
version: "0"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
45
20
|
type: :runtime
|
46
21
|
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
47
28
|
name: url
|
48
|
-
|
49
|
-
|
50
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
|
-
requirements:
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
53
31
|
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
|
56
|
-
|
57
|
-
- 0
|
58
|
-
version: "0"
|
59
|
-
type: :development
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
60
35
|
prerelease: false
|
61
|
-
|
62
|
-
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
67
38
|
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
73
48
|
type: :development
|
74
49
|
prerelease: false
|
75
|
-
|
76
|
-
|
77
|
-
-
|
78
|
-
|
79
|
-
|
80
|
-
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
81
59
|
- - ">="
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
|
84
|
-
segments:
|
85
|
-
- 0
|
86
|
-
version: "0"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
87
62
|
type: :development
|
88
63
|
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
89
70
|
name: shoulda
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
- - ~>
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
hash: 23
|
98
|
-
segments:
|
99
|
-
- 1
|
100
|
-
- 0
|
101
|
-
- 0
|
102
|
-
version: 1.0.0
|
103
|
-
type: :development
|
104
|
-
prerelease: false
|
105
|
-
name: bundler
|
106
|
-
version_requirements: *id006
|
107
|
-
- !ruby/object:Gem::Dependency
|
108
|
-
requirement: &id007 !ruby/object:Gem::Requirement
|
109
|
-
none: false
|
110
|
-
requirements:
|
111
|
-
- - ~>
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
hash: 7
|
114
|
-
segments:
|
115
|
-
- 1
|
116
|
-
- 6
|
117
|
-
- 4
|
118
|
-
version: 1.6.4
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
119
76
|
type: :development
|
120
77
|
prerelease: false
|
121
|
-
|
122
|
-
|
123
|
-
- !ruby/object:Gem::Dependency
|
124
|
-
requirement: &id008 !ruby/object:Gem::Requirement
|
125
|
-
none: false
|
126
|
-
requirements:
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
127
80
|
- - ">="
|
128
|
-
- !ruby/object:Gem::Version
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
133
90
|
type: :development
|
134
91
|
prerelease: false
|
135
|
-
|
136
|
-
|
137
|
-
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Library for the Browshot API
|
138
98
|
email: julien@sobrier.net
|
139
99
|
executables: []
|
140
|
-
|
141
100
|
extensions: []
|
142
|
-
|
143
|
-
|
144
|
-
- LICENSE.txt
|
145
|
-
- README.rdoc
|
146
|
-
files:
|
101
|
+
extra_rdoc_files: []
|
102
|
+
files:
|
147
103
|
- Gemfile
|
148
|
-
- Gemfile.lock
|
149
|
-
- LICENSE.txt
|
150
|
-
- README.rdoc
|
151
104
|
- Rakefile
|
152
|
-
- VERSION
|
153
105
|
- lib/browshot.rb
|
154
106
|
- test/helper.rb
|
155
107
|
- test/test_browshot.rb
|
156
|
-
|
157
|
-
|
158
|
-
licenses:
|
108
|
+
homepage: https://browshot.com/
|
109
|
+
licenses:
|
159
110
|
- MIT
|
111
|
+
metadata: {}
|
160
112
|
post_install_message:
|
161
113
|
rdoc_options: []
|
162
|
-
|
163
|
-
require_paths:
|
114
|
+
require_paths:
|
164
115
|
- lib
|
165
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
166
|
-
|
167
|
-
requirements:
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
168
118
|
- - ">="
|
169
|
-
- !ruby/object:Gem::Version
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
version: "0"
|
174
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
|
-
none: false
|
176
|
-
requirements:
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
177
123
|
- - ">="
|
178
|
-
- !ruby/object:Gem::Version
|
179
|
-
|
180
|
-
segments:
|
181
|
-
- 0
|
182
|
-
version: "0"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
183
126
|
requirements: []
|
184
|
-
|
185
127
|
rubyforge_project:
|
186
|
-
rubygems_version:
|
128
|
+
rubygems_version: 2.2.1
|
187
129
|
signing_key:
|
188
|
-
specification_version:
|
189
|
-
summary:
|
190
|
-
test_files:
|
191
|
-
|
130
|
+
specification_version: 4
|
131
|
+
summary: Take website screenshtos with Browshot
|
132
|
+
test_files:
|
133
|
+
- test/helper.rb
|
134
|
+
- test/test_browshot.rb
|
135
|
+
has_rdoc:
|
data/Gemfile.lock
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
git (1.2.5)
|
5
|
-
jeweler (1.6.4)
|
6
|
-
bundler (~> 1.0)
|
7
|
-
git (>= 1.2.5)
|
8
|
-
rake
|
9
|
-
json (1.6.1)
|
10
|
-
rake (0.9.2.2)
|
11
|
-
rcov (0.9.11)
|
12
|
-
shoulda (2.11.3)
|
13
|
-
url (0.3.1)
|
14
|
-
|
15
|
-
PLATFORMS
|
16
|
-
ruby
|
17
|
-
|
18
|
-
DEPENDENCIES
|
19
|
-
bundler (~> 1.0.0)
|
20
|
-
jeweler (~> 1.6.4)
|
21
|
-
json
|
22
|
-
rcov
|
23
|
-
shoulda
|
24
|
-
url
|
data/LICENSE.txt
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2011 Julien Sobrier
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
= browshot
|
2
|
-
|
3
|
-
Browshot (http://www.browshot.com/) is a web service to easily make screenshots of web pages in any screen size, as any device: iPhone©, iPad©, Android©, Nook©, PC, etc. Browshot has full Flash, JavaScript, CSS, & HTML5 support.
|
4
|
-
|
5
|
-
The latest API version is detailed at http://browshot.com/api/documentation. browshot follows the API documentation very closely: the function names are similar to the URLs used (screenshot/create becomes screenshot_create(), instance/list becomes instance_list(), etc.), the request arguments are exactly the same, etc.
|
6
|
-
|
7
|
-
The library version matches closely the API version it handles: browshot 1.0.0 is the first release for the API 1.0, browshot 1.1.1 is the second release for the API 1.1, etc.
|
8
|
-
|
9
|
-
browshot can handle most the API updates within the same major version, e.g. browshot 1.0.0 should be compatible with the API 1.1 or 1.2.
|
10
|
-
|
11
|
-
Browshot gem is availabe at rubygems: https://rubygems.org/gems/browshot
|
12
|
-
|
13
|
-
== Build and install browshot
|
14
|
-
|
15
|
-
git clone https://github.com/juliensobrier/browshot-ruby
|
16
|
-
rake build
|
17
|
-
rake test
|
18
|
-
rake install
|
19
|
-
|
20
|
-
Or
|
21
|
-
|
22
|
-
gem install browshot
|
23
|
-
|
24
|
-
== Contributing to browshot
|
25
|
-
|
26
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
27
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
28
|
-
* Fork the project
|
29
|
-
* Start a feature/bugfix branch
|
30
|
-
* Commit and push until you are happy with your contribution
|
31
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
32
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
33
|
-
|
34
|
-
== Copyright
|
35
|
-
|
36
|
-
Copyright (c) 2012 Julien Sobrier. See LICENSE.txt for
|
37
|
-
further details.
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.12.0
|