grabzit 3.0.1 → 3.0.2

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmY2Y2M1Y2Q1MmZkMDQzZTFkN2UwYmY0N2ZhMDRhMDI5MGViMDdmMQ==
4
+ OTMzZTZhODI3NzVlMDk4M2I1ZTQ3NTRiNDQxNGM2ZWQ4YWJhODM3OA==
5
5
  data.tar.gz: !binary |-
6
- OGFmMzMxNGY2N2ZhMGJjYmU1NGNlZjI5ZjY4YmM3NzlmYmZiNWVmZg==
6
+ YjBkNDZlMTYwZTJjYmM1OTI3ZDRiNTg1M2Y1MDFmZWQzNmJmMGZiYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTVlYTZkNWZmZmMxNWY5NWNhYjIxZThhZDFmMTU5OGNhZGQ3MDFlNDNiNDQw
10
- NDlhY2FlMGNiYTA2M2UwMTJjNzc0MjQ5MzdkMWNjYTQ2ZmExNjExMzcyNGZh
11
- MjQ5MjM0OTYyNTBhNDNjZGI2NjAwZWQxZTcxOWIxYTVmMDNiZTE=
9
+ OGQ1OTUzNWYxMzM2MWJkZDQ3MzNjYWFmYzQ3ZGY4ZmNlODg3NTU0YmI5MjUw
10
+ ZTliYWMwYmNjOWQ4MzdhNzBiMTFiNDY2YjNlZTY1ODMzMTY5Y2QzODkzYTNm
11
+ YTE5YTE0MmQ0MjNmYTBhMGVjNzRmNGY5Y2JlNjQ2ZGFkNTczY2I=
12
12
  data.tar.gz: !binary |-
13
- MzYzOWUxMWMzODY4YmVlZGVmYTI4NmQyYmYyOWNkZTAwMzY4NWM0MmE3MDI3
14
- ZWRmYzBlMzgyZDAzNWVmZjNmZWY3MWI1OWQyZjA3ODY3MzBjNjBkZjRjYzUx
15
- OGIyY2IzZjVlMzk5NzhlN2UzODRlZGNkYzNkNWIxNGQyMmU4ZjI=
13
+ ZWM1Mjk2Y2JlODdkMzg5ZTI3MDU5YjVmNmM2ODBiMjVmMzJhMDk2Y2RmZjkx
14
+ ZTMwODM3MjVlM2QzMDcxNGU3N2Y2NmIxNzVjNTUxYmJiYTMxNTA1OWZmYjUw
15
+ NTI5NDZmNzhjZThmYTliNWRjOTBiODcxNzdiZWUwMmIwZGFlMDM=
@@ -60,7 +60,9 @@ module GrabzIt
60
60
  PARAMETER_INVALID_ANIMATION_COMBINATION = 155
61
61
  PARAMETER_START_TOO_SMALL = 156
62
62
  PARAMETER_DURATION_TOO_LARGE = 157
63
- PARAMETER_NO_HTML = 163
63
+ PARAMETER_NO_HTML = 163
64
+ PARAMETER_INVALID_TARGET_VALUE = 165
65
+ PARAMETER_INVALID_HIDE_VALUE = 166
64
66
  NETWORK_SERVER_OFFLINE = 200
65
67
  NETWORK_GENERAL_ERROR = 201
66
68
  NETWORK_DDOS_ATTACK = 202
@@ -12,6 +12,7 @@ module GrabzIt
12
12
  @height = nil
13
13
  @format = nil
14
14
  @targetElement = nil
15
+ @hideElement = nil
15
16
  @requestAs = 0
16
17
  @customWaterMarkId = nil
17
18
  @quality = -1
@@ -95,18 +96,31 @@ module GrabzIt
95
96
  @delay = value
96
97
  end
97
98
 
98
- # @return [String] get the id of the only HTML element in the web page to turn into a screenshot
99
+ # @return [String] get the CSS selector of the only HTML element in the web page to capture
99
100
  def targetElement
100
101
  @targetElement
101
102
  end
102
103
 
103
- # Set the id of the only HTML element in the web page to turn into a screenshot
104
+ # Set the CSS selector of the only HTML element in the web page to capture
104
105
  #
105
106
  # @param value [String] the target element
106
107
  # @return [void]
107
108
  def targetElement(value)
108
109
  @targetElement = value
109
- end
110
+ end
111
+
112
+ # @return [String] get the CSS selector(s) of the one or more HTML elements in the web page to hide
113
+ def hideElement
114
+ @hideElement
115
+ end
116
+
117
+ # Set the CSS selector(s) of the one or more HTML elements in the web page to hide
118
+ #
119
+ # @param value [String] the element(s) to hide
120
+ # @return [void]
121
+ def hideElement(value)
122
+ @hideElement = value
123
+ end
110
124
 
111
125
  # @return [Integer] get which user agent type should be used
112
126
  def requestAs
@@ -142,7 +156,7 @@ module GrabzIt
142
156
  # Set the quality of the screenshot where 0 is poor and 100 excellent. The default is -1 which uses the recommended quality
143
157
  #
144
158
  # @param value [Integer] the custom identifier
145
- # @return [void]
159
+ # @return [void]
146
160
  def quality(value)
147
161
  @quality = value
148
162
  end
@@ -152,17 +166,17 @@ module GrabzIt
152
166
  urlParam = ''
153
167
  if (url != nil)
154
168
  urlParam = GrabzIt::Utility.nil_check(url)+"|"
155
- end
169
+ end
156
170
 
157
171
  callBackURLParam = ''
158
172
  if (callBackURL != nil)
159
173
  callBackURLParam = GrabzIt::Utility.nil_check(callBackURL)
160
- end
174
+ end
161
175
 
162
176
  return applicationSecret+"|"+ urlParam + callBackURLParam +
163
177
  "|"+GrabzIt::Utility.nil_check(@format)+"|"+GrabzIt::Utility.nil_int_check(@height)+"|"+GrabzIt::Utility.nil_int_check(@width)+"|"+GrabzIt::Utility.nil_int_check(@browserHeight)+
164
178
  "|"+GrabzIt::Utility.nil_int_check(@browserWidth)+"|"+GrabzIt::Utility.nil_check(@customId)+"|"+GrabzIt::Utility.nil_int_check(@delay)+"|"+GrabzIt::Utility.nil_check(@targetElement)+
165
- "|"+GrabzIt::Utility.nil_check(@customWaterMarkId)+"|"+GrabzIt::Utility.nil_int_check(@requestAs)+"|"+GrabzIt::Utility.nil_check(@country)+"|"+GrabzIt::Utility.nil_int_check(@quality)
179
+ "|"+GrabzIt::Utility.nil_check(@customWaterMarkId)+"|"+GrabzIt::Utility.nil_int_check(@requestAs)+"|"+GrabzIt::Utility.nil_check(@country)+"|"+GrabzIt::Utility.nil_int_check(@quality)+"|"+GrabzIt::Utility.nil_check(@hideElement)
166
180
  end
167
181
 
168
182
  # @!visibility private
@@ -176,6 +190,7 @@ module GrabzIt
176
190
  params['bheight'] = GrabzIt::Utility.nil_int_check(@browserHeight)
177
191
  params['delay'] = GrabzIt::Utility.nil_int_check(@delay)
178
192
  params['target'] = GrabzIt::Utility.nil_check(@targetElement)
193
+ params['hide'] = GrabzIt::Utility.nil_check(@hideElement)
179
194
  params['requestmobileversion'] = GrabzIt::Utility.nil_int_check(@requestAs)
180
195
  params['quality'] = GrabzIt::Utility.nil_int_check(@quality)
181
196
 
@@ -21,6 +21,7 @@ module GrabzIt
21
21
  @templateId = nil
22
22
  @customWaterMarkId = nil
23
23
  @quality = -1
24
+ @hideElement = nil
24
25
  end
25
26
 
26
27
  # @return [Boolean] true if the background of the web page should be included in the PDF
@@ -218,6 +219,19 @@ module GrabzIt
218
219
  # @return [void]
219
220
  def quality(value)
220
221
  @quality = value
222
+ end
223
+
224
+ # @return [String] get the CSS selector(s) of the one or more HTML elements in the web page to hide
225
+ def hideElement
226
+ @hideElement
227
+ end
228
+
229
+ # Set the CSS selector(s) of the one or more HTML elements in the web page to hide
230
+ #
231
+ # @param value [String] the element(s) to hide
232
+ # @return [void]
233
+ def hideElement(value)
234
+ @hideElement = value
221
235
  end
222
236
 
223
237
  # @!visibility private
@@ -237,7 +251,7 @@ module GrabzIt
237
251
  GrabzIt::Utility.nil_check(@customWaterMarkId)+"|"+GrabzIt::Utility.b_to_str(@includeLinks)+"|"+GrabzIt::Utility.b_to_str(@includeOutline)+"|"+
238
252
  GrabzIt::Utility.nil_check(@title)+"|"+GrabzIt::Utility.nil_check(@coverURL)+"|"+GrabzIt::Utility.nil_int_check(@marginTop)+"|"+GrabzIt::Utility.nil_int_check(@marginLeft)+
239
253
  "|"+GrabzIt::Utility.nil_int_check(@marginBottom)+"|"+GrabzIt::Utility.nil_int_check(@marginRight)+"|"+GrabzIt::Utility.nil_int_check(@delay)+"|"+
240
- GrabzIt::Utility.nil_int_check(@requestAs)+"|"+GrabzIt::Utility.nil_check(@country)+"|"+GrabzIt::Utility.nil_int_check(@quality)+"|"+GrabzIt::Utility.nil_check(@templateId)
254
+ GrabzIt::Utility.nil_int_check(@requestAs)+"|"+GrabzIt::Utility.nil_check(@country)+"|"+GrabzIt::Utility.nil_int_check(@quality)+"|"+GrabzIt::Utility.nil_check(@templateId)+"|"+GrabzIt::Utility.nil_check(@hideElement)
241
255
  end
242
256
 
243
257
  # @!visibility private
@@ -258,7 +272,8 @@ module GrabzIt
258
272
  params['mbottom'] = GrabzIt::Utility.nil_int_check(@marginBottom)
259
273
  params['delay'] = GrabzIt::Utility.nil_int_check(@delay)
260
274
  params['requestmobileversion'] = GrabzIt::Utility.nil_int_check(@requestAs)
261
- params['quality'] = GrabzIt::Utility.nil_int_check(@quality)
275
+ params['quality'] = GrabzIt::Utility.nil_int_check(@quality)
276
+ params['hide'] = GrabzIt::Utility.nil_check(@hideElement)
262
277
 
263
278
  return params;
264
279
  end
data/test/test_grabzit.rb CHANGED
@@ -213,16 +213,38 @@ class GrabzItTest < Test::Unit::TestCase
213
213
  end
214
214
  end
215
215
 
216
- def test_take_image_options
216
+ def test_take_pdf_hide_popup
217
+ assert_nothing_raised "An error occured when trying to take a pdf screenshot" do
218
+ grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
219
+ options = GrabzIt::PDFOptions.new()
220
+ options.hideElement(".ArevicoModal-bg,.ArevicoModal")
221
+ options.delay(30000)
222
+ grabzItClient.url_to_pdf("http://www.itnews24hrs.com/2016/05/turnkey-lender/", options)
223
+ assert_not_nil(grabzItClient.save(), "Failed to take screenshot using test_take_pdf_hide_popup method")
224
+ end
225
+ end
226
+
227
+ def test_take_image
217
228
  assert_nothing_raised "An error occured when trying to take a image screenshot" do
218
229
  grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
219
230
  options = GrabzIt::ImageOptions.new()
220
231
  options.customWaterMarkId("GrabzIt_Browser")
221
232
  grabzItClient.url_to_image("http://www.google.com", options)
222
- assert_not_nil(grabzItClient.save(), "Failed to take screenshot using set_image_options method")
233
+ assert_not_nil(grabzItClient.save(), "Failed to take screenshot using url_to_image method")
223
234
  end
224
235
  end
225
236
 
237
+ def test_take_image_hide_popup
238
+ assert_nothing_raised "An error occured when trying to take a image screenshot" do
239
+ grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
240
+ options = GrabzIt::ImageOptions.new()
241
+ options.hideElement(".ArevicoModal-bg,.ArevicoModal")
242
+ options.delay(30000)
243
+ grabzItClient.url_to_image("http://www.itnews24hrs.com/2016/05/turnkey-lender/", options)
244
+ assert_not_nil(grabzItClient.save(), "Failed to take screenshot using test_take_image_hide_popup method")
245
+ end
246
+ end
247
+
226
248
  def test_take_unicode_url_image
227
249
  assert_nothing_raised "An error occured when trying to take a image screenshot with a unicode URL" do
228
250
  grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grabzit
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - GrabzIt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-25 00:00:00.000000000 Z
11
+ date: 2017-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -50,7 +50,7 @@ files:
50
50
  - lib/grabzit/watermark.rb
51
51
  - test/test.png
52
52
  - test/test_grabzit.rb
53
- homepage: http://grabz.it/api/ruby
53
+ homepage: https://grabz.it/api/ruby
54
54
  licenses:
55
55
  - MIT
56
56
  metadata: {}