grabzit 2.3.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/test/test_grabzit.rb CHANGED
@@ -9,10 +9,10 @@ class GrabzItTest < Test::Unit::TestCase
9
9
  Screenshot_Path = "test/tmp.jpg"
10
10
 
11
11
  def setup
12
- @applicationKey = "YOUR APPLICATION KEY"
13
- @applicationSecret = "YOUR APPLICATION SECRET"
12
+ @applicationKey = "c3VwcG9ydEBncmFiei5pdA=="
13
+ @applicationSecret = "AD8/aT8/Pz8/Tz8/PwJ3Pz9sVSs/Pz8/Pz9DOzJodoi="
14
14
  #Set to true if the account is subscribed
15
- @isSubscribedAccount = false
15
+ @isSubscribedAccount = true
16
16
  end
17
17
 
18
18
  def test_application_key
@@ -23,71 +23,52 @@ class GrabzItTest < Test::Unit::TestCase
23
23
  assert_not_nil(@applicationSecret, "Please set your application secret variable in the setup method. You can get a application key for free from: http://grabz.it")
24
24
  end
25
25
 
26
- def test_take_picture
27
- assert_nothing_raised "An error occured when trying to take a picture" do
26
+ def test_html_to_image
27
+ assert_nothing_raised "An error occured when trying to take convert HTML to a image" do
28
28
  grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
29
- assert_not_nil(grabzItClient.take_picture("http://www.google.com"), "Failed to take screenshot using depreceated method")
30
- end
29
+ grabzItClient.html_to_image("<h1>Hello world</h1>");
30
+ assert_not_equal(false, grabzItClient.save(), "HTML not converted")
31
+ end
31
32
  end
32
-
33
- def test_take_pdf
34
- assert_nothing_raised "An error occured when trying to take a pdf screenshot" do
35
- grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
36
- grabzItClient.set_pdf_options("http://www.google.com")
37
- assert_not_nil(grabzItClient.save(), "Failed to take screenshot using set_pdf_options method")
38
- end
39
- end
40
-
41
- def test_take_image
42
- assert_nothing_raised "An error occured when trying to take a image screenshot" do
33
+
34
+ def test_html_to_pdf
35
+ assert_nothing_raised "An error occured when trying to take convert HTML to a pdf" do
43
36
  grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
44
- grabzItClient.set_image_options("http://www.google.com")
45
- assert_not_nil(grabzItClient.save(), "Failed to take screenshot using set_image_options method")
46
- end
37
+ grabzItClient.html_to_pdf("<h1>Hello world</h1>");
38
+ assert_not_equal(false, grabzItClient.save(), "HTML not converted")
39
+ end
47
40
  end
48
41
 
49
- def test_take_unicode_url_image
50
- assert_nothing_raised "An error occured when trying to take a image screenshot with a unicode URL" do
42
+ def test_save_to_bytes
43
+ assert_nothing_raised "An error occured when trying to take a image screenshot" do
51
44
  grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
52
- grabzItClient.set_image_options("\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0066\u006f\u0072\u0075\u006d\u002e\u0074\u0068\u0061\u0069\u007a\u0061\u002e\u0063\u006f\u006d\u002f\u0074\u0065\u0063\u0068\u006e\u006f\u006c\u006f\u0067\u0079\u002f\u004e\u0065\u0064\u0061\u0061\u002d\u0e08\u0e31\u0e1a\u0e21\u0e37\u0e2d\u002d\u0048\u0079\u0074\u0065\u0072\u0061\u002d\u0e43\u0e2b\u0e49\u0e1a\u0e23\u0e34\u0e01\u0e32\u0e23\u0e23\u0e30\u0e1a\u0e1a\u0e27\u0e34\u0e17\u0e22\u0e38\u0e21\u0e32\u0e15\u0e23\u0e10\u0e32\u0e19\u002d\u0054\u0045\u0054\u0052\u0041\u002d\u0e23\u0e30\u0e14\u0e31\u0e1a\u0e40\u0e27\u0e34\u0e25\u0e14\u0e4c\u0e04\u0e25\u0e32\u0e2a\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e01\u0e32\u002f\u0036\u0033\u0037\u0037\u0035\u0037\u002f".encode('utf-8'))
53
- assert_not_nil(grabzItClient.save(), "Failed to take screenshot or a unicode URL")
45
+ grabzItClient.url_to_image("http://www.google.com")
46
+ val = grabzItClient.save_to();
47
+ assert_not_nil(val, "Screenshot not returned as bytes")
48
+ assert_not_equal(false, val, "An error occured attempting to save data to byte variable")
54
49
  end
55
50
  end
56
51
 
57
- def test_save_picture
58
- if File.file?(Screenshot_Path)
59
- File.delete(Screenshot_Path)
60
- end
61
- assert_nothing_raised "An error occured when trying to take a image screenshot" do
52
+ def test_save_table
53
+ assert_nothing_raised "An error occured when trying to extract a HTML table" do
62
54
  grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
63
- assert_equal(true, grabzItClient.save_picture("http://www.google.com", Screenshot_Path), "Screenshot not saved")
64
- assert_equal(true, File.file?(Screenshot_Path), "Not saved screenshot file")
55
+ grabzItClient.url_to_table("http://grabz.it/api/php/advanced/errorhandling.aspx")
56
+ assert_not_nil(grabzItClient.save(), "Failed to take screenshot using url_to_table method")
65
57
  end
66
- File.delete(Screenshot_Path)
67
- end
58
+ end
68
59
 
69
60
  def test_save_animation
70
61
  assert_nothing_raised "An error occured when trying to take a animation" do
71
62
  grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
72
- grabzItClient.set_animation_options("http://www.youtube.com");
63
+ grabzItClient.url_to_animation("http://www.youtube.com");
73
64
  assert_not_equal(false, grabzItClient.save(), "Animation not taken")
74
- end
65
+ end
75
66
  end
76
67
 
77
- def test_save_to_bytes
78
- assert_nothing_raised "An error occured when trying to take a image screenshot" do
79
- grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
80
- grabzItClient.set_image_options("http://www.google.com")
81
- val = grabzItClient.save_to();
82
- assert_not_nil(val, "Screenshot not returned as bytes")
83
- assert_not_equal(false, val, "An error occured attempting to save data to byte variable")
84
- end
85
- end
86
-
87
68
  def test_status
88
69
  assert_nothing_raised "An error occured when trying to test the status method" do
89
70
  grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
90
- grabzItClient.set_image_options("http://www.google.com")
71
+ grabzItClient.url_to_image("http://www.google.com")
91
72
  id = grabzItClient.save()
92
73
  status = grabzItClient.get_status(id)
93
74
 
@@ -223,4 +204,30 @@ class GrabzItTest < Test::Unit::TestCase
223
204
 
224
205
  return true
225
206
  end
207
+
208
+ def test_take_pdf
209
+ assert_nothing_raised "An error occured when trying to take a pdf screenshot" do
210
+ grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
211
+ grabzItClient.url_to_pdf("http://www.google.com")
212
+ assert_not_nil(grabzItClient.save(), "Failed to take screenshot using url_to_pdf method")
213
+ end
214
+ end
215
+
216
+ def test_take_image_options
217
+ assert_nothing_raised "An error occured when trying to take a image screenshot" do
218
+ grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
219
+ options = GrabzIt::ImageOptions.new()
220
+ options.customWaterMarkId("GrabzIt_Browser")
221
+ grabzItClient.url_to_image("http://www.google.com", options)
222
+ assert_not_nil(grabzItClient.save(), "Failed to take screenshot using set_image_options method")
223
+ end
224
+ end
225
+
226
+ def test_take_unicode_url_image
227
+ assert_nothing_raised "An error occured when trying to take a image screenshot with a unicode URL" do
228
+ grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
229
+ grabzItClient.url_to_image("\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0066\u006f\u0072\u0075\u006d\u002e\u0074\u0068\u0061\u0069\u007a\u0061\u002e\u0063\u006f\u006d\u002f\u0074\u0065\u0063\u0068\u006e\u006f\u006c\u006f\u0067\u0079\u002f\u004e\u0065\u0064\u0061\u0061\u002d\u0e08\u0e31\u0e1a\u0e21\u0e37\u0e2d\u002d\u0048\u0079\u0074\u0065\u0072\u0061\u002d\u0e43\u0e2b\u0e49\u0e1a\u0e23\u0e34\u0e01\u0e32\u0e23\u0e23\u0e30\u0e1a\u0e1a\u0e27\u0e34\u0e17\u0e22\u0e38\u0e21\u0e32\u0e15\u0e23\u0e10\u0e32\u0e19\u002d\u0054\u0045\u0054\u0052\u0041\u002d\u0e23\u0e30\u0e14\u0e31\u0e1a\u0e40\u0e27\u0e34\u0e25\u0e14\u0e4c\u0e04\u0e25\u0e32\u0e2a\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e01\u0e32\u002f\u0036\u0033\u0037\u0037\u0035\u0037\u002f".encode('utf-8'))
230
+ assert_not_nil(grabzItClient.save(), "Failed to take screenshot or a unicode URL")
231
+ end
232
+ end
226
233
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grabzit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 3.0.0
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: 2016-09-15 00:00:00.000000000 Z
12
+ date: 2016-10-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -27,11 +27,11 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
- description: Use GrabzIt to take PDF or image screenshots of websites. These screenshots
31
- have highly customizable options include altering quality, delay, size, browser
32
- type, geographic location and much more. Additionally GrabzIt can even convert HTML
33
- tables on the web into a CSV or Excel spreadsheet. As well as enabling online video's
34
- to be converted into animated GIF's.
30
+ description: Use GrabzIt to take PDF or image screenshots of websites or convert HTML
31
+ to images or PDF's. These captures have highly customizable options include altering
32
+ quality, delay, size, browser type, geographic location and much more. Additionally
33
+ GrabzIt can even convert HTML tables on the web into a CSV or Excel spreadsheet.
34
+ As well as enabling online video's to be converted into animated GIF's.
35
35
  email: support@grabz.it
36
36
  executables: []
37
37
  extensions: []
@@ -44,6 +44,13 @@ files:
44
44
  - lib/grabzit/screenshotstatus.rb
45
45
  - lib/grabzit/watermark.rb
46
46
  - lib/grabzit/exception.rb
47
+ - lib/grabzit/baseoptions.rb
48
+ - lib/grabzit/utility.rb
49
+ - lib/grabzit/animationoptions.rb
50
+ - lib/grabzit/request.rb
51
+ - lib/grabzit/tableoptions.rb
52
+ - lib/grabzit/imageoptions.rb
53
+ - lib/grabzit/pdfoptions.rb
47
54
  - test/test.png
48
55
  - test/test_grabzit.rb
49
56
  homepage: http://grabz.it/api/ruby
@@ -71,3 +78,4 @@ signing_key:
71
78
  specification_version: 3
72
79
  summary: GrabzIt Ruby Client
73
80
  test_files: []
81
+ has_rdoc: