cubism 0.1.0.pre8 → 0.1.0.pre9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/channels/cubism/presence_channel.rb~ +1 -1
- data/app/models/concerns/cubism/presence.rb +7 -0
- data/app/models/concerns/cubism/presence.rb~ +5 -3
- data/lib/cubism/broadcaster.rb +1 -10
- data/lib/cubism/broadcaster.rb~ +2 -2
- data/lib/cubism/cubicle_block_store.rb +8 -0
- data/lib/cubism/cubicle_block_store.rb~ +27 -0
- data/lib/cubism/version.rb +1 -1
- data/lib/cubism/version.rb~ +1 -1
- data/lib/cubism.rb~ +8 -0
- metadata +54 -21
- data/app/channels/cubism/presence.rb~ +0 -18
- data/app/helpers/cubism_helper.rb~ +0 -20
- data/app/models/concerns/cubism/base.rb~ +0 -3
- data/app/models/concerns/cubism/user.rb~ +0 -11
- data/app/models/cubism/base.rb +0 -14
- data/app/models/cubism/base.rb~ +0 -13
- data/app/models/cubism/current.rb~ +0 -0
- data/lib/cubism/engine.rb~ +0 -5
- data/lib/cubism/railtie.rb~ +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 579dec94521951d33b64eb0c211a210fe86cc89f927a79489cd05258593e3634
|
4
|
+
data.tar.gz: 21d48a1e4c42ad33e27e11c1128930d22c2103120307a8bd0351d5321d520f9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57c779b3efd7deae25de93339ab19d4a673e2bfae83e3f0d02e62741780b8320d4f1e1dd1c2a4c07bfec3a42c417eb5c59e5fbdfddd43a586c28ed9f945e546a
|
7
|
+
data.tar.gz: 999b2cae4e2d0c506fd08a02dad104c7e66f50f863fd9f5a58fa600e4fa2d0409ad81d88819905541423b68fccb9d80589a03dafc75c6c6a510aed2966f164fb
|
@@ -3,7 +3,7 @@ class Cubism::PresenceChannel < ActionCable::Channel::Base
|
|
3
3
|
|
4
4
|
def subscribed
|
5
5
|
if resource.present?
|
6
|
-
|
6
|
+
stream_from params[:element_id]
|
7
7
|
resource.cubicle_element_ids << element_id
|
8
8
|
resource.excluded_user_id_for_element_id[element_id] = user.id if exclude_current_user?
|
9
9
|
else
|
@@ -10,4 +10,11 @@ module Cubism::Presence
|
|
10
10
|
def stream_presence
|
11
11
|
Cubism::Broadcaster.new(resource: self).broadcast
|
12
12
|
end
|
13
|
+
|
14
|
+
def present_users_for_element_id(element_id)
|
15
|
+
users = Cubism.user_class.find(present_users.members)
|
16
|
+
users.reject! { |user| user.id == excluded_user_id_for_element_id[element_id].to_i }
|
17
|
+
|
18
|
+
users
|
19
|
+
end
|
13
20
|
end
|
@@ -2,10 +2,12 @@ module Cubism::Presence
|
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
included do
|
5
|
-
kredis_set :present_users, after_change: :
|
5
|
+
kredis_set :present_users, after_change: :stream_presence
|
6
|
+
kredis_set :cubicle_element_ids
|
7
|
+
kredis_hash :excluded_user_id_for_element_id
|
6
8
|
end
|
7
9
|
|
8
|
-
def
|
9
|
-
Cubism::
|
10
|
+
def stream_presence
|
11
|
+
Cubism::Broadcaster.new(resource: self).broadcast
|
10
12
|
end
|
11
13
|
end
|
data/lib/cubism/broadcaster.rb
CHANGED
@@ -16,7 +16,7 @@ module Cubism
|
|
16
16
|
/cubicle-(?<block_key>.+)/ =~ element_id
|
17
17
|
block = Cubism.store[block_key].block
|
18
18
|
view_context = Cubism.store[block_key].context
|
19
|
-
html = view_context.capture(
|
19
|
+
html = view_context.capture(resource.present_users_for_element_id(element_id), &block)
|
20
20
|
|
21
21
|
cable_ready[element_id].inner_html(
|
22
22
|
selector: "cubicle-element##{element_id}[identifier='#{signed_stream_identifier(resource.to_global_id.to_s)}']",
|
@@ -24,14 +24,5 @@ module Cubism
|
|
24
24
|
).broadcast
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def users_for(resource, element_id)
|
31
|
-
users = Cubism.user_class.find(resource.present_users.members)
|
32
|
-
users.reject! { |user| user.id == resource.excluded_user_id_for_element_id[element_id].to_i }
|
33
|
-
|
34
|
-
users
|
35
|
-
end
|
36
27
|
end
|
37
28
|
end
|
data/lib/cubism/broadcaster.rb~
CHANGED
@@ -18,10 +18,10 @@ module Cubism
|
|
18
18
|
view_context = Cubism.store[block_key].context
|
19
19
|
html = view_context.capture(users_for(resource, element_id), &block)
|
20
20
|
|
21
|
-
cable_ready[
|
21
|
+
cable_ready[element_id].inner_html(
|
22
22
|
selector: "cubicle-element##{element_id}[identifier='#{signed_stream_identifier(resource.to_global_id.to_s)}']",
|
23
23
|
html: html
|
24
|
-
).
|
24
|
+
).broadcast
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -2,6 +2,8 @@ module Cubism
|
|
2
2
|
class CubicleBlockStore
|
3
3
|
include Singleton
|
4
4
|
|
5
|
+
delegate_missing_to :@blocks
|
6
|
+
|
5
7
|
def initialize
|
6
8
|
@blocks = {}
|
7
9
|
end
|
@@ -16,6 +18,12 @@ module Cubism
|
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
21
|
+
def clear
|
22
|
+
mutex.synchronize do
|
23
|
+
@blocks.clear
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
19
27
|
private
|
20
28
|
|
21
29
|
def mutex
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Cubism
|
2
|
+
class CubicleBlockStore
|
3
|
+
include Singleton
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@blocks = {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def [](key)
|
10
|
+
@blocks[key]
|
11
|
+
end
|
12
|
+
|
13
|
+
def []=(key, value)
|
14
|
+
mutex.synchronize do
|
15
|
+
@blocks[key] = value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def mutex
|
22
|
+
@mutex ||= Mutex.new
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
BlockStoreItem = Struct.new(:context, :block, keyword_init: true)
|
27
|
+
end
|
data/lib/cubism/version.rb
CHANGED
data/lib/cubism/version.rb~
CHANGED
data/lib/cubism.rb~
CHANGED
@@ -2,7 +2,15 @@ require "kredis"
|
|
2
2
|
|
3
3
|
require "cubism/version"
|
4
4
|
require "cubism/engine"
|
5
|
+
require "cubism/broadcaster"
|
6
|
+
require "cubism/cubicle_block_store"
|
5
7
|
|
6
8
|
module Cubism
|
9
|
+
extend ActiveSupport::Autoload
|
10
|
+
|
11
|
+
autoload :Broadcaster, "cubism/broadcaster"
|
12
|
+
|
7
13
|
mattr_accessor :user_class, instance_writer: false, instance_reader: false
|
14
|
+
|
15
|
+
mattr_reader :store, instance_reader: false, default: Cubism::CubicleBlockStore.instance
|
8
16
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cubism
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.pre9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Rubisch
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 6.
|
19
|
+
version: '6.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 6.
|
26
|
+
version: '6.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: kredis
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 5.0.0.pre8
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: standard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,49 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: nokogiri
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: mocha
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: appraisal
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sqlite3
|
71
113
|
requirement: !ruby/object:Gem::Requirement
|
72
114
|
requirements:
|
73
115
|
- - ">="
|
@@ -90,20 +132,13 @@ files:
|
|
90
132
|
- MIT-LICENSE
|
91
133
|
- README.md
|
92
134
|
- Rakefile
|
93
|
-
- app/channels/cubism/presence.rb~
|
94
135
|
- app/channels/cubism/presence_channel.rb
|
95
136
|
- app/channels/cubism/presence_channel.rb~
|
96
137
|
- app/helpers/cubism_helper.rb
|
97
|
-
- app/helpers/cubism_helper.rb~
|
98
|
-
- app/models/concerns/cubism/base.rb~
|
99
138
|
- app/models/concerns/cubism/presence.rb
|
100
139
|
- app/models/concerns/cubism/presence.rb~
|
101
140
|
- app/models/concerns/cubism/user.rb
|
102
|
-
- app/models/concerns/cubism/user.rb~
|
103
|
-
- app/models/cubism/base.rb
|
104
|
-
- app/models/cubism/base.rb~
|
105
141
|
- app/models/cubism/current.rb
|
106
|
-
- app/models/cubism/current.rb~
|
107
142
|
- config/routes.rb
|
108
143
|
- lib/cubism.rb
|
109
144
|
- lib/cubism.rb~
|
@@ -112,8 +147,6 @@ files:
|
|
112
147
|
- lib/cubism/cubicle_block_store.rb
|
113
148
|
- lib/cubism/cubicle_block_store.rb~
|
114
149
|
- lib/cubism/engine.rb
|
115
|
-
- lib/cubism/engine.rb~
|
116
|
-
- lib/cubism/railtie.rb~
|
117
150
|
- lib/cubism/version.rb
|
118
151
|
- lib/cubism/version.rb~
|
119
152
|
- lib/tasks/cubism_tasks.rake
|
@@ -123,7 +156,7 @@ licenses:
|
|
123
156
|
metadata:
|
124
157
|
homepage_uri: https://github.com/julianrubisch/cubism
|
125
158
|
source_code_uri: https://github.com/julianrubisch/cubism.git
|
126
|
-
post_install_message:
|
159
|
+
post_install_message:
|
127
160
|
rdoc_options: []
|
128
161
|
require_paths:
|
129
162
|
- lib
|
@@ -138,8 +171,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
171
|
- !ruby/object:Gem::Version
|
139
172
|
version: 1.3.1
|
140
173
|
requirements: []
|
141
|
-
rubygems_version: 3.
|
142
|
-
signing_key:
|
174
|
+
rubygems_version: 3.1.4
|
175
|
+
signing_key:
|
143
176
|
specification_version: 4
|
144
177
|
summary: Lightweight Resource-Based Presence Solution with CableReady
|
145
178
|
test_files: []
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class Cubism::Presence < ActionCable::Channel::Base
|
2
|
-
def subscribed
|
3
|
-
resource = GlobalID::Locator.locate_signed params[:signed_resource]
|
4
|
-
if resource.present?
|
5
|
-
stream_for resource
|
6
|
-
resource.present_users.add(current_user.id)
|
7
|
-
else
|
8
|
-
reject
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def unsubscribed
|
13
|
-
resource = GlobalID::Locator.locate_signed params[:signed_resource]
|
14
|
-
return unless resource.present?
|
15
|
-
|
16
|
-
resource.present_users.remove(current_user.id)
|
17
|
-
end
|
18
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module CubismHelper
|
2
|
-
include CableReady::StreamIdentifier
|
3
|
-
|
4
|
-
def cubicle_for(resource, user, html_options: {}, appear_trigger: :connect, disappear_trigger: nil, trigger_root: nil, exclude_current_user: true, &block)
|
5
|
-
key = "#{block.source_location.join(":")}:#{resource.to_gid}:#{user.to_gid}"
|
6
|
-
digested_id = ActiveSupport::Digest.hexdigest(key)
|
7
|
-
|
8
|
-
Cubism.store[digested_id] = Cubism::BlockStoreItem.new(context: self, block: block.dup)
|
9
|
-
tag.cubicle_element(
|
10
|
-
identifier: signed_stream_identifier(resource.to_gid.to_s),
|
11
|
-
user: user.to_sgid.to_s,
|
12
|
-
"appear-trigger": appear_trigger,
|
13
|
-
"disappear-trigger": disappear_trigger,
|
14
|
-
"trigger-root": trigger_root,
|
15
|
-
id: "cubicle-#{digested_id}",
|
16
|
-
"exclude-current-user": exclude_current_user,
|
17
|
-
**html_options
|
18
|
-
)
|
19
|
-
end
|
20
|
-
end
|
data/app/models/cubism/base.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
class Cubism::Base
|
2
|
-
include ActiveModel::Model
|
3
|
-
include Kredis::Attributes
|
4
|
-
include Cubism::Presence
|
5
|
-
include GlobalID::Identification
|
6
|
-
|
7
|
-
def self.find(id)
|
8
|
-
new if id == "cubism-#{self.class.name.underscore}"
|
9
|
-
end
|
10
|
-
|
11
|
-
def id
|
12
|
-
"cubism-#{self.class.name.underscore}"
|
13
|
-
end
|
14
|
-
end
|
data/app/models/cubism/base.rb~
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
class Cubism::Base
|
2
|
-
include ActiveModel::Model
|
3
|
-
include Cubism::Presence
|
4
|
-
include GlobalID::Identifiable
|
5
|
-
|
6
|
-
def self.find(id)
|
7
|
-
new if id == "cubism-#{self.class.name.underscore}"
|
8
|
-
end
|
9
|
-
|
10
|
-
def id
|
11
|
-
"cubism-#{self.class.name.underscore}"
|
12
|
-
end
|
13
|
-
end
|
File without changes
|
data/lib/cubism/engine.rb~
DELETED
data/lib/cubism/railtie.rb~
DELETED