cubism 0.1.0.pre6 → 0.1.0.pre10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +15 -5
- data/app/channels/cubism/presence_channel.rb~ +1 -1
- data/app/helpers/cubism_helper.rb +22 -5
- data/app/helpers/cubism_helper.rb~ +19 -9
- data/app/models/concerns/cubism/presence.rb +7 -0
- data/app/models/concerns/cubism/presence.rb~ +5 -3
- data/lib/cubism/broadcaster.rb +5 -12
- data/lib/cubism/broadcaster.rb~ +27 -14
- data/lib/cubism/cubicle_block_store.rb +34 -5
- data/lib/cubism/cubicle_block_store.rb~ +43 -0
- data/lib/cubism/engine.rb +3 -0
- data/lib/cubism/engine.rb~ +0 -1
- data/{app/models/cubism/current.rb~ → lib/cubism/parser.rb~} +0 -0
- data/lib/cubism/preprocessor.rb +30 -0
- data/lib/cubism/preprocessor.rb~ +26 -0
- data/lib/cubism/version.rb +1 -1
- data/lib/cubism/version.rb~ +1 -1
- data/lib/cubism.rb +3 -1
- data/lib/cubism.rb~ +10 -0
- metadata +57 -19
- data/app/channels/cubism/presence.rb~ +0 -18
- 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/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: 976cb8cfb5c2fe6edb6dd6e541c74361ae17dd12ce717bafadcb6ff6bdd1b9f1
|
4
|
+
data.tar.gz: a3e777efd1df0423ab4754ed30fe119b6497197ec2bc8ee564304385b907849d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 163db944110832cefb97406ebc7c4c98b231fdf98d9cce25abe164469eb64d9930d5aa1689c53426605dd11e42cbb721e314430a7b1ec1b7acc37449a676f702
|
7
|
+
data.tar.gz: b1c4052e437c7ebe723615e4b3316f1ac5d538aa2008b87957aca8762cd04bf61aed0f930aac42256aa07340d1c05652611fdcd47cad2f4b2e9d870393999e18
|
data/README.md
CHANGED
@@ -4,7 +4,9 @@
|
|
4
4
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
5
5
|
[](https://twitter.com/julian_rubisch)
|
6
6
|
|
7
|
-
Lightweight Resource-Based Presence Solution with CableReady
|
7
|
+
Lightweight Resource-Based Presence Solution with CableReady.
|
8
|
+
|
9
|
+
`Cubism` provides real-time updates of who is viewing or interacting with whatever resources you need. Whether you want Slack's "X is typing..." indicator or an e-commerce "5 other customers are viewing this item" notice, `Cubism` gives you everything you need "under the hood" so that you can focus on what really matters—end-user functionality.
|
8
10
|
|
9
11
|
## Table of Contents
|
10
12
|
|
@@ -12,6 +14,7 @@ Lightweight Resource-Based Presence Solution with CableReady
|
|
12
14
|
- [Usage](#usage)
|
13
15
|
- [Installation](#installation)
|
14
16
|
- [API](#api)
|
17
|
+
- [Limitations](#limitations)
|
15
18
|
- [Gotchas](#gotchas)
|
16
19
|
- [Contributing](#contributing)
|
17
20
|
- [License](#license)
|
@@ -54,6 +57,8 @@ Using the `cubicle_for` helper, you can set up a presence indicator. It will
|
|
54
57
|
<% end %>
|
55
58
|
```
|
56
59
|
|
60
|
+
**Important!** due to technical limitations the cubism block does _not_ act as a closure, i.e. it has _only_ access to the `users` variable passed to it - think of it more as a self-contained component.
|
61
|
+
|
57
62
|
## Installation
|
58
63
|
Add this line to your application's Gemfile:
|
59
64
|
|
@@ -91,12 +96,17 @@ CableReady.initialize({ consumer });
|
|
91
96
|
|
92
97
|
The `cubicle_for` helper accepts the following options as keyword arguments:
|
93
98
|
|
94
|
-
- `exclude_current_user (true|false)`: Whether or not to exclude the current user from the list of present users broadcasted to the view. Useful e.g. for "typing..." indicators.
|
95
|
-
- `appear_trigger`:
|
96
|
-
- `disappear_trigger`: a JavaScript event name (e.g. `:blur`) to use. The default is `:disconnect`, i.e. remove a user form the present users list when the element disconnects from the DOM.
|
99
|
+
- `exclude_current_user (true|false)`: Whether or not to exclude the current user from the list of present users broadcasted to the view. Useful e.g. for "typing..." indicators (default: `true`).
|
100
|
+
- `appear_trigger`: JavaScript event names (e.g. `["focus", "debounced:input]`) to use. (Can also be a singular string, which will be converted to an array). The default is `:connect`, i.e. register a user as "appeared"/"present" when the element connects to the DOM.
|
101
|
+
- `disappear_trigger`: a JavaScript event name (e.g. `:blur`) to use. (Can also be a singular string, which will be converted to an array). The default is `:disconnect`, i.e. remove a user form the present users list when the element disconnects from the DOM.
|
97
102
|
- `trigger_root`: a CSS selector to attach the appear/disappear events to. Defaults to the `cubicle-element` itself.
|
98
103
|
- `html_options` are passed to the TagBuilder.
|
99
104
|
|
105
|
+
## Limitations
|
106
|
+
|
107
|
+
### Supported Template Handlers
|
108
|
+
- ERB
|
109
|
+
|
100
110
|
## Gotchas
|
101
111
|
|
102
112
|
### Usage with ViewComponent
|
@@ -177,4 +187,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
177
187
|
<!-- markdownlint-restore -->
|
178
188
|
<!-- prettier-ignore-end -->
|
179
189
|
|
180
|
-
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
190
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
@@ -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
|
@@ -2,17 +2,34 @@ module CubismHelper
|
|
2
2
|
include CableReady::StreamIdentifier
|
3
3
|
|
4
4
|
def cubicle_for(resource, user, html_options: {}, appear_trigger: :connect, disappear_trigger: nil, trigger_root: nil, exclude_current_user: true, &block)
|
5
|
-
|
6
|
-
|
5
|
+
filename, lineno = block.source_location
|
6
|
+
block_location = block.source_location.join(":")
|
7
|
+
resource_user_key = "#{resource.to_gid}:#{user.to_gid}"
|
8
|
+
digested_block_key = ActiveSupport::Digest.hexdigest("#{block_location}:#{resource_user_key}")
|
9
|
+
|
10
|
+
# the store item (identified by block location, resource, and user) might already be present
|
11
|
+
store_item = Cubism.store[digested_block_key] || Cubism::BlockStoreItem.new(
|
12
|
+
block_location: block_location,
|
13
|
+
resource_gid: resource.to_gid.to_s,
|
14
|
+
user_gid: user.to_gid.to_s
|
15
|
+
)
|
16
|
+
|
17
|
+
if Cubism.store[digested_block_key]&.block_source.blank? && !block_location.start_with?("inline template")
|
18
|
+
lines = File.readlines(filename)[lineno - 1..]
|
19
|
+
|
20
|
+
preprocessor = Cubism::Preprocessor.new(source: lines.join.squish, view_context: self)
|
21
|
+
store_item.block_source = preprocessor.process
|
22
|
+
end
|
23
|
+
|
24
|
+
Cubism.store[digested_block_key] = store_item
|
7
25
|
|
8
|
-
Cubism.store[digested_id] = Cubism::BlockStoreItem.new(context: self, block: block.dup)
|
9
26
|
tag.cubicle_element(
|
10
27
|
identifier: signed_stream_identifier(resource.to_gid.to_s),
|
11
28
|
user: user.to_sgid.to_s,
|
12
|
-
"appear-trigger": appear_trigger,
|
29
|
+
"appear-trigger": Array(appear_trigger).join(","),
|
13
30
|
"disappear-trigger": disappear_trigger,
|
14
31
|
"trigger-root": trigger_root,
|
15
|
-
id: "cubicle-#{
|
32
|
+
id: "cubicle-#{digested_block_key}",
|
16
33
|
"exclude-current-user": exclude_current_user,
|
17
34
|
**html_options
|
18
35
|
)
|
@@ -2,23 +2,33 @@ module CubismHelper
|
|
2
2
|
include CableReady::StreamIdentifier
|
3
3
|
|
4
4
|
def cubicle_for(resource, user, html_options: {}, appear_trigger: :connect, disappear_trigger: nil, trigger_root: nil, exclude_current_user: true, &block)
|
5
|
-
|
6
|
-
|
5
|
+
filename, lineno = block.source_location
|
6
|
+
block_location = block.source_location.join(":")
|
7
|
+
resource_user_key = "#{resource.to_gid}:#{user.to_gid}"
|
8
|
+
digested_block_key = ActiveSupport::Digest.hexdigest("#{block_location}:#{resource_user_key}")
|
7
9
|
|
8
|
-
Cubism.store[
|
9
|
-
|
10
|
+
Cubism.store[digested_block_key] = Cubism::BlockStoreItem.new(
|
11
|
+
block_location: block_location,
|
12
|
+
resource_gid: resource.to_gid.to_s,
|
13
|
+
user_gid: user.to_gid.to_s
|
14
|
+
)
|
15
|
+
|
16
|
+
if Cubism.store[block_location].blank? && !block_location.start_with?("inline template")
|
17
|
+
lines = File.readlines(filename)[lineno - 1..]
|
18
|
+
|
19
|
+
preprocessor = Cubism::Preprocessor.new(source: lines.join.squish, view_context: self)
|
20
|
+
Cubism.store[block_location] = preprocessor.process
|
21
|
+
end
|
10
22
|
|
11
23
|
tag.cubicle_element(
|
12
24
|
identifier: signed_stream_identifier(resource.to_gid.to_s),
|
13
25
|
user: user.to_sgid.to_s,
|
14
|
-
"appear-trigger": appear_trigger,
|
26
|
+
"appear-trigger": Array(appear_trigger).join(","),
|
15
27
|
"disappear-trigger": disappear_trigger,
|
16
28
|
"trigger-root": trigger_root,
|
17
|
-
id: "cubicle-#{
|
29
|
+
id: "cubicle-#{digested_block_key}",
|
18
30
|
"exclude-current-user": exclude_current_user,
|
19
31
|
**html_options
|
20
|
-
)
|
21
|
-
content_tag(:template, template, {slot: "template"})
|
22
|
-
end
|
32
|
+
)
|
23
33
|
end
|
24
34
|
end
|
@@ -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
@@ -14,9 +14,11 @@ module Cubism
|
|
14
14
|
def broadcast
|
15
15
|
resource.cubicle_element_ids.to_a.each do |element_id|
|
16
16
|
/cubicle-(?<block_key>.+)/ =~ element_id
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
store_item = Cubism.store[block_key]
|
18
|
+
|
19
|
+
next if store_item.blank?
|
20
|
+
|
21
|
+
html = ApplicationController.render(inline: store_item.block_source, locals: {users: resource.present_users_for_element_id(element_id)})
|
20
22
|
|
21
23
|
cable_ready[element_id].inner_html(
|
22
24
|
selector: "cubicle-element##{element_id}[identifier='#{signed_stream_identifier(resource.to_global_id.to_s)}']",
|
@@ -24,14 +26,5 @@ module Cubism
|
|
24
26
|
).broadcast
|
25
27
|
end
|
26
28
|
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
29
|
end
|
37
30
|
end
|
data/lib/cubism/broadcaster.rb~
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
require "cable_ready"
|
2
|
+
require "parser/current"
|
2
3
|
|
3
4
|
module Cubism
|
4
5
|
class Broadcaster
|
5
6
|
include CableReady::Broadcaster
|
6
7
|
include CableReady::StreamIdentifier
|
8
|
+
include ActionView::Helpers
|
7
9
|
|
8
10
|
attr_reader :resource
|
9
11
|
|
@@ -14,24 +16,35 @@ module Cubism
|
|
14
16
|
def broadcast
|
15
17
|
resource.cubicle_element_ids.to_a.each do |element_id|
|
16
18
|
/cubicle-(?<block_key>.+)/ =~ element_id
|
17
|
-
|
18
|
-
view_context = Cubism.store[block_key].context
|
19
|
-
html = view_context.capture(users_for(resource, element_id), &block)
|
19
|
+
block_store_item = Cubism.store[block_key]
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
next if block_store_item.blank?
|
22
|
+
|
23
|
+
block_source = Cubism.store[block_store_item.block_location]
|
24
|
+
erubi = ActionView::Template::Handlers::ERB::Erubi.new(block_source)
|
25
|
+
ast = Parser::CurrentRuby.parse erubi.src
|
26
|
+
|
27
|
+
# html = ApplicationController.render(inline: block_source, locals: {current_user: block_store_item.user, "@project": block_store_item.resource, users: resource.present_users_for_element_id(element_id)})
|
27
28
|
|
28
|
-
|
29
|
+
# binding.pry
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
# context = ActionView::Base.with_view_paths(ActionController::Base.view_paths)
|
32
|
+
# erubi = ActionView::Template::Handlers::ERB::Erubi.new(File.read(filename), filename: filename)
|
33
|
+
# context = ApplicationController.new.view_context
|
33
34
|
|
34
|
-
|
35
|
+
# filename, lineno = block_store_item.block_location.split
|
36
|
+
|
37
|
+
# binding.pry
|
38
|
+
|
39
|
+
# block = Cubism.store[block_key].block
|
40
|
+
# view_context = Cubism.store[block_key].context
|
41
|
+
# html = view_context.capture(resource.present_users_for_element_id(element_id), &block)
|
42
|
+
|
43
|
+
cable_ready[element_id].inner_html(
|
44
|
+
selector: "cubicle-element##{element_id}[identifier='#{signed_stream_identifier(resource.to_global_id.to_s)}']",
|
45
|
+
html: "#{resource.present_users_for_element_id(element_id).map(&:id)}"
|
46
|
+
).broadcast
|
47
|
+
end
|
35
48
|
end
|
36
49
|
end
|
37
50
|
end
|
@@ -1,21 +1,32 @@
|
|
1
1
|
module Cubism
|
2
2
|
class CubicleBlockStore
|
3
|
-
|
3
|
+
delegate_missing_to :@blocks
|
4
4
|
|
5
5
|
def initialize
|
6
|
-
@blocks =
|
6
|
+
@blocks = Kredis.hash "cubism-blocks"
|
7
7
|
end
|
8
8
|
|
9
9
|
def [](key)
|
10
|
-
@blocks[key]
|
10
|
+
Marshal.load(@blocks[key]) if @blocks[key]
|
11
11
|
end
|
12
12
|
|
13
13
|
def []=(key, value)
|
14
14
|
mutex.synchronize do
|
15
|
-
@blocks[key] = value
|
15
|
+
@blocks[key] = Marshal.dump value
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def clear
|
20
|
+
mutex.synchronize do
|
21
|
+
# kredis #remove
|
22
|
+
@blocks.remove
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def size
|
27
|
+
@blocks.to_h.size
|
28
|
+
end
|
29
|
+
|
19
30
|
private
|
20
31
|
|
21
32
|
def mutex
|
@@ -23,5 +34,23 @@ module Cubism
|
|
23
34
|
end
|
24
35
|
end
|
25
36
|
|
26
|
-
BlockStoreItem = Struct.new(:
|
37
|
+
BlockStoreItem = Struct.new(:block_location, :block_source, :user_gid, :resource_gid, keyword_init: true) do
|
38
|
+
def user
|
39
|
+
GlobalID::Locator.locate self[:user_gid]
|
40
|
+
end
|
41
|
+
|
42
|
+
def resource
|
43
|
+
GlobalID::Locator.locate self[:resource_gid]
|
44
|
+
end
|
45
|
+
|
46
|
+
def marshal_dump
|
47
|
+
to_h
|
48
|
+
end
|
49
|
+
|
50
|
+
def marshal_load(serialized_item)
|
51
|
+
%i[block_location block_source user_gid resource_gid].each do |arg|
|
52
|
+
send("#{arg}=", serialized_item[arg])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
27
56
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Cubism
|
2
|
+
class CubicleBlockStore
|
3
|
+
include Singleton
|
4
|
+
|
5
|
+
delegate_missing_to :@blocks
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@blocks = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def [](key)
|
12
|
+
@blocks[key]
|
13
|
+
end
|
14
|
+
|
15
|
+
def []=(key, value)
|
16
|
+
mutex.synchronize do
|
17
|
+
@blocks[key] = value
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def clear
|
22
|
+
mutex.synchronize do
|
23
|
+
@blocks.clear
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def mutex
|
30
|
+
@mutex ||= Mutex.new
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
BlockStoreItem = Struct.new(:block_location, :user_gid, :resource_gid, keyword_init: true) do
|
35
|
+
def user
|
36
|
+
GlobalID::Locator.locate self[:user_gid]
|
37
|
+
end
|
38
|
+
|
39
|
+
def resource
|
40
|
+
GlobalID::Locator.locate self[:resource_gid]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/cubism/engine.rb
CHANGED
data/lib/cubism/engine.rb~
CHANGED
File without changes
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Cubism
|
2
|
+
class Preprocessor
|
3
|
+
def initialize(source:, view_context:)
|
4
|
+
match_data = /<%=\s+cubicle_for.+\|.+\|\s+%>/.match(source)
|
5
|
+
start_pos = match_data&.end(0) || 0
|
6
|
+
@source = source[start_pos..]
|
7
|
+
@view_context = view_context
|
8
|
+
end
|
9
|
+
|
10
|
+
def process
|
11
|
+
begin
|
12
|
+
do_parse
|
13
|
+
rescue NameError
|
14
|
+
# we ignore any name errors from unset instance variables or local assigns here
|
15
|
+
end
|
16
|
+
|
17
|
+
@source
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def do_parse
|
23
|
+
ActionView::Template::Handlers::ERB::Erubi.new(@source).evaluate(@view_context)
|
24
|
+
rescue SyntaxError
|
25
|
+
end_at_end = /(<%\s+end\s+%>)\z/.match(@source)
|
26
|
+
@source = end_at_end ? @source[..-(end_at_end[0].length + 1)] : @source[..-2]
|
27
|
+
do_parse
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Cubism
|
2
|
+
class Preprocessor
|
3
|
+
def initialize(source:, view_context:)
|
4
|
+
start_pos = /<%= cubicle_for/ =~ source
|
5
|
+
@source = source[start_pos..]
|
6
|
+
@view_context = view_context
|
7
|
+
end
|
8
|
+
|
9
|
+
def process
|
10
|
+
begin
|
11
|
+
do_parse
|
12
|
+
rescue NameError
|
13
|
+
# we ignore any name errors from unset instance variables or local assigns here
|
14
|
+
end
|
15
|
+
|
16
|
+
@source
|
17
|
+
end
|
18
|
+
|
19
|
+
def do_parse
|
20
|
+
ActionView::Template::Handlers::ERB::Erubi.new(@source).evaluate(@view_context)
|
21
|
+
rescue SyntaxError
|
22
|
+
@source = @source[..-2]
|
23
|
+
do_parse
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/cubism/version.rb
CHANGED
data/lib/cubism/version.rb~
CHANGED
data/lib/cubism.rb
CHANGED
@@ -4,13 +4,15 @@ require "cubism/version"
|
|
4
4
|
require "cubism/engine"
|
5
5
|
require "cubism/broadcaster"
|
6
6
|
require "cubism/cubicle_block_store"
|
7
|
+
require "cubism/preprocessor"
|
7
8
|
|
8
9
|
module Cubism
|
9
10
|
extend ActiveSupport::Autoload
|
10
11
|
|
11
12
|
autoload :Broadcaster, "cubism/broadcaster"
|
13
|
+
autoload :Preprocessor, "cubism/preprocessor"
|
12
14
|
|
13
15
|
mattr_accessor :user_class, instance_writer: false, instance_reader: false
|
14
16
|
|
15
|
-
|
17
|
+
mattr_accessor :store, instance_reader: false
|
16
18
|
end
|
data/lib/cubism.rb~
CHANGED
@@ -2,7 +2,17 @@ require "kredis"
|
|
2
2
|
|
3
3
|
require "cubism/version"
|
4
4
|
require "cubism/engine"
|
5
|
+
require "cubism/broadcaster"
|
6
|
+
require "cubism/cubicle_block_store"
|
7
|
+
require "cubism/preprocessor"
|
5
8
|
|
6
9
|
module Cubism
|
10
|
+
extend ActiveSupport::Autoload
|
11
|
+
|
12
|
+
autoload :Broadcaster, "cubism/broadcaster"
|
13
|
+
autoload :Preprocessor, "cubism/preprocessor"
|
14
|
+
|
7
15
|
mattr_accessor :user_class, instance_writer: false, instance_reader: false
|
16
|
+
|
17
|
+
mattr_reader :store, instance_reader: false, default: Cubism::CubicleBlockStore.instance
|
8
18
|
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.pre10
|
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-24 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,14 @@ 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
138
|
- app/helpers/cubism_helper.rb~
|
98
|
-
- app/models/concerns/cubism/base.rb~
|
99
139
|
- app/models/concerns/cubism/presence.rb
|
100
140
|
- app/models/concerns/cubism/presence.rb~
|
101
141
|
- 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
142
|
- app/models/cubism/current.rb
|
106
|
-
- app/models/cubism/current.rb~
|
107
143
|
- config/routes.rb
|
108
144
|
- lib/cubism.rb
|
109
145
|
- lib/cubism.rb~
|
@@ -113,7 +149,9 @@ files:
|
|
113
149
|
- lib/cubism/cubicle_block_store.rb~
|
114
150
|
- lib/cubism/engine.rb
|
115
151
|
- lib/cubism/engine.rb~
|
116
|
-
- lib/cubism/
|
152
|
+
- lib/cubism/parser.rb~
|
153
|
+
- lib/cubism/preprocessor.rb
|
154
|
+
- lib/cubism/preprocessor.rb~
|
117
155
|
- lib/cubism/version.rb
|
118
156
|
- lib/cubism/version.rb~
|
119
157
|
- lib/tasks/cubism_tasks.rake
|
@@ -123,7 +161,7 @@ licenses:
|
|
123
161
|
metadata:
|
124
162
|
homepage_uri: https://github.com/julianrubisch/cubism
|
125
163
|
source_code_uri: https://github.com/julianrubisch/cubism.git
|
126
|
-
post_install_message:
|
164
|
+
post_install_message:
|
127
165
|
rdoc_options: []
|
128
166
|
require_paths:
|
129
167
|
- lib
|
@@ -138,8 +176,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
176
|
- !ruby/object:Gem::Version
|
139
177
|
version: 1.3.1
|
140
178
|
requirements: []
|
141
|
-
rubygems_version: 3.
|
142
|
-
signing_key:
|
179
|
+
rubygems_version: 3.1.4
|
180
|
+
signing_key:
|
143
181
|
specification_version: 4
|
144
182
|
summary: Lightweight Resource-Based Presence Solution with CableReady
|
145
183
|
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
|
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
|
data/lib/cubism/railtie.rb~
DELETED