grabzit 2.0.2 → 2.1.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.
@@ -1,6 +1,6 @@
1
1
  module GrabzIt
2
2
  # This class represents the cookies stored in GrabzIt
3
- # @version 2.0
3
+ # @version 2.1
4
4
  # @author GrabzIt
5
5
  class Cookie
6
6
  # @api private
@@ -0,0 +1,75 @@
1
+ module GrabzIt
2
+ # This class represents the exceptions thrown by GrabzIt
3
+ # @version 2.1
4
+ # @author GrabzIt
5
+ class GrabzItException < Exception
6
+
7
+ SUCCESS = 0
8
+ PARAMETER_NO_URL = 100
9
+ PARAMETER_INVALID_URL = 101
10
+ PARAMETER_NON_EXISTANT_URL = 102
11
+ PARAMETER_MISSING_APPLICATION_KEY = 103
12
+ PARAMETER_UNRECOGNISED_APPLICATION_KEY = 104
13
+ PARAMETER_MISSING_SIGNATURE = 105
14
+ PARAMETER_INVALID_SIGNATURE = 106
15
+ PARAMETER_INVALID_FORMAT = 107
16
+ PARAMETER_INVALID_COUNTRY_CODE = 108
17
+ PARAMETER_DUPLICATE_IDENTIFIER = 109
18
+ PARAMETER_MATCHING_RECORD_NOT_FOUND = 110
19
+ PARAMETER_INVALID_CALLBACK_URL = 111
20
+ PARAMETER_NON_EXISTANT_CALLBACK_URL = 112
21
+ PARAMETER_IMAGE_WIDTH_TOO_LARGE = 113
22
+ PARAMETER_IMAGE_HEIGHT_TOO_LARGE = 114
23
+ PARAMETER_BROWSER_WIDTH_TOO_LARGE = 115
24
+ PARAMETER_BROWSER_HEIGHT_TOO_LARGE = 116
25
+ PARAMETER_DELAY_TOO_LARGE = 117
26
+ PARAMETER_INVALID_BACKGROUND = 118
27
+ PARAMETER_INVALID_INCLUDE_LINKS = 119
28
+ PARAMETER_INVALID_INCLUDE_OUTLINE = 120
29
+ PARAMETER_INVALID_PAGE_SIZE = 121
30
+ PARAMETER_INVALID_PAGE_ORIENTATION = 122
31
+ PARAMETER_VERTICAL_MARGIN_TOO_LARGE = 123
32
+ PARAMETER_HORIZONTAL_MARGIN_TOO_LARGE = 124
33
+ PARAMETER_INVALID_COVER_URL = 125
34
+ PARAMETER_NON_EXISTANT_COVER_URL = 126
35
+ PARAMETER_MISSING_COOKIE_NAME = 127
36
+ PARAMETER_MISSING_COOKIE_DOMAIN = 128
37
+ PARAMETER_INVALID_COOKIE_NAME = 129
38
+ PARAMETER_INVALID_COOKIE_DOMAIN = 130
39
+ PARAMETER_INVALID_COOKIE_DELETE = 131
40
+ PARAMETER_INVALID_COOKIE_HTTP = 132
41
+ PARAMETER_INVALID_COOKIE_EXPIRY = 133
42
+ PARAMETER_INVALID_CACHE_VALUE = 134
43
+ PARAMETER_INVALID_DOWNLOAD_VALUE = 135
44
+ PARAMETER_INVALID_SUPPRESS_VALUE = 136
45
+ PARAMETER_MISSING_WATERMARK_IDENTIFIER = 137
46
+ PARAMETER_INVALID_WATERMARK_IDENTIFIER = 138
47
+ PARAMETER_INVALID_WATERMARK_XPOS = 139
48
+ PARAMETER_INVALID_WATERMARK_YPOS = 140
49
+ PARAMETER_MISSING_WATERMARK_FORMAT = 141
50
+ PARAMETER_WATERMARK_TOO_LARGE = 142
51
+ PARAMETER_MISSING_PARAMETERS = 143
52
+ PARAMETER_QUALITY_TOO_LARGE = 144
53
+ PARAMETER_QUALITY_TOO_SMALL = 145
54
+ NETWORK_SERVER_OFFLINE = 200
55
+ NETWORK_GENERAL_ERROR = 201
56
+ NETWORK_DDOS_ATTACK = 202
57
+ RENDERING_ERROR = 300
58
+ RENDERING_MISSING_SCREENSHOT = 301
59
+ GENERIC_ERROR = 400
60
+ UPGRADE_REQUIRED = 500
61
+ FILE_SAVE_ERROR = 600
62
+ FILE_NON_EXISTANT_PATH = 601
63
+
64
+ # @api private
65
+ def initialize(message, code)
66
+ @Code = code
67
+ super(message)
68
+ end
69
+
70
+ # @return [Integer] the value of the error code
71
+ def code
72
+ @Code
73
+ end
74
+ end
75
+ end
@@ -1,6 +1,6 @@
1
1
  module GrabzIt
2
2
  # This class represents the screenshot status
3
- # @version 2.0
3
+ # @version 2.1
4
4
  # @author GrabzIt
5
5
  class ScreenShotStatus
6
6
  # @api private
@@ -1,6 +1,6 @@
1
1
  module GrabzIt
2
2
  # This class represents the custom watermarks stored in GrabzIt
3
- # @version 2.0
3
+ # @version 2.1
4
4
  # @author GrabzIt
5
5
  class WaterMark
6
6
  # @api private
data/test/test_grabzit.rb CHANGED
@@ -9,8 +9,8 @@ class GrabzItTest < Test::Unit::TestCase
9
9
  Screenshot_Path = "test/tmp.jpg"
10
10
 
11
11
  def setup
12
- @applicationKey = nil
13
- @applicationSecret = nil
12
+ @applicationKey = ""
13
+ @applicationSecret = ""
14
14
  #Set to true if the account is subscribed
15
15
  @isSubscribedAccount = false
16
16
  end
@@ -76,7 +76,7 @@ class GrabzItTest < Test::Unit::TestCase
76
76
  if @isSubscribedAccount
77
77
  grabzItClient.set_cookie(Cookie_Name, Cookie_Domain)
78
78
  elsif
79
- assert_raise RuntimeError, "User not subscribed should throw error. If user is subscribed please set @isSubscribedAccount in the setup method" do
79
+ assert_raise GrabzIt::GrabzItException, "User not subscribed should throw error. If user is subscribed please set @isSubscribedAccount in the setup method" do
80
80
  grabzItClient.set_cookie(Cookie_Name, Cookie_Domain)
81
81
  end
82
82
  return
@@ -92,7 +92,7 @@ class GrabzItTest < Test::Unit::TestCase
92
92
  if @isSubscribedAccount
93
93
  grabzItClient.set_cookie(Cookie_Name, Cookie_Domain)
94
94
  elsif
95
- assert_raise RuntimeError, "User not subscribed should throw error. If user is subscribed please set @isSubscribedAccount in the setup method" do
95
+ assert_raise GrabzIt::GrabzItException, "User not subscribed should throw error. If user is subscribed please set @isSubscribedAccount in the setup method" do
96
96
  grabzItClient.set_cookie(Cookie_Name, Cookie_Domain)
97
97
  end
98
98
  return
@@ -117,7 +117,7 @@ class GrabzItTest < Test::Unit::TestCase
117
117
  if @isSubscribedAccount
118
118
  grabzItClient.add_watermark(WaterMark_Identifier, WaterMark_Path, 2, 2)
119
119
  elsif
120
- assert_raise RuntimeError, "User not subscribed should throw error. If user is subscribed please set @isSubscribedAccount in the setup method" do
120
+ assert_raise GrabzIt::GrabzItException, "User not subscribed should throw error. If user is subscribed please set @isSubscribedAccount in the setup method" do
121
121
  grabzItClient.add_watermark(WaterMark_Identifier, WaterMark_Path, 2, 2)
122
122
  end
123
123
  return
@@ -141,7 +141,7 @@ class GrabzItTest < Test::Unit::TestCase
141
141
  if @isSubscribedAccount
142
142
  grabzItClient.add_watermark(WaterMark_Identifier, WaterMark_Path, 2, 2)
143
143
  elsif
144
- assert_raise RuntimeError, "User not subscribed should throw error. If user is subscribed please set @isSubscribedAccount in the setup method" do
144
+ assert_raise GrabzIt::GrabzItException, "User not subscribed should throw error. If user is subscribed please set @isSubscribedAccount in the setup method" do
145
145
  grabzItClient.add_watermark(WaterMark_Identifier, WaterMark_Path, 2, 2)
146
146
  end
147
147
  return
@@ -151,6 +151,15 @@ class GrabzItTest < Test::Unit::TestCase
151
151
  end
152
152
  end
153
153
 
154
+ #def test_Xtreme_DDOS
155
+ # assert_raise RuntimeError, "An error occured when detecting potential DDOS attack." do
156
+ # grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
157
+ # for i in 0..200
158
+ # grabzItClient.get_status("ccxz")
159
+ # end
160
+ # end
161
+ #end
162
+
154
163
  def find_cookie(grabzItClient)
155
164
  cookies = grabzItClient.get_cookies(Cookie_Domain)
156
165
 
@@ -168,18 +177,12 @@ class GrabzItTest < Test::Unit::TestCase
168
177
  end
169
178
 
170
179
  def find_watermark(grabzItClient)
171
- watermarks = grabzItClient.get_watermarks(WaterMark_Identifier)
180
+ watermark = grabzItClient.get_watermark(WaterMark_Identifier)
172
181
 
173
- if watermarks == nil
182
+ if watermark == nil
174
183
  return false
175
184
  end
176
185
 
177
- watermarks.each { |watermark|
178
- if watermark.identifier == WaterMark_Identifier
179
- return true
180
- end
181
- }
182
-
183
- return false
186
+ return true
184
187
  end
185
188
  end
metadata CHANGED
@@ -1,33 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grabzit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
5
- prerelease:
4
+ version: 2.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - GrabzIt
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-27 00:00:00.000000000 Z
11
+ date: 2013-12-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
- description: ! 'Automatically create screenshots of website for free, with GrabzIt.
27
+ description: 'Automatically create screenshots of website for free, with GrabzIt.
31
28
  Screenshots can be output in a variety of formats including: JPEG, PNG, TIFF, BMP,
32
29
  PDF, CSV and XLSX.'
33
30
  email: support@grabz.it
@@ -41,31 +38,31 @@ files:
41
38
  - lib/grabzit/cookie.rb
42
39
  - lib/grabzit/screenshotstatus.rb
43
40
  - lib/grabzit/watermark.rb
41
+ - lib/grabzit/exception.rb
44
42
  - test/test.png
45
43
  - test/test_grabzit.rb
46
44
  homepage: http://grabz.it/api/ruby
47
45
  licenses: []
46
+ metadata: {}
48
47
  post_install_message:
49
48
  rdoc_options: []
50
49
  require_paths:
51
50
  - lib
52
51
  required_ruby_version: !ruby/object:Gem::Requirement
53
- none: false
54
52
  requirements:
55
- - - ! '>='
53
+ - - '>='
56
54
  - !ruby/object:Gem::Version
57
55
  version: '0'
58
56
  required_rubygems_version: !ruby/object:Gem::Requirement
59
- none: false
60
57
  requirements:
61
- - - ! '>='
58
+ - - '>='
62
59
  - !ruby/object:Gem::Version
63
60
  version: '0'
64
61
  requirements: []
65
62
  rubyforge_project:
66
- rubygems_version: 1.8.23
63
+ rubygems_version: 2.0.2
67
64
  signing_key:
68
- specification_version: 3
65
+ specification_version: 4
69
66
  summary: GrabzIt Ruby Client
70
67
  test_files: []
71
68
  has_rdoc: