celluloid_pubsub 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +22 -17
- data/celluloid_pubsub.gemspec +1 -1
- data/lib/celluloid_pubsub/base_actor.rb +1 -1
- data/lib/celluloid_pubsub/reactor.rb +1 -1
- data/lib/celluloid_pubsub/version.rb +1 -1
- data/lib/celluloid_pubsub.rb +1 -0
- data/spec/lib/celluloid_pubsub/reactor_spec.rb +6 -2
- data/spec/spec_helper.rb +15 -0
- metadata +21 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c8492791d62fac1a25802a1f220f34f75c4f57c
|
4
|
+
data.tar.gz: 0c95d4091fdc3becc7ecf07707d4aed11f006c4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77a0d22a464b8a45713b8ea366f8f5653cc3ee44b4d4d089a9a1b23d8f58ab47d1be05a38bfcb4da0a919970b8fa06dd81b5c86f7b74a42fc06d6353f2f94737
|
7
|
+
data.tar.gz: 05ca183e6aa33cd0a4695a333ab015ce5485d7989e964fef0527378bffcb67b2e5ca11239584e3cf09242043626b63425bfc079929d5a9abcb93bc80b28dfe3a
|
data/Rakefile
CHANGED
@@ -1,26 +1,14 @@
|
|
1
1
|
require 'bundler/setup'
|
2
2
|
require 'bundler/gem_tasks'
|
3
|
+
require 'appraisal'
|
3
4
|
require 'rspec/core/rake_task'
|
4
5
|
require 'coveralls/rake/task'
|
5
6
|
require 'yard'
|
6
7
|
Coveralls::RakeTask.new
|
7
8
|
|
8
9
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
9
|
-
spec.rspec_opts = ['--backtrace
|
10
|
-
|
11
|
-
|
12
|
-
YARD::Config.options[:load_plugins] = true
|
13
|
-
YARD::Config.load_plugins
|
14
|
-
|
15
|
-
# dirty hack for YardocTask
|
16
|
-
::Rake.application.class.class_eval do
|
17
|
-
alias_method :last_comment, :last_description
|
18
|
-
end
|
19
|
-
|
20
|
-
YARD::Rake::YardocTask.new do |t|
|
21
|
-
t.files = ['lib/**/*.rb', 'spec/**/*_spec.rb'] # optional
|
22
|
-
t.options = ['--any', '--extra', '--opts', '--markup-provider=redcarpet', '--markup=markdown', '--debug'] # optional
|
23
|
-
t.stats_options = ['--list-undoc'] # optional
|
10
|
+
spec.rspec_opts = ['--backtrace '] if ENV['DEBUG']
|
11
|
+
spec.verbose = true
|
24
12
|
end
|
25
13
|
|
26
14
|
desc 'Default: run the unit tests.'
|
@@ -29,12 +17,29 @@ task default: [:all]
|
|
29
17
|
desc 'Test the plugin under all supported Rails versions.'
|
30
18
|
task :all do |_t|
|
31
19
|
if ENV['TRAVIS']
|
32
|
-
|
20
|
+
# require 'json'
|
21
|
+
# puts JSON.pretty_generate(ENV.to_hash)
|
22
|
+
if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
|
23
|
+
appraisal_name = ENV['BUNDLE_GEMFILE'].scan(/rails\_(.*)\.gemfile/).flatten.first
|
24
|
+
command_prefix = "appraisal rails-#{appraisal_name}"
|
25
|
+
exec ("#{command_prefix} bundle install && #{command_prefix} bundle exec rspec && bundle exec rake coveralls:push ")
|
26
|
+
else
|
27
|
+
exec(' bundle exec appraisal install && bundle exec rake appraisal spec && bundle exec rake coveralls:push')
|
28
|
+
end
|
33
29
|
else
|
34
|
-
exec('bundle exec rake spec')
|
30
|
+
exec('bundle exec appraisal install && bundle exec rake appraisal spec')
|
35
31
|
end
|
36
32
|
end
|
37
33
|
|
34
|
+
YARD::Config.options[:load_plugins] = true
|
35
|
+
YARD::Config.load_plugins
|
36
|
+
|
37
|
+
YARD::Rake::YardocTask.new do |t|
|
38
|
+
t.files = ['lib/**/*.rb', 'spec/**/*_spec.rb'] # optional
|
39
|
+
t.options = ['--any', '--extra', '--opts', '--markup-provider=redcarpet', '--markup=markdown', '--debug'] # optional
|
40
|
+
t.stats_options = ['--list-undoc'] # optional
|
41
|
+
end
|
42
|
+
|
38
43
|
task :docs do
|
39
44
|
exec('bundle exec inch --pedantic && bundle exec yard --list-undoc')
|
40
45
|
end
|
data/celluloid_pubsub.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_runtime_dependency 'celluloid-pmap', '~> 0.2', '>= 0.2.2'
|
24
24
|
s.add_runtime_dependency 'activesupport', '>= 4.0', '>= 4.0'
|
25
25
|
|
26
|
-
|
26
|
+
s.add_development_dependency 'appraisal', '~> 2.1', '>= 2.1'
|
27
27
|
s.add_development_dependency 'rspec', '~> 3.4', '>= 3.4'
|
28
28
|
s.add_development_dependency 'simplecov', '~> 0.10', '>= 0.10'
|
29
29
|
s.add_development_dependency 'simplecov-summary', '~> 0.0.4', '>= 0.0.4'
|
@@ -40,7 +40,7 @@ module CelluloidPubsub
|
|
40
40
|
if version_less_than_seventeen?
|
41
41
|
class_name.supervise_as(options[:actor_name], options[:args])
|
42
42
|
else
|
43
|
-
class_name.supervise(as: options[:actor_name], args: [options[:args]])
|
43
|
+
class_name.supervise(as: options[:actor_name], args: [options[:args]].compact)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -222,7 +222,7 @@ module CelluloidPubsub
|
|
222
222
|
return unless channel.present?
|
223
223
|
forget_channel(channel)
|
224
224
|
@server.mutex.synchronize do
|
225
|
-
(@server.subscribers[channel]
|
225
|
+
(@server.subscribers[channel] || []).delete_if do |hash|
|
226
226
|
hash[:reactor] == Actor.current
|
227
227
|
end
|
228
228
|
end
|
data/lib/celluloid_pubsub.rb
CHANGED
@@ -6,6 +6,7 @@ require 'reel'
|
|
6
6
|
require 'celluloid/websocket/client'
|
7
7
|
require 'active_support/all'
|
8
8
|
require 'json'
|
9
|
+
require 'thread'
|
9
10
|
require 'celluloid/pmap'
|
10
11
|
require 'celluloid_pubsub/base_actor'
|
11
12
|
Gem.find_files('celluloid_pubsub/initializers/**/*.rb').each { |path| require path }
|
@@ -5,6 +5,8 @@ require 'spec_helper'
|
|
5
5
|
describe CelluloidPubsub::Reactor do
|
6
6
|
let(:websocket) { mock }
|
7
7
|
let(:server) { mock }
|
8
|
+
let(:mutex) { mock }
|
9
|
+
let(:synchronizer) { mock }
|
8
10
|
|
9
11
|
before(:each) do
|
10
12
|
subject.stubs(:async).returns(subject)
|
@@ -22,6 +24,8 @@ describe CelluloidPubsub::Reactor do
|
|
22
24
|
subject.stubs(:run)
|
23
25
|
subject.work(websocket, server)
|
24
26
|
subject.stubs(:unsubscribe_from_channel).returns(true)
|
27
|
+
server.stubs(:mutex).returns(mutex)
|
28
|
+
mutex.stubs(:synchronize).yields(server)
|
25
29
|
Celluloid::Actor.stubs(:kill).returns(true)
|
26
30
|
end
|
27
31
|
|
@@ -140,14 +144,14 @@ describe CelluloidPubsub::Reactor do
|
|
140
144
|
subject.channels.stubs(:blank?).returns(false)
|
141
145
|
subject.channels.expects(:delete).with(channel)
|
142
146
|
act = subject.unsubscribe(channel)
|
143
|
-
expect(act).to eq(
|
147
|
+
expect(act).to eq(nil)
|
144
148
|
end
|
145
149
|
|
146
150
|
it 'unsubscribes' do
|
147
151
|
subject.channels.stubs(:blank?).returns(true)
|
148
152
|
subject.websocket.expects(:close)
|
149
153
|
act = subject.unsubscribe(channel)
|
150
|
-
expect(act).to eq(
|
154
|
+
expect(act).to eq(nil)
|
151
155
|
end
|
152
156
|
|
153
157
|
it 'unsubscribes' do
|
data/spec/spec_helper.rb
CHANGED
@@ -49,6 +49,21 @@ end
|
|
49
49
|
# class used for testing actions
|
50
50
|
class TestActor
|
51
51
|
include CelluloidPubsub::BaseActor
|
52
|
+
|
53
|
+
def initialize(*args)
|
54
|
+
end
|
52
55
|
end
|
53
56
|
|
54
57
|
CelluloidPubsub::BaseActor.setup_actor_supervision(TestActor, actor_name: :test_actor, args: { })
|
58
|
+
|
59
|
+
unless defined?(silence_stream) # Rails 5
|
60
|
+
def silence_stream(stream)
|
61
|
+
old_stream = stream.dup
|
62
|
+
stream.reopen(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL:' : '/dev/null')
|
63
|
+
stream.sync = true
|
64
|
+
yield
|
65
|
+
ensure
|
66
|
+
stream.reopen(old_stream)
|
67
|
+
old_stream.close
|
68
|
+
end
|
69
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: celluloid_pubsub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bogdanRada
|
@@ -124,6 +124,26 @@ dependencies:
|
|
124
124
|
- - ">="
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '4.0'
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: appraisal
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - "~>"
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '2.1'
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '2.1'
|
137
|
+
type: :development
|
138
|
+
prerelease: false
|
139
|
+
version_requirements: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - "~>"
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '2.1'
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '2.1'
|
127
147
|
- !ruby/object:Gem::Dependency
|
128
148
|
name: rspec
|
129
149
|
requirement: !ruby/object:Gem::Requirement
|