federal_offense 0.1.0 → 0.1.2

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
2
  SHA256:
3
- metadata.gz: 72a753592cc61bfb16aa40f12c821def2d9a5b19d1420d6656d023f50528765a
4
- data.tar.gz: 31da2e309fc35f087665fbc3e347b26a1434f9baf157c955cb961f7f904ea969
3
+ metadata.gz: c8f2aad73ac12c17667d27c4e8ab4bed3a05404d1ce27124bdce05dd3f7b9460
4
+ data.tar.gz: 6826764368d5158c1148ebb25ab4afb819c47260273e8891297cfd49a1ecc54d
5
5
  SHA512:
6
- metadata.gz: 7ad12b89234faad79ecf3858b3faef262cca1b3ff571404a6d4db3e87335010589d1d48f53d8790d4cf5afea4dae8f162e2fdeaf3713616417d80558f5c8ba42
7
- data.tar.gz: 1340009c960bd94aee253855c7d7b5d3e972b8ccbcdc9d40f39295a24ffd2077559bb5d9df92c44894313133c51a58e5aa3be4ba509031f4c5a700150ebdbb2e
6
+ metadata.gz: 1b9230af21379c71f1f967b08ab6f025eb80e5461ef403d937e4be55266ae75464f052655d8786e7539b4b049601ab750cafd78a722b6a47eed35a0dba6f6460
7
+ data.tar.gz: 7c67a2bf94aeb01807cb7e639dde8f4fe0e193cae31a4082b60add146175939fd3b033bec09cddeead8682fc26ac871341cae9142a736a377367830686fc7905
@@ -1,7 +1,7 @@
1
1
  //= require ./vendor/action_cable
2
2
 
3
3
  const consumer = ActionCable.createConsumer()
4
- consumer.subscriptions.create("FederalOffense::InboxChannel", {
4
+ consumer.subscriptions.create("FederalOffense::ActionCable::InboxChannel", {
5
5
  connected: () => {
6
6
  /* NOOP */
7
7
  },
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FederalOffense
4
+ module ActionCable
5
+ def self.broadcast!(message: {reload: true})
6
+ InboxChannel.broadcast!(message: message)
7
+ end
8
+
9
+ class Connection < ::ActionCable::Connection::Base
10
+ end
11
+
12
+ class InboxChannel < ::ActionCable::Channel::Base
13
+ def self.broadcast!(message: {reload: true})
14
+ FederalOffense::Engine.cable_server.broadcast(name, message)
15
+ end
16
+
17
+ def subscribed
18
+ stream_from self.class.name
19
+ end
20
+
21
+ def unsubscribed
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_dependency "federal_offense/action_cable" if defined? ActionCable
3
4
  require_dependency "federal_offense/interceptor"
4
5
 
5
6
  module FederalOffense
@@ -10,9 +11,9 @@ module FederalOffense
10
11
  attr_accessor :cable_server
11
12
 
12
13
  def cable_config
13
- @cable_config ||= ActionCable::Server::Configuration.new.tap do |config|
14
+ @cable_config ||= ::ActionCable::Server::Configuration.new.tap do |config|
14
15
  config.logger = Rails.logger
15
- config.connection_class = -> { FederalOffense::ApplicationCable::Connection }
16
+ config.connection_class = -> { FederalOffense::ActionCable::Connection }
16
17
  config.mount_path = "cable"
17
18
  end
18
19
  end
@@ -34,24 +35,30 @@ module FederalOffense
34
35
 
35
36
  # Enable ActionCable connections in the inbox for auto-reload
36
37
  initializer "action_cable_connection" do |app|
37
- # Find cable configs
38
- federal_offense_config_path = Rails.root.join("config", "federal_offense_cable.yml")
39
- app_config_path = Rails.root.join("config", "cable.yml")
40
-
41
- # Determine which config we're going to use
42
- config = if File.exist?(federal_offense_config_path)
43
- app.config_for(federal_offense_config_path).with_indifferent_access
44
- elsif File.exist?(app_config_path)
45
- app.config_for(app_config_path).with_indifferent_access
38
+ if defined? ::ActionCable
39
+ # Activate ActionCable
40
+ FederalOffense.action_cable = true
41
+
42
+ # Find cable configs
43
+ federal_offense_config_path = Rails.root.join("config", "federal_offense_cable.yml")
44
+ app_config_path = Rails.root.join("config", "cable.yml")
45
+
46
+ # Determine which config we're going to use
47
+ config = if File.exist?(federal_offense_config_path)
48
+ app.config_for(federal_offense_config_path).with_indifferent_access
49
+ elsif File.exist?(app_config_path)
50
+ app.config_for(app_config_path).with_indifferent_access
51
+ else
52
+ # Default to an async cable cause whatever
53
+ {adapter: "async"}
54
+ end
55
+
56
+ # Assign the values to the cable config and create a server
57
+ self.class.cable_config.cable = config
58
+ self.class.cable_server = ::ActionCable::Server::Base.new(config: self.class.cable_config)
46
59
  else
47
- # Default to an async cable cause whatever
48
- {adapter: "async"}
60
+ FederalOffense.action_cable = false
49
61
  end
50
-
51
- # Assign the values to the cable config and create a server
52
- self.class.cable_config.cable = config
53
- self.class.cable_server = ActionCable::Server::Base.new(config: self.class.cable_config)
54
- FederalOffense.action_cable = true
55
62
  end
56
63
  end
57
64
  end
@@ -4,7 +4,7 @@ module FederalOffense
4
4
  class Interceptor
5
5
  def self.delivering_email(message)
6
6
  FederalOffense::Message.create(message)
7
- FederalOffense::InboxChannel.broadcast!
7
+ FederalOffense::ActionCable.broadcast! if FederalOffense.action_cable
8
8
  end
9
9
  end
10
10
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FederalOffense
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: federal_offense
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flip Sasser
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-28 00:00:00.000000000 Z
11
+ date: 2020-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -238,9 +238,6 @@ files:
238
238
  - app/assets/stylesheets/federal_offense/components/nav.css
239
239
  - app/assets/stylesheets/federal_offense/components/section.css
240
240
  - app/assets/stylesheets/federal_offense/components/table.css
241
- - app/channels/federal_offense/application_cable/channel.rb
242
- - app/channels/federal_offense/application_cable/connection.rb
243
- - app/channels/federal_offense/inbox_channel.rb
244
241
  - app/controllers/federal_offense/application_controller.rb
245
242
  - app/controllers/federal_offense/messages_controller.rb
246
243
  - app/helpers/federal_offense/application_helper.rb
@@ -251,6 +248,7 @@ files:
251
248
  - config/locales/en.yml
252
249
  - config/routes.rb
253
250
  - lib/federal_offense.rb
251
+ - lib/federal_offense/action_cable.rb
254
252
  - lib/federal_offense/engine.rb
255
253
  - lib/federal_offense/interceptor.rb
256
254
  - lib/federal_offense/version.rb
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module FederalOffense
4
- module ApplicationCable
5
- class Channel < ActionCable::Channel::Base
6
- end
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module FederalOffense
4
- module ApplicationCable
5
- class Connection < ActionCable::Connection::Base
6
- end
7
- end
8
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module FederalOffense
4
- class InboxChannel < FederalOffense::ApplicationCable::Channel
5
- def self.broadcast!(message: {reload: true})
6
- FederalOffense::Engine.cable_server.broadcast(name, message)
7
- end
8
-
9
- def subscribed
10
- stream_from self.class.name
11
- end
12
-
13
- def unsubscribed
14
- end
15
- end
16
- end