gastly 0.1.1 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/bin/console +3 -3
- data/gastly.gemspec +1 -1
- data/lib/gastly/screenshot.rb +12 -3
- data/lib/gastly/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65033a39c65ae48403a64c73e28fc8a1de4a7981
|
4
|
+
data.tar.gz: 0bbcc84f2da4bb4ce06524e5952a8b00f1cdb7cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f0105743886cedeca9176dcff78df8cc9880b3798a509512db316deb78f047b8700c5f49d976f4aeff645b1bf6dbde6bfab809e08f640525275fc0e497775bd
|
7
|
+
data.tar.gz: 332b85808e033c3c2ebbd6a03d51ec7fdfc00de17d0775333ed7d13a979e3ca323ae7f47dbd8923c49ce8381c13b1e6853e32e307df680b16db3c9700b23a191
|
data/README.md
CHANGED
@@ -35,6 +35,8 @@ screenshot.browser_width = 1280 # Default: 1440px
|
|
35
35
|
screenshot.browser_height = 780 # Default: 900px
|
36
36
|
screenshot.timeout = 1000 # Default: 0 seconds
|
37
37
|
screenshot.cookies = { user_id: 1, auth_token: 'abcd' } # If you need
|
38
|
+
screenshot.proxy_host = '10.10.10.1' # If you want to use a proxy
|
39
|
+
screenshot.proxy_port = '8080'
|
38
40
|
image = screenshot.capture
|
39
41
|
```
|
40
42
|
|
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'gastly'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "gastly"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start
|
data/gastly.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency 'bundler', '~> 1.9'
|
22
22
|
spec.add_development_dependency 'rake', '~> 10.0'
|
23
23
|
|
24
|
-
spec.add_dependency '
|
24
|
+
spec.add_dependency 'phantomjs2', '~> 2.0'
|
25
25
|
spec.add_dependency 'mini_magick', '~> 4.2'
|
26
26
|
spec.add_dependency 'activesupport', '>= 3.1'
|
27
27
|
end
|
data/lib/gastly/screenshot.rb
CHANGED
@@ -13,10 +13,10 @@ module Gastly
|
|
13
13
|
DEFAULT_FILE_FORMAT = '.png'.freeze
|
14
14
|
|
15
15
|
attr_writer :timeout, :browser_width, :browser_height
|
16
|
-
attr_accessor :url, :selector, :cookies
|
16
|
+
attr_accessor :url, :selector, :cookies, :proxy_host, :proxy_port
|
17
17
|
|
18
18
|
def initialize(url, **kwargs)
|
19
|
-
kwargs.assert_valid_keys(:timeout, :browser_width, :browser_height, :selector, :cookies)
|
19
|
+
kwargs.assert_valid_keys(:timeout, :browser_width, :browser_height, :selector, :cookies, :proxy_host, :proxy_port)
|
20
20
|
|
21
21
|
@url = url
|
22
22
|
self.cookies = kwargs.delete(:cookies)
|
@@ -51,10 +51,19 @@ module Gastly
|
|
51
51
|
params[:cookies] = cookies.map { |k, v| "#{k}=#{v}" }.join(',') if cookies.present?
|
52
52
|
prepared_params = params.map { |k, v| "#{k}=#{v}" }
|
53
53
|
|
54
|
-
Phantomjs.
|
54
|
+
Phantomjs.proxy_host = proxy_host if proxy_host
|
55
|
+
Phantomjs.proxy_port = proxy_port if proxy_port
|
56
|
+
Phantomjs.run(proxy_options, SCRIPT_PATH.to_s, *prepared_params)
|
55
57
|
|
56
58
|
Gastly::Image.new(tempfile)
|
57
59
|
end
|
58
60
|
|
61
|
+
private
|
62
|
+
|
63
|
+
def proxy_options
|
64
|
+
return '' if proxy_host.blank? && proxy_port.blank?
|
65
|
+
"--proxy=#{proxy_host}:#{proxy_port}"
|
66
|
+
end
|
67
|
+
|
59
68
|
end
|
60
69
|
end
|
data/lib/gastly/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gastly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikhail Grachev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: phantomjs2
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|