celluloid_pubsub 1.1.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a1eba9a9d8cfa302a2d8345fc4d5ba9e97387b33
4
- data.tar.gz: 032b659f65e7e148908743b46abbf121705beb88
2
+ SHA256:
3
+ metadata.gz: 03c8681e99ddf220f8fbdec951b30b6297e6d813e0dc81d179f1a203445eaee9
4
+ data.tar.gz: 2faac6758815b6a65da97967286e490b918cdcbcdf26098fa8bffc02cd8e29db
5
5
  SHA512:
6
- metadata.gz: 55bbe3c294f63f699394856175c8a93fde5171514b205911f947ae9ca9646a752f81f50164e31cad13aa1e0cb32754b8eef9054adf10c6c88f2251dcdeb4a8f7
7
- data.tar.gz: 80db42f3886b90caf6b4b3899e0dcb3108679790a44736d72dc70ed0102c5ad34957aa3fbeedcdba1aed546ffcf86caf2b1756da6b40416b53481d8eb59671e6
6
+ metadata.gz: 2a86c3c51afc78faff3dd1cf534152bbfabbb40f4425a2bcdde435ae4f54fb1e8c3ed1cec2399640a8ec911609d4cd1cf3887c9c849b016fa2053bfeff69b157
7
+ data.tar.gz: e32fb0726143ddcf85f627ad731be01afa57d02ee8eaf473bbc56c3c7aec26d7b0bc6f939fe3adf6246a5815ae433a2dc9bef94315737de481f9b4ebb67eff45
data/.hound.yml ADDED
@@ -0,0 +1,10 @@
1
+ rubocop:
2
+ config_file: .rubocop.yml
3
+ enabled: false
4
+
5
+ flog:
6
+ enabled: false
7
+
8
+ reek:
9
+ enabled: false
10
+
data/.rubocop.yml CHANGED
@@ -1,6 +1,12 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
1
3
  AllCops:
4
+ TargetRubyVersion: 3.0
5
+ DisplayStyleGuide: true
6
+ ExtraDetails: true
2
7
  Exclude:
3
8
  - celluloid_pubsub.gemspec
9
+ - gemfiles/**/**
4
10
  - bin/**/*
5
11
  - Guardfile
6
12
  - vendor/**/**
@@ -8,70 +14,146 @@ AllCops:
8
14
  - spec/**/*
9
15
  - Gemfile
10
16
  - Rakefile
17
+ - Appraisals
18
+
19
+ Style/OptionalBooleanParameter:
20
+ Enabled: false
11
21
 
12
- TargetRubyVersion: 2.3
13
-
14
- ClassLength:
15
- Max: 500
22
+ Lint/RedundantRequireStatement:
23
+ Enabled: false
16
24
 
17
- Documentation:
25
+ Style/StringChars: # (new in 1.12)
18
26
  Enabled: true
19
27
 
20
- Encoding:
28
+ Metrics/ClassLength:
29
+ Max: 900
30
+
31
+ Metrics/ModuleLength:
32
+ Max: 900
33
+
34
+ Style/Documentation:
21
35
  Enabled: false
22
36
 
23
- LineLength:
37
+ Style/Encoding:
38
+ Enabled: false
39
+
40
+ Layout/LineLength:
24
41
  Max: 200
25
42
 
26
- AccessModifierIndentation:
27
- EnforcedStyle: outdent
43
+ Layout/AccessModifierIndentation:
44
+ EnforcedStyle: indent
28
45
 
29
- IfUnlessModifier:
46
+ Style/IfUnlessModifier:
30
47
  Enabled: false
31
48
 
32
- CaseIndentation:
33
- IndentWhenRelativeTo: case
34
- IndentOneStep: true
49
+ Layout/CaseIndentation:
50
+ EnforcedStyle: case
51
+ IndentOneStep: false
35
52
 
36
- MethodLength:
53
+ Metrics/MethodLength:
37
54
  CountComments: false
38
55
  Max: 20
39
56
 
40
- SignalException:
57
+ Style/SignalException:
41
58
  Enabled: false
42
59
 
43
- ColonMethodCall:
60
+ Style/ColonMethodCall:
44
61
  Enabled: false
45
62
 
46
- AsciiComments:
63
+ Style/AsciiComments:
47
64
  Enabled: false
48
65
 
49
- RegexpLiteral:
66
+ Style/RegexpLiteral:
50
67
  Enabled: false
51
68
 
52
- AssignmentInCondition:
69
+ Lint/AssignmentInCondition:
53
70
  Enabled: false
54
71
 
55
- ParameterLists:
72
+ Metrics/ParameterLists:
56
73
  CountKeywordArgs: false
57
74
 
58
- SingleLineBlockParams:
75
+ Style/SingleLineBlockParams:
59
76
  Methods:
60
77
  - reduce:
61
- - memo
62
- - item
78
+ - memo
79
+ - item
63
80
 
64
81
  Metrics/AbcSize:
65
82
  Enabled: false
66
83
 
84
+ Layout/EmptyLineAfterGuardClause:
85
+ Enabled: false
86
+
87
+ Style/GlobalStdStream:
88
+ Enabled: false
89
+
67
90
  Style/CollectionMethods:
68
91
  Enabled: true
69
92
 
70
93
  Style/SymbolArray:
71
94
  Enabled: true
72
95
 
73
- Style/ExtraSpacing:
96
+ Layout/ExtraSpacing:
74
97
  Enabled: true
75
98
 
76
- Style/FileName:
99
+ Naming/FileName:
77
100
  Enabled: false
101
+
102
+ Gemspec/DateAssignment: # (new in 1.10)
103
+ Enabled: true
104
+ Layout/SpaceBeforeBrackets: # (new in 1.7)
105
+ Enabled: true
106
+ Lint/AmbiguousAssignment: # (new in 1.7)
107
+ Enabled: true
108
+ Lint/DeprecatedConstants: # (new in 1.8)
109
+ Enabled: true
110
+ Lint/DuplicateBranch: # (new in 1.3)
111
+ Enabled: true
112
+ Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
113
+ Enabled: true
114
+ Lint/EmptyBlock: # (new in 1.1)
115
+ Enabled: true
116
+ Lint/EmptyClass: # (new in 1.3)
117
+ Enabled: true
118
+ Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
119
+ Enabled: true
120
+ Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
121
+ Enabled: true
122
+ Lint/NumberedParameterAssignment: # (new in 1.9)
123
+ Enabled: true
124
+ Lint/OrAssignmentToConstant: # (new in 1.9)
125
+ Enabled: true
126
+ Lint/RedundantDirGlobSort: # (new in 1.8)
127
+ Enabled: true
128
+ Lint/SymbolConversion: # (new in 1.9)
129
+ Enabled: true
130
+ Lint/ToEnumArguments: # (new in 1.1)
131
+ Enabled: true
132
+ Lint/TripleQuotes: # (new in 1.9)
133
+ Enabled: true
134
+ Lint/UnexpectedBlockArity: # (new in 1.5)
135
+ Enabled: true
136
+ Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
137
+ Enabled: true
138
+ Style/ArgumentsForwarding: # (new in 1.1)
139
+ Enabled: true
140
+ Style/CollectionCompact: # (new in 1.2)
141
+ Enabled: true
142
+ Style/DocumentDynamicEvalDefinition: # (new in 1.1)
143
+ Enabled: true
144
+ Style/EndlessMethod: # (new in 1.8)
145
+ Enabled: true
146
+ Style/HashConversion: # (new in 1.10)
147
+ Enabled: true
148
+ Style/HashExcept: # (new in 1.7)
149
+ Enabled: true
150
+ Style/IfWithBooleanLiteralBranches: # (new in 1.9)
151
+ Enabled: true
152
+ Style/NegatedIfElseCondition: # (new in 1.2)
153
+ Enabled: true
154
+ Style/NilLambda: # (new in 1.3)
155
+ Enabled: true
156
+ Style/RedundantArgument: # (new in 1.4)
157
+ Enabled: true
158
+ Style/SwapValues: # (new in 1.1)
159
+ Enabled: true
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,7 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2021-03-26 21:52:12 UTC using RuboCop version 1.12.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
data/.travis.yml CHANGED
@@ -1,5 +1,4 @@
1
1
  language: ruby
2
- sudo: false
3
2
 
4
3
  cache: bundler
5
4
 
@@ -7,24 +6,62 @@ bundler_args: --no-deployment --binstubs=./bin
7
6
 
8
7
  before_install:
9
8
  - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
10
- - gem install bundler
11
- - gem update bundler
9
+ - if [[ ! "${RUBY_VERSION}" =~ "jruby" ]]; then travis_wait 30 rvm rubygems current; fi
10
+ - if [[ ! "${RUBY_VERSION}" =~ "jruby" ]]; then yes | gem update --system --force || true; fi
11
+ - gem --version
12
+ - gem install bundler -v 1.17.3
13
+ - export MY_BUNDLER_VERSION='_1.17.3_'
14
+ - bundle ${MY_BUNDLER_VERSION} --version
12
15
 
13
16
  install:
14
- - bundle install --path vendor/bundle
17
+ - bundle ${MY_BUNDLER_VERSION} config --local path vendor/bundle
18
+ - bundle ${MY_BUNDLER_VERSION} config --local jobs 3
19
+ - bundle ${MY_BUNDLER_VERSION} config --local retry 3
20
+ - bundle ${MY_BUNDLER_VERSION} config --local binstubs ./bin
21
+ - bundle ${MY_BUNDLER_VERSION} config --local bin ./bin
22
+ - bundle ${MY_BUNDLER_VERSION} install
23
+ - gem env
24
+ - bundle ${MY_BUNDLER_VERSION} env
15
25
 
16
26
  script:
17
- - echo $BUNDLE_GEMFILE
18
- - bundle exec rake
27
+ - echo $BUNDLE_GEMFILE
28
+ - bundle ${MY_BUNDLER_VERSION} exec rake
19
29
 
30
+ gemfile:
31
+ - gemfiles/cell_0.16.0.gemfile
32
+ - gemfiles/cell_0.17.3.gemfile
33
+ - gemfiles/cell_0.17.4.gemfile
34
+ - gemfiles/cell_0.18.0.gemfile
35
+ matrix:
36
+ fast_finish: true
37
+ allow_failures:
38
+ - rvm: 2.2.5
39
+ exclude:
40
+ - rvm: 2.0.0
41
+ gemfile: gemfiles/cell_0.18.0.gemfile
42
+ - rvm: 2.1.3
43
+ gemfile: gemfiles/cell_0.18.0.gemfile
44
+ - rvm: 2.2.0
45
+ gemfile: gemfiles/cell_0.18.0.gemfile
46
+ - rvm: 2.2.2
47
+ gemfile: gemfiles/cell_0.18.0.gemfile
48
+ - rvm: 2.2.5
49
+ gemfile: gemfiles/cell_0.18.0.gemfile
20
50
  rvm:
21
- - 2.2.2
22
- - 2.2.5
23
- - 2.3.1
24
- - 2.3.2
25
- - 2.3.3
26
- - 2.4.0
51
+ - 2.1.3
52
+ - 2.2.2
53
+ - 2.2.5
54
+ - 2.3.1
55
+ - 2.3.2
56
+ - 2.3.3
57
+ - 2.4.0
58
+ - 2.5.3
59
+ - 2.6.5
60
+ - 2.7.1
61
+ # - 3.0.0 - celluloid/io doesn't work
62
+
27
63
  env:
28
- - RAILS_ENV=test RACK_ENV=test
64
+ - RAILS_ENV=test RACK_ENV=test APP_ENV=test
65
+
29
66
  notifications:
30
67
  email: false
data/Appraisals CHANGED
@@ -1,11 +1,15 @@
1
- appraise "celluloid-0.16.0" do
1
+ appraise "cell-0.16.0" do
2
2
  gem "celluloid", "0.16.0"
3
3
  end
4
4
 
5
- appraise "celluloid-0.17.3" do
5
+ appraise "cell-0.17.3" do
6
6
  gem "celluloid", "0.17.3"
7
7
  end
8
8
 
9
- appraise "celluloid-0.18.0.pre" do
10
- gem "celluloid", "0.18.0.pre"
9
+ appraise "cell-0.17.4" do
10
+ gem "celluloid", "0.17.4"
11
11
  end
12
+
13
+ appraise "cell-0.18.0" do
14
+ gem "celluloid", "0.18.0"
15
+ end
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gemspec
3
+ gemspec
data/Rakefile CHANGED
@@ -20,8 +20,8 @@ task :all do |_t|
20
20
  # require 'json'
21
21
  # puts JSON.pretty_generate(ENV.to_hash)
22
22
  if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
23
- appraisal_name = ENV['BUNDLE_GEMFILE'].scan(/rails\_(.*)\.gemfile/).flatten.first
24
- command_prefix = "appraisal rails-#{appraisal_name}"
23
+ appraisal_name = ENV['BUNDLE_GEMFILE'].scan(/cell\_(.*)\.gemfile/).flatten.first
24
+ command_prefix = "appraisal cell-#{appraisal_name}"
25
25
  exec ("#{command_prefix} bundle install && #{command_prefix} bundle exec rspec && bundle exec rake coveralls:push ")
26
26
  else
27
27
  exec(' bundle exec appraisal install && bundle exec rake appraisal spec && bundle exec rake coveralls:push')
@@ -19,20 +19,21 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ['lib']
20
20
 
21
21
  s.add_runtime_dependency 'celluloid', '>= 0.16', '>= 0.16.0'
22
+ s.add_runtime_dependency 'celluloid-fsm'
22
23
  s.add_runtime_dependency 'celluloid-io', '>= 0.16', '>= 0.16.2'
23
- s.add_runtime_dependency 'reel', '~> 0.6', '>= 0.6.0'
24
+ #TODO: reel 0.6.1 seems broken - Need to investigate
25
+ s.add_runtime_dependency 'reel', '0.6.0'
24
26
  s.add_runtime_dependency 'celluloid-websocket-client', '~> 0.0', '>= 0.0.1'
25
- s.add_runtime_dependency 'celluloid-pmap', '~> 0.2', '>= 0.2.2'
27
+ s.add_runtime_dependency 'celluloid-pmap', '~> 1.0'
26
28
  s.add_runtime_dependency 'activesupport', '>= 4.0', '>= 4.0'
27
29
 
28
30
  s.add_development_dependency 'appraisal', '~> 2.1', '>= 2.1'
29
31
  s.add_development_dependency 'rspec', '~> 3.5', '>= 3.5'
30
32
  s.add_development_dependency 'simplecov', '~> 0.12', '>= 0.12'
31
33
  s.add_development_dependency 'simplecov-summary', '~> 0.0', '>= 0.0.5'
32
- s.add_development_dependency 'mocha', '~> 1.2', '>= 1.2'
33
34
  s.add_development_dependency 'coveralls', '~> 0.8', '>= 0.8'
34
35
  s.add_development_dependency 'rake', '>= 12.0', '>= 12.0'
35
- s.add_development_dependency 'yard', '~> 0.8', '>= 0.8.7'
36
+ s.add_development_dependency 'yard', '>= 0.9.20'
36
37
  s.add_development_dependency 'redcarpet', '~> 3.4', '>= 3.4'
37
38
  s.add_development_dependency 'github-markup', '~> 1.4', '>= 1.4'
38
39
  s.add_development_dependency 'inch', '~> 0.7', '>= 0.7'
@@ -2,9 +2,15 @@ require 'bundler/setup'
2
2
  require 'celluloid_pubsub'
3
3
  require 'logger'
4
4
 
5
- debug_enabled = ENV['DEBUG'].present? && ENV['DEBUG'].to_s == 'true'
5
+ debug_enabled = (ENV['DEBUG'].present? && ENV['DEBUG'].to_s != 'false') || ENV['DEBUG'].blank?
6
6
  log_file_path = File.join(File.expand_path(File.dirname(__FILE__)), 'log', 'celluloid_pubsub.log')
7
+ log_level = debug_enabled ? ::Logger::Severity::DEBUG : ::Logger::Severity::INFO
7
8
 
9
+ Celluloid.task_class = if defined?(Celluloid::TaskThread)
10
+ Celluloid::TaskThread
11
+ else
12
+ Celluloid::Task::Threaded
13
+ end
8
14
  # actor that subscribes to a channel
9
15
  class FirstActor
10
16
  include Celluloid
@@ -23,11 +29,10 @@ class FirstActor
23
29
  end
24
30
 
25
31
  def on_close(code, reason)
26
- puts "websocket connection closed: #{code.inspect}, #{reason.inspect}"
32
+ puts "subscriber: websocket connection closed: #{code.inspect}, #{reason.inspect}"
27
33
  terminate
28
34
  end
29
35
 
30
-
31
36
  end
32
37
 
33
38
  # actor that publishes a message in a channel
@@ -48,7 +53,7 @@ class SecondActor
48
53
  end
49
54
 
50
55
  def on_close(code, reason)
51
- puts "websocket connection closed: #{code.inspect}, #{reason.inspect}"
56
+ puts "publisher: websocket connection closed: #{code.inspect}, #{reason.inspect}"
52
57
  terminate
53
58
  end
54
59
 
@@ -57,9 +62,18 @@ end
57
62
 
58
63
  # please don't use the BaseActor class to supervise actors. This is subject to change . This class is used only to test backward compatibility.
59
64
  # For more information on how to supervise actors please see Celluloid wiki.
60
- CelluloidPubsub::BaseActor.setup_actor_supervision(CelluloidPubsub::WebServer, actor_name: :web_server, args: {enable_debug: debug_enabled, adapter: nil,log_file_path: log_file_path })
61
- CelluloidPubsub::BaseActor.setup_actor_supervision(FirstActor, actor_name: :first_actor, args: {enable_debug: debug_enabled })
62
- CelluloidPubsub::BaseActor.setup_actor_supervision(SecondActor, actor_name: :second_actor, args: {enable_debug: debug_enabled })
65
+ CelluloidPubsub::BaseActor.setup_actor_supervision(CelluloidPubsub::WebServer, actor_name: :web_server, args: {enable_debug: debug_enabled, spy: debug_enabled, adapter: nil,log_file_path: log_file_path, log_level: log_level })
66
+ if ENV['RUN_IN_PARALLEL'].nil? || ENV['RUN_IN_PARALLEL'].to_s.downcase == 'true'
67
+ [
68
+ { class: FirstActor, name: :first_actor },
69
+ { class: SecondActor, name: :second_actor }
70
+ ].pmap do |hash|
71
+ CelluloidPubsub::BaseActor.setup_actor_supervision(hash[:class], actor_name: hash[:name], args: { enable_debug: debug_enabled, log_level: log_level })
72
+ end
73
+ else
74
+ CelluloidPubsub::BaseActor.setup_actor_supervision(FirstActor, actor_name: :first_actor, args: { enable_debug: debug_enabled, log_level: log_level })
75
+ CelluloidPubsub::BaseActor.setup_actor_supervision(SecondActor, actor_name: :second_actor, args: { enable_debug: debug_enabled, log_level: log_level})
76
+ end
63
77
 
64
78
  signal_received = false
65
79
 
@@ -68,5 +82,13 @@ Signal.trap('INT') do
68
82
  signal_received = true
69
83
  end
70
84
 
71
- sleep 0.1 until signal_received
85
+ Kernel.sleep 0.1 until signal_received
72
86
  puts 'Exited succesfully! =)'
87
+
88
+ # use this if you want to see the `on_close` callbacks being fired
89
+ #Celluloid::Actor[:web_server].shutdown
90
+
91
+ # if you are using this, the `on_close` on the websocket connection won't get triggered
92
+ # in this case you will need a finalizer on the subscriber and publisher
93
+ # for when the actors are shutting down
94
+ Celluloid.shutdown
@@ -4,4 +4,4 @@ source "http://rubygems.org"
4
4
 
5
5
  gem "celluloid", "0.16.0"
6
6
 
7
- gemspec :path => "../"
7
+ gemspec path: "../"