osxscreenshot 0.0.3 → 0.0.4

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.
@@ -1,3 +1,8 @@
1
+ === 0.0.4 / 2010-02-19
2
+
3
+ * Kill pid properly on timeout
4
+ * Throw OSX::Screenshot::CommandFailed if any command returns nonzero.
5
+
1
6
  === 0.0.2 / 2010-02-16
2
7
 
3
8
  * Added simple usage example.
@@ -2,8 +2,10 @@ require 'open4'
2
2
 
3
3
  module OSX
4
4
  class Screenshot
5
- VERSION = '0.0.3'
6
-
5
+ VERSION = '0.0.4'
6
+
7
+ class CommandFailed < StandardError; end
8
+
7
9
  ##
8
10
  # Takes a screenshot of a website, optionally resizes it, and writes
9
11
  # it to a temporary directory. Returns the file path to the
@@ -109,9 +111,9 @@ module OSX
109
111
  end
110
112
 
111
113
  # Error
112
- system "kill -9 #{pid}"
113
- raise "Command failed: #{cmd}"
114
+ raise CommandFailed, "Command failed: #{cmd}"
114
115
  rescue Timeout::Error => e
116
+ Process.kill "KILL", pid
115
117
  return nil
116
118
  end
117
119
 
@@ -30,6 +30,15 @@ class TestOsxscreenshot < Test::Unit::TestCase
30
30
  assert_nil @tmpfile
31
31
  end
32
32
 
33
+ def test_handles_error_when_exiting
34
+ @tmpfile = nil
35
+ assert_raise OSX::Screenshot::CommandFailed do
36
+ OSX::Screenshot.capture("http://example.com", {
37
+ :webkit2png => "exit 1;"
38
+ })
39
+ end
40
+ end
41
+
33
42
  def teardown
34
43
  if @tmpfile
35
44
  FileUtils.rm @tmpfile
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osxscreenshot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoffrey Grosenbach
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-18 00:00:00 -08:00
12
+ date: 2010-02-19 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency