grabzit 2.1.0 → 2.1.1
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 +4 -4
- data/lib/grabzit/client.rb +9 -4
- data/test/test_grabzit.rb +11 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d2223ca515903553cf12b990e3f90de7f44b239
|
4
|
+
data.tar.gz: 0e58d1f65e7ddb1a7787f4bf06c70eb87a7e5a19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f7c74b1277bb39194c3fe7e276b7fa818e13480b2d027b79ecb55989f332cdd90fedbe4d061d4364f7daacc54475153685c929fb0d8a4e624fb5e45c377ab0e
|
7
|
+
data.tar.gz: aad07f06798f3b0271c2986a92001d102a1c4711eee711765cd7cb6d8006fff80f9cb265c80aeb79874225dfb341f0c68970477651542489f6316032c2fecac8
|
data/lib/grabzit/client.rb
CHANGED
@@ -144,15 +144,16 @@ module GrabzIt
|
|
144
144
|
return get_result_value(get(@@request), "ID")
|
145
145
|
end
|
146
146
|
|
147
|
-
# Calls the GrabzIt web service to take the screenshot and saves it to the target path provided
|
147
|
+
# Calls the GrabzIt web service to take the screenshot and saves it to the target path provided. if no target path is provided
|
148
|
+
# it returns the screenshot byte data.
|
148
149
|
#
|
149
150
|
# @note Warning, this is a SYNCHONOUS method and can take up to 5 minutes before a response
|
150
|
-
# @param saveToFile [String] the file path that the screenshot should saved to.
|
151
|
+
# @param saveToFile [String, nil] the file path that the screenshot should saved to.
|
151
152
|
# @example Synchronously save the screenshot to test.jpg
|
152
153
|
# save_to('images/test.jpg')
|
153
154
|
# @raise [RuntimeError] if the screenshot cannot be saved a RuntimeError will be raised that will contain an explanation
|
154
|
-
# @return [Boolean] returns the true if it is
|
155
|
-
def save_to(saveToFile)
|
155
|
+
# @return [Boolean] returns the true if it is successfully saved to a file, otherwise if a target path is not provided it returns the screenshot's byte data.
|
156
|
+
def save_to(saveToFile = nil)
|
156
157
|
id = save()
|
157
158
|
|
158
159
|
if id == nil || id == ""
|
@@ -172,6 +173,10 @@ module GrabzIt
|
|
172
173
|
raise GrabzItException.new("The screenshot could not be found on GrabzIt.", GrabzItException::RENDERING_MISSING_SCREENSHOT)
|
173
174
|
break
|
174
175
|
end
|
176
|
+
|
177
|
+
if saveToFile == nil || saveToFile == ""
|
178
|
+
return result
|
179
|
+
end
|
175
180
|
|
176
181
|
screenshot = File.new(saveToFile, "wb")
|
177
182
|
screenshot.write(result)
|
data/test/test_grabzit.rb
CHANGED
@@ -56,7 +56,17 @@ class GrabzItTest < Test::Unit::TestCase
|
|
56
56
|
assert_equal(true, File.file?(Screenshot_Path), "Not saved screenshot file")
|
57
57
|
end
|
58
58
|
File.delete(Screenshot_Path)
|
59
|
-
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_save_to_bytes
|
62
|
+
assert_nothing_raised "An error occured when trying to take a image screenshot" do
|
63
|
+
grabzItClient = GrabzIt::Client.new(@applicationKey, @applicationSecret)
|
64
|
+
grabzItClient.set_image_options("http://www.google.com")
|
65
|
+
val = grabzItClient.save_to();
|
66
|
+
assert_not_nil(val, "Screenshot not returned as bytes")
|
67
|
+
assert_not_equal(false, val, "An error occured attempting to save data to byte variable")
|
68
|
+
end
|
69
|
+
end
|
60
70
|
|
61
71
|
def test_status
|
62
72
|
assert_nothing_raised "An error occured when trying to test the status method" do
|
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: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GrabzIt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|