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/lib/grabzit/animationoptions.rb +187 -0
- data/lib/grabzit/baseoptions.rb +59 -0
- data/lib/grabzit/client.rb +191 -219
- data/lib/grabzit/cookie.rb +2 -2
- data/lib/grabzit/exception.rb +3 -2
- data/lib/grabzit/imageoptions.rb +185 -0
- data/lib/grabzit/pdfoptions.rb +266 -0
- data/lib/grabzit/request.rb +36 -0
- data/lib/grabzit/screenshotstatus.rb +2 -2
- data/lib/grabzit/tableoptions.rb +126 -0
- data/lib/grabzit/utility.rb +31 -0
- data/lib/grabzit/watermark.rb +2 -2
- data/test/test_grabzit.rb +54 -47
- metadata +15 -7
@@ -0,0 +1,187 @@
|
|
1
|
+
module GrabzIt
|
2
|
+
require File.join(File.dirname(__FILE__), 'baseoptions')
|
3
|
+
|
4
|
+
# Represents all of the options available when creating an animated GIF
|
5
|
+
# @version 3.0
|
6
|
+
# @author GrabzIt
|
7
|
+
class AnimationOptions < BaseOptions
|
8
|
+
def initialize()
|
9
|
+
@width = 0
|
10
|
+
@height = 0
|
11
|
+
@start = 0
|
12
|
+
@duration = 0
|
13
|
+
@speed = 0
|
14
|
+
@framesPerSecond = 0
|
15
|
+
@repeat = 0
|
16
|
+
@reverse = false
|
17
|
+
@customWaterMarkId = nil
|
18
|
+
@quality = -1
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [Integer] the width of the resulting animated GIF in pixels
|
22
|
+
def width
|
23
|
+
@width
|
24
|
+
end
|
25
|
+
|
26
|
+
# Set the width of the resulting animated GIF in pixels
|
27
|
+
#
|
28
|
+
# @param value [Integer] the width
|
29
|
+
# @return [void]
|
30
|
+
def width(value)
|
31
|
+
@width = value
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Integer] the height of the resulting animated GIF in pixels
|
35
|
+
def height
|
36
|
+
@height
|
37
|
+
end
|
38
|
+
|
39
|
+
# Set the height of the resulting animated GIF in pixels
|
40
|
+
#
|
41
|
+
# @param value [Integer] the height
|
42
|
+
# @return [void]
|
43
|
+
def height(value)
|
44
|
+
@height = value
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [Integer] the starting position of the video that should be converted into an animated GIF
|
48
|
+
def start
|
49
|
+
@start
|
50
|
+
end
|
51
|
+
|
52
|
+
# Set the starting position of the video that should be converted into an animated GIF
|
53
|
+
#
|
54
|
+
# @param value [Integer] the second to start at
|
55
|
+
# @return [void]
|
56
|
+
def start(value)
|
57
|
+
@start = value
|
58
|
+
end
|
59
|
+
|
60
|
+
# @return [Integer] the length in seconds of the video that should be converted into a animated GIF
|
61
|
+
def duration
|
62
|
+
@duration
|
63
|
+
end
|
64
|
+
|
65
|
+
# Set the length in seconds of the video that should be converted into a animated GIF
|
66
|
+
#
|
67
|
+
# @param value [Integer] the number of seconds
|
68
|
+
# @return [void]
|
69
|
+
def duration(value)
|
70
|
+
@duration = value
|
71
|
+
end
|
72
|
+
|
73
|
+
# @return [Float] the speed of the animated GIF
|
74
|
+
def speed
|
75
|
+
@speed
|
76
|
+
end
|
77
|
+
|
78
|
+
# Set the speed of the animated GIF from 0.2 to 10 times the original speed
|
79
|
+
#
|
80
|
+
# @param value [Float] the speed
|
81
|
+
# @return [void]
|
82
|
+
def speed(value)
|
83
|
+
@speed = value
|
84
|
+
end
|
85
|
+
|
86
|
+
# @return [Float] the number of frames per second that should be captured from the video
|
87
|
+
def framesPerSecond
|
88
|
+
@framesPerSecond
|
89
|
+
end
|
90
|
+
|
91
|
+
# Set the number of frames per second that should be captured from the video. From a minimum of 0.2 to a maximum of 60
|
92
|
+
#
|
93
|
+
# @param value [Float] the number of frames per second
|
94
|
+
# @return [void]
|
95
|
+
def framesPerSecond(value)
|
96
|
+
@framesPerSecond = value
|
97
|
+
end
|
98
|
+
|
99
|
+
# @return [Integer] the number of times to loop the animated GIF
|
100
|
+
def repeat
|
101
|
+
@repeat
|
102
|
+
end
|
103
|
+
|
104
|
+
# Set the number of times to loop the animated GIF. If 0 it will loop forever
|
105
|
+
#
|
106
|
+
# @param value [Integer] the number of times to loop
|
107
|
+
# @return [void]
|
108
|
+
def repeat(value)
|
109
|
+
@repeat = value
|
110
|
+
end
|
111
|
+
|
112
|
+
# @return [Boolean] if the frames of the animated GIF should be reversed
|
113
|
+
def reverse
|
114
|
+
@reverse
|
115
|
+
end
|
116
|
+
|
117
|
+
# Set to true if the frames of the animated GIF should be reversed
|
118
|
+
#
|
119
|
+
# @param value [Boolean] reverse value
|
120
|
+
# @return [void]
|
121
|
+
def reverse(value)
|
122
|
+
@reverse = value
|
123
|
+
end
|
124
|
+
|
125
|
+
# @return [String] the custom watermark id
|
126
|
+
def customWaterMarkId
|
127
|
+
@customWaterMarkId
|
128
|
+
end
|
129
|
+
|
130
|
+
# Set a custom watermark to add to the animated GIF
|
131
|
+
#
|
132
|
+
# @param value [String] custom watermark id
|
133
|
+
# @return [void]
|
134
|
+
def customWaterMarkId(value)
|
135
|
+
@customWaterMarkId = value
|
136
|
+
end
|
137
|
+
|
138
|
+
# @return [Integer] the quality of the animated GIF
|
139
|
+
def quality
|
140
|
+
@quality
|
141
|
+
end
|
142
|
+
|
143
|
+
# Set the quality of the image where 0 is poor and 100 excellent. The default is -1 which uses the recommended quality
|
144
|
+
#
|
145
|
+
# @param value [Integer] the custom identifier
|
146
|
+
# @return [void]
|
147
|
+
def quality(value)
|
148
|
+
@quality = value
|
149
|
+
end
|
150
|
+
|
151
|
+
# @!visibility private
|
152
|
+
def _getSignatureString(applicationSecret, callBackURL, url = nil)
|
153
|
+
urlParam = ''
|
154
|
+
if (url != nil)
|
155
|
+
urlParam = GrabzIt::Utility.nil_check(url)+"|"
|
156
|
+
end
|
157
|
+
|
158
|
+
callBackURLParam = ''
|
159
|
+
if (callBackURL != nil)
|
160
|
+
callBackURLParam = GrabzIt::Utility.nil_check(callBackURL)
|
161
|
+
end
|
162
|
+
|
163
|
+
return applicationSecret+"|"+ urlParam + callBackURLParam +
|
164
|
+
"|"+GrabzIt::Utility.nil_int_check(@height)+"|"+GrabzIt::Utility.nil_int_check(@width)+"|"+GrabzIt::Utility.nil_check(@customId)+"|"+
|
165
|
+
GrabzIt::Utility.nil_float_check(@framesPerSecond)+"|"+GrabzIt::Utility.nil_float_check(@speed)+"|"+GrabzIt::Utility.nil_int_check(@duration)+
|
166
|
+
"|"+GrabzIt::Utility.nil_int_check(@repeat)+"|"+GrabzIt::Utility.b_to_str(@reverse)+"|"+GrabzIt::Utility.nil_int_check(@start)+
|
167
|
+
"|"+GrabzIt::Utility.nil_check(@customWaterMarkId)+"|"+GrabzIt::Utility.nil_check(@country)+"|"+GrabzIt::Utility.nil_int_check(@quality)
|
168
|
+
end
|
169
|
+
|
170
|
+
# @!visibility private
|
171
|
+
def _getParameters(applicationKey, sig, callBackURL, dataName, dataValue)
|
172
|
+
params = createParameters(applicationKey, sig, callBackURL, dataName, dataValue)
|
173
|
+
params['width'] = GrabzIt::Utility.nil_int_check(@width)
|
174
|
+
params['height'] = GrabzIt::Utility.nil_int_check(@height)
|
175
|
+
params['duration'] = GrabzIt::Utility.nil_int_check(@duration)
|
176
|
+
params['speed'] = GrabzIt::Utility.nil_float_check(@speed)
|
177
|
+
params['customwatermarkid'] = GrabzIt::Utility.nil_check(@customWaterMarkId)
|
178
|
+
params['start'] = GrabzIt::Utility.nil_int_check(@start)
|
179
|
+
params['fps'] = GrabzIt::Utility.nil_float_check(@framesPerSecond)
|
180
|
+
params['repeat'] = GrabzIt::Utility.nil_int_check(@repeat)
|
181
|
+
params['reverse'] = GrabzIt::Utility.b_to_str(@reverse)
|
182
|
+
params['quality'] = GrabzIt::Utility.nil_int_check(@quality)
|
183
|
+
|
184
|
+
return params
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module GrabzIt
|
2
|
+
# @version 3.0
|
3
|
+
# @author GrabzIt
|
4
|
+
class BaseOptions
|
5
|
+
# @!visibility private
|
6
|
+
def initialize()
|
7
|
+
@customId = nil
|
8
|
+
@country = nil
|
9
|
+
@delay = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
# @return [String] the custom identifier that you can pass through to the web service.
|
13
|
+
def customId
|
14
|
+
@customId
|
15
|
+
end
|
16
|
+
|
17
|
+
# Set a custom identifier to pass to the web service. This will be returned with the callback URL you have specified.
|
18
|
+
#
|
19
|
+
# @param value [String] the custom identifier
|
20
|
+
# @return [void]
|
21
|
+
def customId(value)
|
22
|
+
@customId = value
|
23
|
+
end
|
24
|
+
|
25
|
+
# @return [String] the country the capture should be created from.
|
26
|
+
def country
|
27
|
+
@country
|
28
|
+
end
|
29
|
+
|
30
|
+
# Set the country the capture should be created from: Default = "", UK = "UK", US = "US".
|
31
|
+
#
|
32
|
+
# @param value [String] the country to use
|
33
|
+
# @return [void]
|
34
|
+
def country(value)
|
35
|
+
@country = value
|
36
|
+
end
|
37
|
+
|
38
|
+
# @!visibility private
|
39
|
+
def startDelay
|
40
|
+
if @delay == nil
|
41
|
+
return 0
|
42
|
+
end
|
43
|
+
return @delay
|
44
|
+
end
|
45
|
+
|
46
|
+
protected
|
47
|
+
def createParameters(applicationKey, sig, callBackURL, dataName, dataValue)
|
48
|
+
params = Hash.new
|
49
|
+
params['key'] = GrabzIt::Utility.nil_check(applicationKey);
|
50
|
+
params['country'] = GrabzIt::Utility.nil_check(@country);
|
51
|
+
params['customid'] = GrabzIt::Utility.nil_check(@customId);
|
52
|
+
params['callback'] = GrabzIt::Utility.nil_check(callBackURL);
|
53
|
+
params['sig'] = sig;
|
54
|
+
params[dataName] = GrabzIt::Utility.nil_check(dataValue);
|
55
|
+
|
56
|
+
return params
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|