celluloid_pubsub 1.0.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: 744da161b724c0f27b8d289aa174c5ed2631d257
4
- data.tar.gz: 76bcbc4331d662c180197baab699d2ca3d785ce9
2
+ SHA256:
3
+ metadata.gz: 03c8681e99ddf220f8fbdec951b30b6297e6d813e0dc81d179f1a203445eaee9
4
+ data.tar.gz: 2faac6758815b6a65da97967286e490b918cdcbcdf26098fa8bffc02cd8e29db
5
5
  SHA512:
6
- metadata.gz: fc67441aa3be5fe9ae514b6e93686ef36618449ab88b0283098f8f98dabfc054ee9270642bcbb511ceb277064eaf5fed4baaad10b97197fd1338b869f1859c5d
7
- data.tar.gz: 894a54c267978100949e1a789d72d8aa6a656aeba98a2c167bbc119ce3a2910d5be94b7f108a9943d941ab12c8b7527bd62494ffd5e78b5da8f70f6f16b78fd1
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/.reek CHANGED
@@ -16,3 +16,5 @@ ClassVariable:
16
16
  exclude_paths:
17
17
  - examples/**/**
18
18
  - spec/**/**
19
+
20
+
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,26 +1,67 @@
1
1
  language: ruby
2
- sudo: false
3
2
 
4
3
  cache: bundler
5
4
 
6
- bundler_args: --without test --jobs 3 --retry 3
5
+ 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
- script: bundle exec rake
26
+ script:
27
+ - echo $BUNDLE_GEMFILE
28
+ - bundle ${MY_BUNDLER_VERSION} exec rake
17
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
18
50
  rvm:
19
- - 2.0.0
20
- - 2.1.5
21
- - 2.2.2
22
- - 2.2.3
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
+
23
63
  env:
24
- - RAILS_ENV=test RACK_ENV=test
64
+ - RAILS_ENV=test RACK_ENV=test APP_ENV=test
65
+
25
66
  notifications:
26
67
  email: false
data/Appraisals CHANGED
@@ -1,7 +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
+
9
+ appraise "cell-0.17.4" do
10
+ gem "celluloid", "0.17.4"
11
+ end
12
+
13
+ appraise "cell-0.18.0" do
14
+ gem "celluloid", "0.18.0"
15
+ end
data/Gemfile CHANGED
@@ -1,8 +1,3 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gemspec
4
-
5
- if RUBY_VERSION < "2.2.0"
6
- gem 'activesupport', '>= 4.0', '< 5.0'
7
- gem 'bundler' , '< 1.13'
8
- end
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')
@@ -31,6 +31,11 @@ task :all do |_t|
31
31
  end
32
32
  end
33
33
 
34
+ # dirty hack for YardocTask
35
+ ::Rake.application.class.class_eval do
36
+ alias_method :last_comment, :last_description
37
+ end
38
+
34
39
  YARD::Config.options[:load_plugins] = true
35
40
  YARD::Config.load_plugins
36
41
 
@@ -1,3 +1,4 @@
1
+ require 'date'
1
2
  require File.expand_path('../lib/celluloid_pubsub/version', __FILE__)
2
3
 
3
4
  Gem::Specification.new do |s|
@@ -16,23 +17,24 @@ Gem::Specification.new do |s|
16
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
18
  s.executables = `git ls-files -- bin/*`.split('\n').map{ |f| File.basename(f) }
18
19
  s.require_paths = ['lib']
19
-
20
+
20
21
  s.add_runtime_dependency 'celluloid', '>= 0.16', '>= 0.16.0'
22
+ s.add_runtime_dependency 'celluloid-fsm'
21
23
  s.add_runtime_dependency 'celluloid-io', '>= 0.16', '>= 0.16.2'
22
- 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'
23
26
  s.add_runtime_dependency 'celluloid-websocket-client', '~> 0.0', '>= 0.0.1'
24
- s.add_runtime_dependency 'celluloid-pmap', '~> 0.2', '>= 0.2.2'
27
+ s.add_runtime_dependency 'celluloid-pmap', '~> 1.0'
25
28
  s.add_runtime_dependency 'activesupport', '>= 4.0', '>= 4.0'
26
29
 
27
30
  s.add_development_dependency 'appraisal', '~> 2.1', '>= 2.1'
28
- s.add_development_dependency 'rspec', '~> 3.4', '>= 3.4'
29
- s.add_development_dependency 'simplecov', '~> 0.10', '>= 0.10'
30
- s.add_development_dependency 'simplecov-summary', '~> 0.0.4', '>= 0.0.4'
31
- s.add_development_dependency 'mocha', '~> 1.1', '>= 1.1'
32
- s.add_development_dependency 'coveralls', '~> 0.7', '>= 0.7'
33
- s.add_development_dependency 'rake', '>= 10.5', '>= 10.5'
34
- s.add_development_dependency 'yard', '~> 0.8', '>= 0.8.7'
35
- s.add_development_dependency 'redcarpet', '~> 3.3', '>= 3.3'
36
- s.add_development_dependency 'github-markup', '~> 1.3', '>= 1.3.3'
37
- s.add_development_dependency 'inch', '~> 0.6', '>= 0.6'
31
+ s.add_development_dependency 'rspec', '~> 3.5', '>= 3.5'
32
+ s.add_development_dependency 'simplecov', '~> 0.12', '>= 0.12'
33
+ s.add_development_dependency 'simplecov-summary', '~> 0.0', '>= 0.0.5'
34
+ s.add_development_dependency 'coveralls', '~> 0.8', '>= 0.8'
35
+ s.add_development_dependency 'rake', '>= 12.0', '>= 12.0'
36
+ s.add_development_dependency 'yard', '>= 0.9.20'
37
+ s.add_development_dependency 'redcarpet', '~> 3.4', '>= 3.4'
38
+ s.add_development_dependency 'github-markup', '~> 1.4', '>= 1.4'
39
+ s.add_development_dependency 'inch', '~> 0.7', '>= 0.7'
38
40
  end
@@ -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