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 CHANGED
@@ -2,6 +2,7 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in girl_friday.gemspec
4
4
  gemspec
5
+ gem 'rubinius-actor', :platforms => [:rbx, :jruby]
5
6
 
6
7
  # Needed for testing only!
7
8
  gem 'minitest'
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 << Hoptoad if defined?(HoptoadNotifier)
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 Hoptoad
17
+ class Airbrake
18
18
  def handle(ex)
19
- HoptoadNotifier.notify_or_ignore(ex)
19
+ ::Airbrake.notify_or_ignore(ex)
20
20
  end
21
21
  end
22
- Airbrake = Hoptoad
23
-
24
22
  end
25
23
  end
@@ -1,3 +1,3 @@
1
1
  module GirlFriday
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
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
@@ -182,6 +182,8 @@ class TestGirlFridayQueue < MiniTest::Unit::TestCase
182
182
  queue.push(:text => 'foo')
183
183
  end
184
184
 
185
+ sleep 0.1
186
+
185
187
  assert_equal 1, GirlFriday.queues.size
186
188
  count = GirlFriday.shutdown!
187
189
  assert_equal 0, count
metadata CHANGED
@@ -2,46 +2,63 @@
2
2
  name: girl_friday
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.10.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-08-02 00:00:00.000000000Z
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: &2056 !ruby/object:Gem::Requirement
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: &2074 !ruby/object:Gem::Requirement
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: &2092 !ruby/object:Gem::Requirement
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: '0'
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: '0'
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: '0'
120
+ version: !binary |-
121
+ MA==
103
122
  none: false
104
123
  requirements: []
105
124
  rubyforge_project: girl_friday
106
- rubygems_version: 1.8.15
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