snapcrawl 0.2.4rc3 → 0.2.4rc4
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/snapcrawl/crawler.rb +20 -13
- data/lib/snapcrawl/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2edb5c120d33af705d3f04220c534ce7a4d1da0d5de7e252f9df7ac55ae61888
|
4
|
+
data.tar.gz: '00508fad9d3fca8123320f4dd9fd8c3a23cbcd590f2f52e39d9a269b48257f15'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b5571ffd1751269e3e842b485b04cf130ceb0b3a64c6016724b8b0e11c6a451c0df590388356ee329a5c5d44c1692b584c986e8d161dbb34932cf48811c867a
|
7
|
+
data.tar.gz: aa5309aa123a25addf9eb0039b18fb3907d6a9d3d1aef1513790d32e4859c4b9909366316d071d3bc353936ffad5292753df9138a32fb249ee7245a000da2a1b
|
data/lib/snapcrawl/crawler.rb
CHANGED
@@ -99,20 +99,16 @@ module Snapcrawl
|
|
99
99
|
fetch_opts[:full] = false
|
100
100
|
end
|
101
101
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
c.quality 100
|
111
|
-
c.extent @opts.height > 0 ? "#{@opts.width}x#{@opts.height}" : "#{@opts.width}x"
|
102
|
+
hide_output do
|
103
|
+
webshot.capture url, image_path, fetch_opts do |magick|
|
104
|
+
magick.combine_options do |c|
|
105
|
+
c.background "white"
|
106
|
+
c.gravity 'north'
|
107
|
+
c.quality 100
|
108
|
+
c.extent @opts.height > 0 ? "#{@opts.width}x#{@opts.height}" : "#{@opts.width}x"
|
109
|
+
end
|
112
110
|
end
|
113
|
-
end
|
114
|
-
|
115
|
-
$stdout, $stderr = $keep_stdout, $keep_stderr
|
111
|
+
end
|
116
112
|
|
117
113
|
say "done"
|
118
114
|
end
|
@@ -230,5 +226,16 @@ module Snapcrawl
|
|
230
226
|
def webshot
|
231
227
|
Webshot::Screenshot.instance
|
232
228
|
end
|
229
|
+
|
230
|
+
# The webshot gem messes with stdout/stderr streams so we keep it in
|
231
|
+
# check by using this method. Also, in some sites (e.g. uown.co) it
|
232
|
+
# prints some output to stdout, this is why we override $stdout for
|
233
|
+
# the duration of the run.
|
234
|
+
def hide_output
|
235
|
+
$keep_stdout, $keep_stderr = $stdout, $stderr
|
236
|
+
$stdout, $stderr = StringIO.new, StringIO.new
|
237
|
+
yield
|
238
|
+
$stdout, $stderr = $keep_stdout, $keep_stderr
|
239
|
+
end
|
233
240
|
end
|
234
241
|
end
|
data/lib/snapcrawl/version.rb
CHANGED