girl_friday 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/History.md +8 -0
- data/lib/girl_friday.rb +10 -15
- data/lib/girl_friday/error_handler.rb +3 -5
- data/lib/girl_friday/version.rb +1 -1
- data/test/helper.rb +15 -1
- data/test/test_batch.rb +0 -4
- data/test/test_error_handler.rb +60 -0
- data/test/test_girl_friday_queue.rb +2 -0
- metadata +33 -14
- data/lib/girl_friday/monkey_patches.rb +0 -31
data/Gemfile
CHANGED
data/History.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
Changes
|
2
2
|
================
|
3
3
|
|
4
|
+
HEAD
|
5
|
+
---------
|
6
|
+
|
7
|
+
* Remove old Rubinius 1.2.3 monkeypatches
|
8
|
+
* Remove default `at_exit` handle which was causing issues [#67]
|
9
|
+
* Support the rubinius-actor gem for jruby/rbx (jc00ke)
|
10
|
+
Avoids a nameclash for projects that define their own Actor class.
|
11
|
+
|
4
12
|
0.10.0
|
5
13
|
---------
|
6
14
|
|
data/lib/girl_friday.rb
CHANGED
@@ -1,13 +1,5 @@
|
|
1
1
|
require 'weakref'
|
2
2
|
require 'thread'
|
3
|
-
begin
|
4
|
-
# Rubinius
|
5
|
-
require 'actor'
|
6
|
-
require 'girl_friday/monkey_patches'
|
7
|
-
rescue LoadError
|
8
|
-
# Others
|
9
|
-
require 'girl_friday/actor'
|
10
|
-
end
|
11
3
|
|
12
4
|
require 'girl_friday/version'
|
13
5
|
require 'girl_friday/work_queue'
|
@@ -15,6 +7,16 @@ require 'girl_friday/error_handler'
|
|
15
7
|
require 'girl_friday/persistence'
|
16
8
|
require 'girl_friday/batch'
|
17
9
|
|
10
|
+
begin
|
11
|
+
# Rubinius or JRuby
|
12
|
+
require 'rubinius/actor'
|
13
|
+
require 'girl_friday/monkey_patches'
|
14
|
+
GirlFriday::WorkQueue::Actor = Rubinius::Actor
|
15
|
+
rescue LoadError
|
16
|
+
# Others
|
17
|
+
require 'girl_friday/actor'
|
18
|
+
end
|
19
|
+
|
18
20
|
module GirlFriday
|
19
21
|
|
20
22
|
@lock = Mutex.new
|
@@ -88,10 +90,3 @@ module GirlFriday
|
|
88
90
|
end
|
89
91
|
|
90
92
|
end
|
91
|
-
|
92
|
-
|
93
|
-
unless defined?($testing)
|
94
|
-
at_exit do
|
95
|
-
GirlFriday.shutdown!
|
96
|
-
end
|
97
|
-
end
|
@@ -3,7 +3,7 @@ module GirlFriday
|
|
3
3
|
|
4
4
|
def self.default
|
5
5
|
handlers = [Stderr]
|
6
|
-
handlers <<
|
6
|
+
handlers << Airbrake if defined?(::Airbrake)
|
7
7
|
handlers
|
8
8
|
end
|
9
9
|
|
@@ -14,12 +14,10 @@ module GirlFriday
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
class
|
17
|
+
class Airbrake
|
18
18
|
def handle(ex)
|
19
|
-
|
19
|
+
::Airbrake.notify_or_ignore(ex)
|
20
20
|
end
|
21
21
|
end
|
22
|
-
Airbrake = Hoptoad
|
23
|
-
|
24
22
|
end
|
25
23
|
end
|
data/lib/girl_friday/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
$testing = true
|
2
1
|
puts RUBY_DESCRIPTION
|
3
2
|
|
4
3
|
at_exit do
|
@@ -40,3 +39,18 @@ class MiniTest::Unit::TestCase
|
|
40
39
|
end
|
41
40
|
|
42
41
|
end
|
42
|
+
|
43
|
+
module Faker
|
44
|
+
def initialize
|
45
|
+
@number_of_calls = 0
|
46
|
+
end
|
47
|
+
|
48
|
+
def number_of_calls
|
49
|
+
@number_of_calls
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def count(*args,&blk)
|
54
|
+
@number_of_calls += 1
|
55
|
+
end
|
56
|
+
end
|
data/test/test_batch.rb
CHANGED
@@ -34,10 +34,6 @@ class TestBatch < MiniTest::Unit::TestCase
|
|
34
34
|
assert_equal 'x', results[1]
|
35
35
|
assert_nil results[2]
|
36
36
|
assert_equal 'x', results[3]
|
37
|
-
|
38
|
-
# Necessary to work around a Ruby 1.9.2 bug
|
39
|
-
# http://redmine.ruby-lang.org/issues/5342
|
40
|
-
sleep 0.1
|
41
37
|
end
|
42
38
|
|
43
39
|
def test_empty_batch
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
|
4
|
+
class TestErrorHandler < MiniTest::Unit::TestCase
|
5
|
+
Stderr = GirlFriday::ErrorHandler::Stderr
|
6
|
+
Airbrake = GirlFriday::ErrorHandler::Airbrake
|
7
|
+
|
8
|
+
class FakeStderr
|
9
|
+
include Faker
|
10
|
+
def flush
|
11
|
+
"WOOSH!"
|
12
|
+
end
|
13
|
+
alias_method :puts, :count
|
14
|
+
alias_method :write, :count
|
15
|
+
end
|
16
|
+
|
17
|
+
class FakeAirbrake
|
18
|
+
include Faker
|
19
|
+
alias_method :notify_or_ignore, :count
|
20
|
+
end
|
21
|
+
|
22
|
+
class FakeError
|
23
|
+
def backtrace
|
24
|
+
%w(
|
25
|
+
We're no strangers to love
|
26
|
+
You know the rules and so do I
|
27
|
+
A full commitment's what I'm thinking of
|
28
|
+
You wouldn't get this from any other guy
|
29
|
+
I just wanna tell you how I'm feeling
|
30
|
+
Gotta make you understand
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def handler
|
36
|
+
GirlFriday::ErrorHandler
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_default
|
40
|
+
assert_equal [Stderr], handler.default
|
41
|
+
|
42
|
+
Object.const_set("Airbrake","super cool error catcher")
|
43
|
+
assert_equal [Stderr,Airbrake], handler.default
|
44
|
+
Object.send(:remove_const,:Airbrake)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_stderr
|
48
|
+
$stderr = FakeStderr.new
|
49
|
+
Stderr.new.handle(FakeError.new)
|
50
|
+
assert_equal 2, $stderr.number_of_calls
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_airbrake
|
54
|
+
airbrake = FakeAirbrake.new
|
55
|
+
Object.const_set("Airbrake", airbrake)
|
56
|
+
Airbrake.new.handle(FakeError.new)
|
57
|
+
assert_equal 1, airbrake.number_of_calls
|
58
|
+
Object.send(:remove_const,:Airbrake)
|
59
|
+
end
|
60
|
+
end
|
metadata
CHANGED
@@ -2,46 +2,63 @@
|
|
2
2
|
name: girl_friday
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.11.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mike Perham
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: connection_pool
|
16
|
-
version_requirements:
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ~>
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.9.0
|
21
|
+
none: false
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
17
23
|
requirements:
|
18
24
|
- - ~>
|
19
25
|
- !ruby/object:Gem::Version
|
20
26
|
version: 0.9.0
|
21
27
|
none: false
|
22
|
-
requirement: *2056
|
23
28
|
prerelease: false
|
24
29
|
type: :runtime
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: sinatra
|
27
|
-
version_requirements:
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ~>
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '1.3'
|
37
|
+
none: false
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
28
39
|
requirements:
|
29
40
|
- - ~>
|
30
41
|
- !ruby/object:Gem::Version
|
31
42
|
version: '1.3'
|
32
43
|
none: false
|
33
|
-
requirement: *2074
|
34
44
|
prerelease: false
|
35
45
|
type: :development
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rake
|
38
|
-
version_requirements:
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: !binary |-
|
53
|
+
MA==
|
54
|
+
none: false
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
39
56
|
requirements:
|
40
57
|
- - ! '>='
|
41
58
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
59
|
+
version: !binary |-
|
60
|
+
MA==
|
43
61
|
none: false
|
44
|
-
requirement: *2092
|
45
62
|
prerelease: false
|
46
63
|
type: :development
|
47
64
|
description: Background processing, simplified
|
@@ -69,7 +86,6 @@ files:
|
|
69
86
|
- lib/girl_friday/actor.rb
|
70
87
|
- lib/girl_friday/batch.rb
|
71
88
|
- lib/girl_friday/error_handler.rb
|
72
|
-
- lib/girl_friday/monkey_patches.rb
|
73
89
|
- lib/girl_friday/persistence.rb
|
74
90
|
- lib/girl_friday/server.rb
|
75
91
|
- lib/girl_friday/version.rb
|
@@ -80,6 +96,7 @@ files:
|
|
80
96
|
- server/views/index.erb
|
81
97
|
- test/helper.rb
|
82
98
|
- test/test_batch.rb
|
99
|
+
- test/test_error_handler.rb
|
83
100
|
- test/test_girl_friday.rb
|
84
101
|
- test/test_girl_friday_immediately.rb
|
85
102
|
- test/test_girl_friday_queue.rb
|
@@ -93,24 +110,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
110
|
requirements:
|
94
111
|
- - ! '>='
|
95
112
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
113
|
+
version: !binary |-
|
114
|
+
MA==
|
97
115
|
none: false
|
98
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
117
|
requirements:
|
100
118
|
- - ! '>='
|
101
119
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
120
|
+
version: !binary |-
|
121
|
+
MA==
|
103
122
|
none: false
|
104
123
|
requirements: []
|
105
124
|
rubyforge_project: girl_friday
|
106
|
-
rubygems_version: 1.8.
|
125
|
+
rubygems_version: 1.8.24
|
107
126
|
signing_key:
|
108
127
|
specification_version: 3
|
109
128
|
summary: Background processing, simplified
|
110
129
|
test_files:
|
111
130
|
- test/helper.rb
|
112
131
|
- test/test_batch.rb
|
132
|
+
- test/test_error_handler.rb
|
113
133
|
- test/test_girl_friday.rb
|
114
134
|
- test/test_girl_friday_immediately.rb
|
115
135
|
- test/test_girl_friday_queue.rb
|
116
|
-
...
|
@@ -1,31 +0,0 @@
|
|
1
|
-
if RUBY_ENGINE == 'rbx' && (Rubinius::VERSION < '1.2.4' || Rubinius::VERSION == '1.2.4dev')
|
2
|
-
puts "Loading rubinius actor monkeypatches" if $testing
|
3
|
-
class Actor
|
4
|
-
|
5
|
-
# Monkeypatch so this works with Rubinius 1.2.3 (latest).
|
6
|
-
# 1.2.4 should have the necessary fix included.
|
7
|
-
def notify_exited(actor, reason)
|
8
|
-
exit_message = nil
|
9
|
-
@lock.receive
|
10
|
-
begin
|
11
|
-
return self unless @alive
|
12
|
-
@links.delete(actor)
|
13
|
-
if @trap_exit
|
14
|
-
exit_message = DeadActorError.new(actor, reason)
|
15
|
-
elsif reason
|
16
|
-
@interrupts << DeadActorError.new(actor, reason)
|
17
|
-
if @filter
|
18
|
-
@filter = nil
|
19
|
-
@ready << nil
|
20
|
-
end
|
21
|
-
end
|
22
|
-
ensure
|
23
|
-
@lock << nil
|
24
|
-
end
|
25
|
-
send exit_message if exit_message
|
26
|
-
self
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|