screenshot_capture 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +197 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/example/example.rb +22 -0
- data/example/example_w_export.rb +23 -0
- data/example/example_w_filename.rb +23 -0
- data/lib/screenshot_capture.rb +167 -0
- data/lib/screenshot_capture/missing_argument_exception.rb +13 -0
- data/lib/screenshot_capture/version.rb +3 -0
- data/screenshot_capture.gemspec +38 -0
- data/screenshot_capture.iml +34 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a2ee2d8ec46e7d64418014768a743134344f3f9c
|
4
|
+
data.tar.gz: 36d9d60710b3b12c66b2cb651cea33b61efce299
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8c04d53bbd31d4d2b37167d1b3082f4f0213d596e9d15e36a9766e0b8399b8069940f6763a387bc9d31ffbda4e40dfdd3617bef51ab14cf622808cda6df8e8db
|
7
|
+
data.tar.gz: 68d34b65da8208c8192bc4315763cf5d622b5cc2b11ad0a0de8896130a7870ae352872c4eaed0d8357a416dae3aff537192452cd99deded152ac44c9fb0a8d26
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at github@petermolgaard.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Peter Andreas Moelgaard
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
[![Travis](https://travis-ci.org/pmoelgaard/screenshot_capture.svg)](Travis)
|
2
|
+
|
3
|
+
# screenshot_capture
|
4
|
+
Ruby Library for [the screenshotlayer API](https://screenshotlayer.com/).
|
5
|
+
Capture highly customizable snapshots of any website. Powerful Screenshot API for any application
|
6
|
+
|
7
|
+
---
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```
|
14
|
+
gem 'screenshot_capture'
|
15
|
+
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
```
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
```
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
```
|
28
|
+
$ gem install screenshot_capture
|
29
|
+
|
30
|
+
```
|
31
|
+
|
32
|
+
---
|
33
|
+
|
34
|
+
## Configuration
|
35
|
+
|
36
|
+
Before using the screenshotlayer API client you have to setup your account and obtain your API Access Key.
|
37
|
+
You can get it by signing up at [https://screenshotlayer.com/product](https://screenshotlayer.com/product).
|
38
|
+
|
39
|
+
---
|
40
|
+
|
41
|
+
## API Overview
|
42
|
+
All endpoints in the public API is available through this library.
|
43
|
+
|
44
|
+
- capture
|
45
|
+
|
46
|
+
---
|
47
|
+
|
48
|
+
## Usage
|
49
|
+
|
50
|
+
The general API is documented here: [https://pdflayer.com/documentation](https://screenshotlayer.com/documentation).
|
51
|
+
You can find parameters, result set definitions and status codes documented here as well.
|
52
|
+
|
53
|
+
In the examples directory you can find demos and samples of general usage of all the API functions.
|
54
|
+
|
55
|
+
### Setup
|
56
|
+
|
57
|
+
```
|
58
|
+
@client = ScreenshotLayer::Client.new( [access_key], [secret_keyword] )
|
59
|
+
|
60
|
+
```
|
61
|
+
|
62
|
+
#### Required Parameters
|
63
|
+
|
64
|
+
###### access_key
|
65
|
+
Your unique key that you can find on the dashboard of your account under the screenshotlayer account.
|
66
|
+
|
67
|
+
###### secret_key
|
68
|
+
A userdefined private key that you can find on the dashboard of your account under the screenshotlayer account, it's used to encrypt parameters to prevent unauthorised usage of your account.
|
69
|
+
|
70
|
+
#### Optional Parameters
|
71
|
+
|
72
|
+
###### Secure (only available for Basic, Pro and Enterprise accounts)
|
73
|
+
Boolean value to indicate if the calls to the API should use a secure protocol or insecure (HTTP/HTTPS). Defaults to false (HTTP, insecure).
|
74
|
+
|
75
|
+
---
|
76
|
+
|
77
|
+
## Convert (simple case)
|
78
|
+
|
79
|
+
Takes a URL and returns the captured image.
|
80
|
+
|
81
|
+
###### Define Query
|
82
|
+
Second we define an options object.
|
83
|
+
All the options are documented here: [https://screenshotlayer.com/documentation](https://screenshotlayer.com/documentation)
|
84
|
+
|
85
|
+
```
|
86
|
+
options = ScreenshotLayer::CaptureOptions.new()
|
87
|
+
|
88
|
+
```
|
89
|
+
|
90
|
+
###### Call Client
|
91
|
+
We then place the actual call to the API, passing in the URL we wish to capture as PDF and the options we defined above.
|
92
|
+
|
93
|
+
```
|
94
|
+
response = @client.capture(url, options)
|
95
|
+
|
96
|
+
```
|
97
|
+
|
98
|
+
###### Response
|
99
|
+
|
100
|
+
```
|
101
|
+
[The binary content of the image file] (Defaults to PNG)
|
102
|
+
|
103
|
+
```
|
104
|
+
|
105
|
+
---
|
106
|
+
|
107
|
+
## Capture (w. filename)
|
108
|
+
|
109
|
+
Takes a URL, saves the image to a local file defined by the export argument and returns a response object.
|
110
|
+
|
111
|
+
###### Define Query
|
112
|
+
|
113
|
+
We define an options object, and sets the ```filename``` option.
|
114
|
+
This option is specific to the RubyGem and not documented in the API found on screenshotlayer.
|
115
|
+
If the directory doesn't exist, it will be created.
|
116
|
+
|
117
|
+
```
|
118
|
+
options = ScreenshotLayer::CaptureOptions.new()
|
119
|
+
options.filename = '[local_file_system]/some_directory]/my_file.png'
|
120
|
+
|
121
|
+
```
|
122
|
+
|
123
|
+
###### Simple Request (using Callback)
|
124
|
+
|
125
|
+
```
|
126
|
+
response = @client.capture(url, options)
|
127
|
+
|
128
|
+
```
|
129
|
+
|
130
|
+
###### Response
|
131
|
+
```
|
132
|
+
{
|
133
|
+
"success": true,
|
134
|
+
"info": "The image has been saved to your local file system",
|
135
|
+
"file_name": "path_to_local_file.png"
|
136
|
+
}
|
137
|
+
```
|
138
|
+
|
139
|
+
---
|
140
|
+
|
141
|
+
## Example Application
|
142
|
+
|
143
|
+
In the [rootdir]/example directory there is a fully functional application which runs all requests against all the endpoints in the API, the examples above can be seen there as source code.
|
144
|
+
|
145
|
+
The example application uses a process.env variable to hold the access key.
|
146
|
+
|
147
|
+
---
|
148
|
+
|
149
|
+
## Tests
|
150
|
+
|
151
|
+
The tests are written using the rspec testing library.
|
152
|
+
**RSpec** [http://rspec.info/](http://rspec.info/)
|
153
|
+
|
154
|
+
In order to run the tests, the following environment variables needs to be set:
|
155
|
+
|
156
|
+
```
|
157
|
+
ACCESS_KEY = [access_key]
|
158
|
+
SECRET_KEYWORD = [secret_keyword]
|
159
|
+
EXPORT_FTP = [path_to_ftp_account]
|
160
|
+
```
|
161
|
+
|
162
|
+
|
163
|
+
---
|
164
|
+
|
165
|
+
## Customer Support
|
166
|
+
|
167
|
+
Need any assistance? [Get in touch with Customer Support](mailto:support@apilayer.net?subject=%screenshotlayer%5D).
|
168
|
+
|
169
|
+
---
|
170
|
+
|
171
|
+
## Updates
|
172
|
+
Stay up to date by following [@apilayernet](https://twitter.com/apilayernet) on Twitter.
|
173
|
+
|
174
|
+
---
|
175
|
+
|
176
|
+
## Legal
|
177
|
+
|
178
|
+
All usage of the languagelayer website, API, and services is subject to the [pdflayer Terms & Conditions](https://pdflayer.com/terms) and all annexed legal documents and agreements.
|
179
|
+
|
180
|
+
---
|
181
|
+
|
182
|
+
## Author
|
183
|
+
Peter Andreas Moelgaard ([GitHub](https://github.com/pmoelgaard), [Twitter](https://twitter.com/petermoelgaard))
|
184
|
+
|
185
|
+
---
|
186
|
+
|
187
|
+
## License
|
188
|
+
Licensed under the The MIT License (MIT)
|
189
|
+
|
190
|
+
Copyright (©) 2016 Peter Andreas Moelgaard & apilayer
|
191
|
+
|
192
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
193
|
+
|
194
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
195
|
+
|
196
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
197
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "screenshot_capture"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/example/example.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'dotenv'
|
2
|
+
require 'screenshot_capture'
|
3
|
+
|
4
|
+
# Load Environment Variables
|
5
|
+
Dotenv.load
|
6
|
+
|
7
|
+
# Declare the Client instance passing in the authentication parameters
|
8
|
+
@client = ScreenshotLayer::Client.new(ENV['ACCESS_KEY'], ENV['SECRET_KEYWORD'])
|
9
|
+
|
10
|
+
# Set the URL for the screenshot, we take a random URL from Wikipedia
|
11
|
+
url = 'https://en.wikipedia.org/wiki/Special:Random'
|
12
|
+
|
13
|
+
# We declare the options
|
14
|
+
options = ScreenshotLayer::CaptureOptions.new()
|
15
|
+
|
16
|
+
# We make the call to convert
|
17
|
+
response = @client.capture(url, options)
|
18
|
+
|
19
|
+
# If its a success, we print a message to the user
|
20
|
+
if ! response.nil?
|
21
|
+
puts 'SUCCESS : Screenshot captured...' << response.length.to_s
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'dotenv'
|
2
|
+
require 'screenshot_capture'
|
3
|
+
|
4
|
+
# Load Environment Variables
|
5
|
+
Dotenv.load
|
6
|
+
|
7
|
+
# Declare the Client instance passing in the authentication parameters
|
8
|
+
@client = ScreenshotLayer::Client.new(ENV['ACCESS_KEY'], ENV['SECRET_KEYWORD'])
|
9
|
+
|
10
|
+
# Set the URL to get as PDF, we take a random URL from Wikipedia
|
11
|
+
url = 'https://en.wikipedia.org/wiki/Special:Random'
|
12
|
+
|
13
|
+
# We declare the options
|
14
|
+
options = ScreenshotLayer::CaptureOptions.new()
|
15
|
+
options.export = ENV['EXPORT_FTP']
|
16
|
+
|
17
|
+
# We make the call to capture
|
18
|
+
response = @client.capture(url, options)
|
19
|
+
|
20
|
+
# If its a success, we print a message to the user
|
21
|
+
if ! response.nil?
|
22
|
+
puts 'SUCCESS : Screenshot Exported...'+ JSON(response)
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'dotenv'
|
2
|
+
require 'screenshot_capture'
|
3
|
+
|
4
|
+
# Load Environment Variables
|
5
|
+
Dotenv.load
|
6
|
+
|
7
|
+
# Declare the Client instance passing in the authentication parameters
|
8
|
+
@client = ScreenshotLayer::Client.new(ENV['ACCESS_KEY'], ENV['SECRET_KEYWORD'])
|
9
|
+
|
10
|
+
# Set the URL to get as PDF, we take a random URL from Wikipedia
|
11
|
+
url = 'https://en.wikipedia.org/wiki/Special:Random'
|
12
|
+
|
13
|
+
# We declare the options
|
14
|
+
options = ScreenshotLayer::CaptureOptions.new()
|
15
|
+
options.filename = File.join('tmp', SecureRandom.uuid() +'.png')
|
16
|
+
|
17
|
+
# We make the call to capture
|
18
|
+
response = @client.capture(url, options)
|
19
|
+
|
20
|
+
# If its a success, we print a message to the user
|
21
|
+
if ! response.nil?
|
22
|
+
puts 'SUCCESS : Screenshot fetched...'+ JSON(response)
|
23
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'digest'
|
3
|
+
require 'fileutils'
|
4
|
+
require "httparty"
|
5
|
+
require "hashable"
|
6
|
+
require "screenshot_capture/version"
|
7
|
+
|
8
|
+
module ScreenshotLayer
|
9
|
+
|
10
|
+
class Client
|
11
|
+
|
12
|
+
include HTTParty
|
13
|
+
|
14
|
+
base_uri 'api.screenshotlayer.com/api'
|
15
|
+
|
16
|
+
def initialize(access_key, secret_keyword)
|
17
|
+
|
18
|
+
if access_key.nil?
|
19
|
+
raise ScreenshotLayer::MissingArgumentException.new 'access_key'
|
20
|
+
end
|
21
|
+
|
22
|
+
if secret_keyword.nil?
|
23
|
+
raise ScreenshotLayer::MissingArgumentException.new 'secret_keyword'
|
24
|
+
end
|
25
|
+
|
26
|
+
@access_key = access_key
|
27
|
+
@secret_keyword = secret_keyword
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def capture(url, options = {})
|
33
|
+
|
34
|
+
if url.nil?
|
35
|
+
raise ScreenshotLayer::MissingArgumentException.new 'url'
|
36
|
+
return
|
37
|
+
end
|
38
|
+
|
39
|
+
# Create a shallow copy so we don't manipulate the original reference
|
40
|
+
query = options.dup
|
41
|
+
|
42
|
+
# Generate the SecretKey for the request
|
43
|
+
md5 = Digest::MD5.new
|
44
|
+
md5.update url + @secret_keyword
|
45
|
+
secret_key = md5.hexdigest
|
46
|
+
|
47
|
+
# Populate the Query
|
48
|
+
query.access_key = @access_key
|
49
|
+
query.secret_key = secret_key
|
50
|
+
query.url = URI.escape(url)
|
51
|
+
|
52
|
+
# We then create the Request
|
53
|
+
req = CaptureRequest.new(query)
|
54
|
+
|
55
|
+
# We create a Hash of the request so we can send it via HTTP
|
56
|
+
req_dto = req.to_dh
|
57
|
+
|
58
|
+
begin
|
59
|
+
|
60
|
+
# We make the actual request
|
61
|
+
res = self.class.get('/capture', req_dto)
|
62
|
+
|
63
|
+
# We ensure that we tap the response so we can use the results
|
64
|
+
res.inspect
|
65
|
+
|
66
|
+
# If we have an export option passed in, we save it to local file system
|
67
|
+
if options.filename.nil?
|
68
|
+
|
69
|
+
# We just return the parsed binary response
|
70
|
+
return res.parsed_response
|
71
|
+
|
72
|
+
else
|
73
|
+
|
74
|
+
begin
|
75
|
+
|
76
|
+
# Ensure the path exists before we write
|
77
|
+
FileUtils.mkdir_p(File.dirname(options.filename))
|
78
|
+
|
79
|
+
File.open(options.filename, 'a+') do |file|
|
80
|
+
|
81
|
+
file.write(res.body)
|
82
|
+
|
83
|
+
result = {
|
84
|
+
success: true,
|
85
|
+
info: ScreenshotLayer::CaptureResponse::INFO_MESSAGE_SUCCESS_FILENAME,
|
86
|
+
file_name: options.filename
|
87
|
+
}
|
88
|
+
return result
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
rescue => e
|
97
|
+
puts e.inspect
|
98
|
+
return
|
99
|
+
|
100
|
+
ensure
|
101
|
+
# Clean Up
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
class CaptureRequest
|
109
|
+
|
110
|
+
include Hashable
|
111
|
+
|
112
|
+
attr_accessor :query
|
113
|
+
|
114
|
+
def initialize(query = {})
|
115
|
+
self.query = query;
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
class CaptureOptions
|
122
|
+
|
123
|
+
include Hashable
|
124
|
+
|
125
|
+
attr_accessor :access_key
|
126
|
+
attr_accessor :secret_key
|
127
|
+
|
128
|
+
attr_accessor :url
|
129
|
+
|
130
|
+
attr_accessor :fullpage
|
131
|
+
attr_accessor :width
|
132
|
+
attr_accessor :viewport
|
133
|
+
attr_accessor :format
|
134
|
+
attr_accessor :css_url
|
135
|
+
attr_accessor :delay
|
136
|
+
attr_accessor :ttl
|
137
|
+
attr_accessor :force
|
138
|
+
attr_accessor :placeholder
|
139
|
+
attr_accessor :user_agent
|
140
|
+
attr_accessor :accept_lang
|
141
|
+
attr_accessor :export
|
142
|
+
attr_accessor :filename
|
143
|
+
|
144
|
+
def initialize()
|
145
|
+
@query = nil
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
|
151
|
+
class CaptureResponse
|
152
|
+
|
153
|
+
SUCCESS_EXPR = 'success'
|
154
|
+
INFO_EXPR = 'info'
|
155
|
+
INFO_MESSAGE_SUCCESS_EXPORT = 'An attempt has been submitted to upload your screenshot to the given path. Please be aware that this process may take up to 1 minute to complete, and there will not be any system notifications in case your upload failed.'
|
156
|
+
INFO_MESSAGE_SUCCESS_FILENAME = 'The Screenshot file has been saved to your local file system.'
|
157
|
+
|
158
|
+
def bar
|
159
|
+
SUCCESS_EXPR
|
160
|
+
INFO_EXPR
|
161
|
+
INFO_MESSAGE_SUCCESS_EXPORT
|
162
|
+
INFO_MESSAGE_SUCCESS_FILENAME
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require 'screenshot_capture/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
|
10
|
+
spec.name = "screenshot_capture"
|
11
|
+
spec.version = ScreenshotLayer::VERSION
|
12
|
+
spec.platform = Gem::Platform::RUBY
|
13
|
+
spec.authors = ["Peter Andreas Moelgaard"]
|
14
|
+
spec.email = ["github@petermolgaard.com"]
|
15
|
+
spec.homepage = "https://github.com/pmoelgaard/screenshot_capture"
|
16
|
+
|
17
|
+
spec.description = "Ruby Library for the screenshotlayer API, a web service that captures highly customizable snapshots of any website, https://screenshotlayer.com/"
|
18
|
+
spec.summary = "Capture highly customizable snapshots of any website. Powerful Screenshot API for any application"
|
19
|
+
|
20
|
+
spec.license = "MIT"
|
21
|
+
|
22
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
spec.bindir = "exe"
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
|
27
|
+
spec.required_ruby_version = '>= 1.9.3'
|
28
|
+
|
29
|
+
spec.add_runtime_dependency "httparty"
|
30
|
+
spec.add_runtime_dependency "hashable"
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
33
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
34
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
35
|
+
spec.add_development_dependency "dotenv"
|
36
|
+
spec.add_development_dependency "bump"
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="FacetManager">
|
4
|
+
<facet type="gem" name="Ruby Gem">
|
5
|
+
<configuration>
|
6
|
+
<option name="GEM_APP_ROOT_PATH" value="" />
|
7
|
+
<option name="GEM_APP_TEST_PATH" value="" />
|
8
|
+
<option name="GEM_APP_LIB_PATH" value="" />
|
9
|
+
</configuration>
|
10
|
+
</facet>
|
11
|
+
</component>
|
12
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
13
|
+
<exclude-output />
|
14
|
+
<content url="file://$MODULE_DIR$">
|
15
|
+
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
16
|
+
</content>
|
17
|
+
<orderEntry type="inheritedJdk" />
|
18
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="bump (v0.5.3, ruby-2.0.0-p645) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.11.2, ruby-2.0.0-p645) [gem]" level="application" />
|
21
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, ruby-2.0.0-p645) [gem]" level="application" />
|
22
|
+
<orderEntry type="library" scope="PROVIDED" name="dotenv (v2.1.0, ruby-2.0.0-p645) [gem]" level="application" />
|
23
|
+
<orderEntry type="library" scope="PROVIDED" name="hashable (v0.1.2, ruby-2.0.0-p645) [gem]" level="application" />
|
24
|
+
<orderEntry type="library" scope="PROVIDED" name="httparty (v0.13.7, ruby-2.0.0-p645) [gem]" level="application" />
|
25
|
+
<orderEntry type="library" scope="PROVIDED" name="json (v1.8.3, ruby-2.0.0-p645) [gem]" level="application" />
|
26
|
+
<orderEntry type="library" scope="PROVIDED" name="multi_xml (v0.5.5, ruby-2.0.0-p645) [gem]" level="application" />
|
27
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v10.5.0, ruby-2.0.0-p645) [gem]" level="application" />
|
28
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.4.0, ruby-2.0.0-p645) [gem]" level="application" />
|
29
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.4.2, ruby-2.0.0-p645) [gem]" level="application" />
|
30
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.4.0, ruby-2.0.0-p645) [gem]" level="application" />
|
31
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.4.1, ruby-2.0.0-p645) [gem]" level="application" />
|
32
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.4.1, ruby-2.0.0-p645) [gem]" level="application" />
|
33
|
+
</component>
|
34
|
+
</module>
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: screenshot_capture
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Peter Andreas Moelgaard
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hashable
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.11'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.11'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: dotenv
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: bump
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Ruby Library for the screenshotlayer API, a web service that captures
|
112
|
+
highly customizable snapshots of any website, https://screenshotlayer.com/
|
113
|
+
email:
|
114
|
+
- github@petermolgaard.com
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- .rspec
|
120
|
+
- .travis.yml
|
121
|
+
- CODE_OF_CONDUCT.md
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/console
|
127
|
+
- bin/setup
|
128
|
+
- example/example.rb
|
129
|
+
- example/example_w_export.rb
|
130
|
+
- example/example_w_filename.rb
|
131
|
+
- lib/screenshot_capture.rb
|
132
|
+
- lib/screenshot_capture/missing_argument_exception.rb
|
133
|
+
- lib/screenshot_capture/version.rb
|
134
|
+
- screenshot_capture.gemspec
|
135
|
+
- screenshot_capture.iml
|
136
|
+
homepage: https://github.com/pmoelgaard/screenshot_capture
|
137
|
+
licenses:
|
138
|
+
- MIT
|
139
|
+
metadata: {}
|
140
|
+
post_install_message:
|
141
|
+
rdoc_options: []
|
142
|
+
require_paths:
|
143
|
+
- lib
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: 1.9.3
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
requirements: []
|
155
|
+
rubyforge_project:
|
156
|
+
rubygems_version: 2.0.14
|
157
|
+
signing_key:
|
158
|
+
specification_version: 4
|
159
|
+
summary: Capture highly customizable snapshots of any website. Powerful Screenshot
|
160
|
+
API for any application
|
161
|
+
test_files: []
|