smartshot 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 435631ac32ff38bf3e3927f74e444b8137817f75
4
- data.tar.gz: d8d543a7c79c66439da77760c8ac87d5a2eacc62
3
+ metadata.gz: 2f2a658f8728e10b9da897ebda2968017f58ceab
4
+ data.tar.gz: 7644b10b19b2c8da6c24208c1fc818a248bc8dc4
5
5
  SHA512:
6
- metadata.gz: 5ab882b1d91125741f8ebbc732d86663d04f6d9f27ab1a581124737962ac041f36052bef2589792f93a5bc5de2124b43a68a3d4fc41a678a2979efc682b9df2f
7
- data.tar.gz: ad885fb8ab0bef0d27d1c318957b1ca48370366133ece8c12b176b2b2a719968f614a1743275488438bef7b1497ea8f1ce46562caa94c7579881e68ede6fc175
6
+ metadata.gz: 6cae9603dee303712228faee64aee0f902434e7b86f3d58c655d7d369b2c71bb67363d4bc51093da7efe1912d3c611405b56ae198bc6dc0a0b8e031210c032cf
7
+ data.tar.gz: a45a1f7cb2735ebf523abc96fdf3a58b1832a9c72e5e0d302ae74e02e36fa125d859fa90e3678a2d10c7f4225df50f2e55893ba24afa648b0883aa93f2dafebf
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Smartshot
2
2
 
3
+ [![Build Status](https://travis-ci.org/caiosba/smartshot.png)](https://travis-ci.org/caiosba/smartshot)
4
+ [![Gem Version](https://badge.fury.io/rb/smartshot.png)](http://badge.fury.io/rb/smartshot)
5
+ [![Code Climate](https://codeclimate.com/repos/5548f1dae30ba02e92005039/badges/8d01f31688f88a488230/gpa.png)](https://codeclimate.com/repos/5548f1dae30ba02e92005039/feed)
6
+
3
7
  Captures a web page as a screenshot using Poltergeist, Capybara and PhantomJS.
4
8
  It can wait for elements and also dive into iframes, while the existing gems
5
9
  just wait for time or expect elements on the main window.
@@ -40,9 +44,12 @@ fetcher.take_screenshot! url: 'http://some.page.with/deep/iframes',
40
44
  output: '/tmp/screenshot.png',
41
45
  wait_for_element: 'div.embed',
42
46
  frames_path: [0, 'name-of-an-iframe-inside-the-first-iframe', 'id-of-an-iframe-inside-the-previous-one']
47
+
48
+ # It's also possible to just wait for some time (for example, 5 seconds)
49
+ fetcher.take_screenshot! url: 'http://google.com', output: '/tmp/google.png', sleep: 5
43
50
  ```
44
51
 
45
- Besides the four options presented so far, it's possible to pass the same options accepted by
52
+ Besides the five custom options presented so far, it's possible to pass the same options accepted by
46
53
  [Poltergeist's save screenshot method](https://github.com/teampoltergeist/poltergeist#taking-screenshots-with-some-extensions),
47
54
  for example:
48
55
 
@@ -23,6 +23,10 @@ module Smartshot
23
23
  inside_frames options.delete(:frames_path) do
24
24
  page.find options.delete(:wait_for_element)
25
25
  end
26
+
27
+ timeout = options.delete(:sleep)
28
+ sleep timeout unless timeout.nil?
29
+
26
30
  page.driver.save_screenshot(options.delete(:output), options)
27
31
  rescue => e
28
32
  raise SmartshotError.new("Error: #{e.message.inspect}")
@@ -1,3 +1,3 @@
1
1
  module Smartshot
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -42,7 +42,7 @@ class SmartshotTest < MiniTest::Unit::TestCase
42
42
  waited = thumb(name)
43
43
  File.delete waited if File.exists? waited
44
44
  @smartshot.take_screenshot! url: 'http://ca.ios.ba/files/others/smartshot.html', output: waited, wait_for_element: 'p.Tweet-text',
45
- frames_path: [0, 'child', 'twitter-widget-0']
45
+ frames_path: [0, 'child', 0]
46
46
  assert File.exists? waited
47
47
  end
48
48
 
@@ -56,6 +56,26 @@ class SmartshotTest < MiniTest::Unit::TestCase
56
56
  assert File.size(waited) > File.size(notwaited)
57
57
  end
58
58
 
59
+ def test_timeout
60
+ waited = notwaited = nil
61
+
62
+ %w(withtime).each do |name|
63
+ waited = thumb(name)
64
+ File.delete waited if File.exists? waited
65
+ @smartshot.take_screenshot! url: 'http://ca.ios.ba/files/others/smartshot.html', output: waited, sleep: 10
66
+ assert File.exists? waited
67
+ end
68
+
69
+ %w(notime).each do |name|
70
+ notwaited = thumb(name)
71
+ File.delete notwaited if File.exists? notwaited
72
+ @smartshot.take_screenshot! url: 'http://ca.ios.ba/files/others/smartshot.html', output: notwaited
73
+ assert File.exists? notwaited
74
+ end
75
+
76
+ assert File.size(waited) > File.size(notwaited)
77
+ end
78
+
59
79
  def thumb(name)
60
80
  File.join(DATA_DIR, "#{name}.png")
61
81
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caio Almeida
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-04 00:00:00.000000000 Z
11
+ date: 2015-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler