cubism 0.1.1 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c3361767976fb4e04ccb86179a2d1ed2c6e2b55f75dbb53834e293c98d32b47
4
- data.tar.gz: 94635e8dc51fb3d63d83a014c6c7b5ccc1309611077018914d34701e2f1bb70e
3
+ metadata.gz: 2807897c46efb6dd8187d18c80c04bee84dfd0e50feeda467d5f735a0af9820e
4
+ data.tar.gz: 0440ddef045b5ce94cbe1928bcf662cf4726e5c206c8595c2c797aa8ad754463
5
5
  SHA512:
6
- metadata.gz: a4747a2c05eefd056a954f7f166ff7e7df11baaf3a4b9603ceef97644e88600ce02c20f99d70f6fb4919f944271d2d2f36461db55c3f3441395f03548137c959
7
- data.tar.gz: dcf467acad0433f66eca65a5bc00814e50a413afdf08ccf0c685208d9127c1e622bd1b8fad2845d0b58a92802c68639ffd0bbff9030c49044d453deef445f0f9
6
+ metadata.gz: bed13da912fad03ac48d8afccb340fbf5b7bf480bfac99e615a77c3fd24cbb47c19ab038a6bcb778323305f4831e20dc33342e0942e56a15ff558fcbf31e99fd
7
+ data.tar.gz: 1290222d3ac7aa0f693b49fe321252649c37b18a7fef3ca6489e8aad61da99d02a243151d234a8b9759dc9fa9b368b3391ef819236642dd54610f003bfb6672e
data/Gemfile.lock CHANGED
@@ -1,179 +1,226 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cubism (0.1.1)
4
+ cubism (0.2.1)
5
5
  cable_ready (>= 5.0.0)
6
6
  kredis (>= 0.4)
7
+ observer
7
8
  rails (>= 6.0)
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
- actioncable (7.0.8)
13
- actionpack (= 7.0.8)
14
- activesupport (= 7.0.8)
13
+ action_text-trix (2.1.16)
14
+ railties
15
+ actioncable (8.1.2)
16
+ actionpack (= 8.1.2)
17
+ activesupport (= 8.1.2)
15
18
  nio4r (~> 2.0)
16
19
  websocket-driver (>= 0.6.1)
17
- actionmailbox (7.0.8)
18
- actionpack (= 7.0.8)
19
- activejob (= 7.0.8)
20
- activerecord (= 7.0.8)
21
- activestorage (= 7.0.8)
22
- activesupport (= 7.0.8)
23
- mail (>= 2.7.1)
24
- net-imap
25
- net-pop
26
- net-smtp
27
- actionmailer (7.0.8)
28
- actionpack (= 7.0.8)
29
- actionview (= 7.0.8)
30
- activejob (= 7.0.8)
31
- activesupport (= 7.0.8)
32
- mail (~> 2.5, >= 2.5.4)
33
- net-imap
34
- net-pop
35
- net-smtp
36
- rails-dom-testing (~> 2.0)
37
- actionpack (7.0.8)
38
- actionview (= 7.0.8)
39
- activesupport (= 7.0.8)
40
- rack (~> 2.0, >= 2.2.4)
20
+ zeitwerk (~> 2.6)
21
+ actionmailbox (8.1.2)
22
+ actionpack (= 8.1.2)
23
+ activejob (= 8.1.2)
24
+ activerecord (= 8.1.2)
25
+ activestorage (= 8.1.2)
26
+ activesupport (= 8.1.2)
27
+ mail (>= 2.8.0)
28
+ actionmailer (8.1.2)
29
+ actionpack (= 8.1.2)
30
+ actionview (= 8.1.2)
31
+ activejob (= 8.1.2)
32
+ activesupport (= 8.1.2)
33
+ mail (>= 2.8.0)
34
+ rails-dom-testing (~> 2.2)
35
+ actionpack (8.1.2)
36
+ actionview (= 8.1.2)
37
+ activesupport (= 8.1.2)
38
+ nokogiri (>= 1.8.5)
39
+ rack (>= 2.2.4)
40
+ rack-session (>= 1.0.1)
41
41
  rack-test (>= 0.6.3)
42
- rails-dom-testing (~> 2.0)
43
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
44
- actiontext (7.0.8)
45
- actionpack (= 7.0.8)
46
- activerecord (= 7.0.8)
47
- activestorage (= 7.0.8)
48
- activesupport (= 7.0.8)
42
+ rails-dom-testing (~> 2.2)
43
+ rails-html-sanitizer (~> 1.6)
44
+ useragent (~> 0.16)
45
+ actiontext (8.1.2)
46
+ action_text-trix (~> 2.1.15)
47
+ actionpack (= 8.1.2)
48
+ activerecord (= 8.1.2)
49
+ activestorage (= 8.1.2)
50
+ activesupport (= 8.1.2)
49
51
  globalid (>= 0.6.0)
50
52
  nokogiri (>= 1.8.5)
51
- actionview (7.0.8)
52
- activesupport (= 7.0.8)
53
+ actionview (8.1.2)
54
+ activesupport (= 8.1.2)
53
55
  builder (~> 3.1)
54
- erubi (~> 1.4)
55
- rails-dom-testing (~> 2.0)
56
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
57
- activejob (7.0.8)
58
- activesupport (= 7.0.8)
56
+ erubi (~> 1.11)
57
+ rails-dom-testing (~> 2.2)
58
+ rails-html-sanitizer (~> 1.6)
59
+ activejob (8.1.2)
60
+ activesupport (= 8.1.2)
59
61
  globalid (>= 0.3.6)
60
- activemodel (7.0.8)
61
- activesupport (= 7.0.8)
62
- activerecord (7.0.8)
63
- activemodel (= 7.0.8)
64
- activesupport (= 7.0.8)
65
- activestorage (7.0.8)
66
- actionpack (= 7.0.8)
67
- activejob (= 7.0.8)
68
- activerecord (= 7.0.8)
69
- activesupport (= 7.0.8)
62
+ activemodel (8.1.2)
63
+ activesupport (= 8.1.2)
64
+ activerecord (8.1.2)
65
+ activemodel (= 8.1.2)
66
+ activesupport (= 8.1.2)
67
+ timeout (>= 0.4.0)
68
+ activestorage (8.1.2)
69
+ actionpack (= 8.1.2)
70
+ activejob (= 8.1.2)
71
+ activerecord (= 8.1.2)
72
+ activesupport (= 8.1.2)
70
73
  marcel (~> 1.0)
71
- mini_mime (>= 1.1.0)
72
- activesupport (7.0.8)
73
- concurrent-ruby (~> 1.0, >= 1.0.2)
74
+ activesupport (8.1.2)
75
+ base64
76
+ bigdecimal
77
+ concurrent-ruby (~> 1.0, >= 1.3.1)
78
+ connection_pool (>= 2.2.5)
79
+ drb
74
80
  i18n (>= 1.6, < 2)
81
+ json
82
+ logger (>= 1.4.2)
75
83
  minitest (>= 5.1)
76
- tzinfo (~> 2.0)
84
+ securerandom (>= 0.3)
85
+ tzinfo (~> 2.0, >= 2.0.5)
86
+ uri (>= 0.13.1)
77
87
  appraisal (2.4.1)
78
88
  bundler
79
89
  rake
80
90
  thor (>= 0.14.0)
81
91
  ast (2.4.2)
82
- builder (3.2.4)
83
- cable_ready (5.0.1)
92
+ base64 (0.3.0)
93
+ bigdecimal (4.0.1)
94
+ builder (3.3.0)
95
+ cable_ready (5.0.6)
84
96
  actionpack (>= 5.2)
85
97
  actionview (>= 5.2)
86
98
  activesupport (>= 5.2)
99
+ observer (~> 0.1)
87
100
  railties (>= 5.2)
88
101
  thread-local (>= 1.1.0)
89
102
  coderay (1.1.3)
90
- concurrent-ruby (1.2.2)
91
- connection_pool (2.4.1)
103
+ concurrent-ruby (1.3.6)
104
+ connection_pool (3.0.2)
92
105
  crass (1.0.6)
93
- date (3.3.3)
94
- erubi (1.12.0)
95
- globalid (1.2.1)
106
+ date (3.5.1)
107
+ drb (2.2.3)
108
+ erb (6.0.1)
109
+ erubi (1.13.1)
110
+ globalid (1.3.0)
96
111
  activesupport (>= 6.1)
97
- i18n (1.14.1)
112
+ i18n (1.14.8)
98
113
  concurrent-ruby (~> 1.0)
99
- kredis (1.5.0)
114
+ io-console (0.8.2)
115
+ irb (1.17.0)
116
+ pp (>= 0.6.0)
117
+ prism (>= 1.3.0)
118
+ rdoc (>= 4.0.0)
119
+ reline (>= 0.4.2)
120
+ json (2.18.1)
121
+ kredis (1.8.0)
100
122
  activemodel (>= 6.0.0)
101
123
  activesupport (>= 6.0.0)
102
124
  redis (>= 4.2, < 6)
103
- loofah (2.21.3)
125
+ logger (1.7.0)
126
+ loofah (2.25.0)
104
127
  crass (~> 1.0.2)
105
128
  nokogiri (>= 1.12.0)
106
- mail (2.8.1)
129
+ mail (2.9.0)
130
+ logger
107
131
  mini_mime (>= 0.1.1)
108
132
  net-imap
109
133
  net-pop
110
134
  net-smtp
111
- marcel (1.0.2)
135
+ marcel (1.1.0)
112
136
  method_source (1.0.0)
113
137
  mini_mime (1.1.5)
114
- mini_portile2 (2.8.1)
115
- minitest (5.20.0)
116
- mocha (1.13.0)
117
- net-imap (0.3.7)
138
+ mini_portile2 (2.8.9)
139
+ minitest (6.0.1)
140
+ prism (~> 1.5)
141
+ mocha (3.0.2)
142
+ ruby2_keywords (>= 0.0.5)
143
+ net-imap (0.6.3)
118
144
  date
119
145
  net-protocol
120
146
  net-pop (0.1.2)
121
147
  net-protocol
122
- net-protocol (0.2.1)
148
+ net-protocol (0.2.2)
123
149
  timeout
124
- net-smtp (0.4.0)
150
+ net-smtp (0.5.1)
125
151
  net-protocol
126
- nio4r (2.5.9)
127
- nokogiri (1.14.3)
128
- mini_portile2 (~> 2.8.0)
152
+ nio4r (2.7.5)
153
+ nokogiri (1.19.1)
154
+ mini_portile2 (~> 2.8.2)
129
155
  racc (~> 1.4)
130
- nokogiri (1.14.3-arm64-darwin)
156
+ nokogiri (1.19.1-arm64-darwin)
131
157
  racc (~> 1.4)
158
+ observer (0.1.2)
132
159
  parallel (1.21.0)
133
160
  parser (3.1.0.0)
134
161
  ast (~> 2.4.1)
162
+ pp (0.6.3)
163
+ prettyprint
164
+ prettyprint (0.2.0)
165
+ prism (1.9.0)
135
166
  pry (0.14.1)
136
167
  coderay (~> 1.1)
137
168
  method_source (~> 1.0)
138
- racc (1.6.2)
139
- rack (2.2.8)
140
- rack-test (2.1.0)
169
+ psych (5.3.1)
170
+ date
171
+ stringio
172
+ racc (1.8.1)
173
+ rack (3.2.5)
174
+ rack-session (2.1.1)
175
+ base64 (>= 0.1.0)
176
+ rack (>= 3.0.0)
177
+ rack-test (2.2.0)
141
178
  rack (>= 1.3)
142
- rails (7.0.8)
143
- actioncable (= 7.0.8)
144
- actionmailbox (= 7.0.8)
145
- actionmailer (= 7.0.8)
146
- actionpack (= 7.0.8)
147
- actiontext (= 7.0.8)
148
- actionview (= 7.0.8)
149
- activejob (= 7.0.8)
150
- activemodel (= 7.0.8)
151
- activerecord (= 7.0.8)
152
- activestorage (= 7.0.8)
153
- activesupport (= 7.0.8)
179
+ rackup (2.3.1)
180
+ rack (>= 3)
181
+ rails (8.1.2)
182
+ actioncable (= 8.1.2)
183
+ actionmailbox (= 8.1.2)
184
+ actionmailer (= 8.1.2)
185
+ actionpack (= 8.1.2)
186
+ actiontext (= 8.1.2)
187
+ actionview (= 8.1.2)
188
+ activejob (= 8.1.2)
189
+ activemodel (= 8.1.2)
190
+ activerecord (= 8.1.2)
191
+ activestorage (= 8.1.2)
192
+ activesupport (= 8.1.2)
154
193
  bundler (>= 1.15.0)
155
- railties (= 7.0.8)
156
- rails-dom-testing (2.2.0)
194
+ railties (= 8.1.2)
195
+ rails-dom-testing (2.3.0)
157
196
  activesupport (>= 5.0.0)
158
197
  minitest
159
198
  nokogiri (>= 1.6)
160
- rails-html-sanitizer (1.6.0)
199
+ rails-html-sanitizer (1.6.2)
161
200
  loofah (~> 2.21)
162
- nokogiri (~> 1.14)
163
- railties (7.0.8)
164
- actionpack (= 7.0.8)
165
- activesupport (= 7.0.8)
166
- method_source
201
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
202
+ railties (8.1.2)
203
+ actionpack (= 8.1.2)
204
+ activesupport (= 8.1.2)
205
+ irb (~> 1.13)
206
+ rackup (>= 1.0.0)
167
207
  rake (>= 12.2)
168
- thor (~> 1.0)
169
- zeitwerk (~> 2.5)
208
+ thor (~> 1.0, >= 1.2.2)
209
+ tsort (>= 0.2)
210
+ zeitwerk (~> 2.6)
170
211
  rainbow (3.0.0)
171
- rake (13.0.6)
172
- redis (5.0.7)
173
- redis-client (>= 0.9.0)
174
- redis-client (0.17.0)
212
+ rake (13.3.1)
213
+ rdoc (7.2.0)
214
+ erb
215
+ psych (>= 4.0.0)
216
+ tsort
217
+ redis (5.4.1)
218
+ redis-client (>= 0.22.0)
219
+ redis-client (0.26.4)
175
220
  connection_pool
176
221
  regexp_parser (2.2.0)
222
+ reline (0.6.3)
223
+ io-console (~> 0.5)
177
224
  rexml (3.2.5)
178
225
  rubocop (1.23.0)
179
226
  parallel (~> 1.10)
@@ -190,20 +237,29 @@ GEM
190
237
  rubocop (>= 1.7.0, < 2.0)
191
238
  rubocop-ast (>= 0.4.0)
192
239
  ruby-progressbar (1.11.0)
193
- sqlite3 (1.4.2)
240
+ ruby2_keywords (0.0.5)
241
+ securerandom (0.4.1)
242
+ sqlite3 (2.9.0)
243
+ mini_portile2 (~> 2.8.0)
244
+ sqlite3 (2.9.0-arm64-darwin)
194
245
  standard (1.5.0)
195
246
  rubocop (= 1.23.0)
196
247
  rubocop-performance (= 1.12.0)
197
- thor (1.2.1)
248
+ stringio (3.2.0)
249
+ thor (1.5.0)
198
250
  thread-local (1.1.0)
199
- timeout (0.4.0)
251
+ timeout (0.6.0)
252
+ tsort (0.2.0)
200
253
  tzinfo (2.0.6)
201
254
  concurrent-ruby (~> 1.0)
202
255
  unicode-display_width (2.1.0)
203
- websocket-driver (0.7.6)
256
+ uri (1.1.1)
257
+ useragent (0.16.11)
258
+ websocket-driver (0.8.0)
259
+ base64
204
260
  websocket-extensions (>= 0.1.0)
205
261
  websocket-extensions (0.1.5)
206
- zeitwerk (2.6.11)
262
+ zeitwerk (2.7.5)
207
263
 
208
264
  PLATFORMS
209
265
  arm64-darwin-21
@@ -215,7 +271,7 @@ DEPENDENCIES
215
271
  mocha
216
272
  nokogiri
217
273
  pry
218
- sqlite3
274
+ sqlite3 (>= 2.1)
219
275
  standard
220
276
 
221
277
  BUNDLED WITH
data/README.md CHANGED
@@ -125,6 +125,15 @@ The `cubicle_for` helper accepts the following options as keyword arguments:
125
125
  ### Supported Template Handlers
126
126
  - ERB
127
127
 
128
+ ## Testing
129
+ In Rails system tests there is a chance that tests will hang in some cases. To overcome this, add the flag
130
+
131
+ ```ruby
132
+ Cubism.skip_in_test = true
133
+ ```
134
+
135
+ to an initializer, for example `config/initializers/cubism.rb`.
136
+
128
137
  ## Gotchas
129
138
 
130
139
  ### Usage with ViewComponent
data/README.md~ CHANGED
@@ -71,10 +71,27 @@ And then execute:
71
71
  $ bundle
72
72
  ```
73
73
 
74
- After `bundle`, install the Javascript library:
74
+ There are a few ways to install the Cubism JavaScript client, depending on your application setup.
75
75
 
76
- ```bash
77
- $ bin/yarn add @minthesize/cubism
76
+ #### ESBuild / Webpacker
77
+
78
+ ```sh
79
+ yarn add @minthesize/cubism
80
+ ```
81
+
82
+ #### Import maps:
83
+
84
+ ```ruby
85
+ # config/importmap.rb
86
+ # ...
87
+ pin '@minthesize/cubism', to: 'cubism.min.js', preload: true
88
+ ```
89
+
90
+ #### Rails Asset pipeline (Sprockets):
91
+
92
+ ```html+erb
93
+ <!-- app/views/layouts/application.html.erb -->
94
+ <%= javascript_include_tag "cubism.umd.min.js", "data-turbo-track": "reload" %>
78
95
  ```
79
96
 
80
97
  ### Kredis
@@ -146,7 +163,7 @@ yarn link # set the local machine's cubism npm package's lookup to this local pa
146
163
 
147
164
  # Setup a sample project and edit Gemfile to point to local gem
148
165
  # (e.g. `gem "cubism", path: "../cubism"`)
149
- # yarn link @stimulus_reflex/cubism
166
+ # yarn link @minthesize/cubism
150
167
 
151
168
 
152
169
  # Do your work, Submit PR, Profit!
@@ -163,14 +180,17 @@ cd path/to/project
163
180
  yarn install --force
164
181
  ```
165
182
 
166
- ### Release
167
-
168
- 1. Update the version numbers in `javascript/package.json` and `lib/cubism/version.rb`
169
- 2. `git commit -m "Bump version to x.x.x"`
170
- 3. Run `bundle exec rake build`
171
- 4. Run `bundle exec rake release`
172
- 5. Run `npm publish --access public`
173
-
183
+ ### 📦 Releasing
184
+
185
+ 1. Make sure that you run `yarn` and `bundle` to pick up the latest.
186
+ 2. Bump version number at `lib/cubism/version.rb`. Pre-release versions use `.preN`
187
+ 3. Run `rake build` and `yarn build`
188
+ 4. Commit and push changes to github `git commit -m "Bump version to x.x.x"`
189
+ 5. Run `rake release`
190
+ 6. Run `yarn publish --no-git-tag-version`
191
+ 7. Yarn will prompt you for the new version. Pre-release versions use `-preN`
192
+ 8. Commit and push changes to GitHub
193
+ 9. Create a new release on GitHub ([here](https://github.com/julianrubisch/cubism/releases)) and generate the changelog for the stable release for it
174
194
  ## License
175
195
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
176
196
 
data/Rakefile CHANGED
@@ -3,8 +3,6 @@ require "bundler/setup"
3
3
  APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
4
  load "rails/tasks/engine.rake"
5
5
 
6
- load "rails/tasks/statistics.rake"
7
-
8
6
  require "bundler/gem_tasks"
9
7
 
10
8
  require "rake/testtask"
@@ -2,6 +2,8 @@ class Cubism::PresenceChannel < ActionCable::Channel::Base
2
2
  include CableReady::StreamIdentifier
3
3
 
4
4
  def subscribed
5
+ return if Cubism.skip_in_test? && Rails.env.test?
6
+
5
7
  if resource.present?
6
8
  stream_from element_id
7
9
  resource.cubicle_element_ids << element_id
@@ -12,6 +14,8 @@ class Cubism::PresenceChannel < ActionCable::Channel::Base
12
14
  end
13
15
 
14
16
  def unsubscribed
17
+ return if Cubism.skip_in_test? && Rails.env.test?
18
+
15
19
  return unless resource.present?
16
20
 
17
21
  resource.cubicle_element_ids.remove(element_id)
@@ -21,10 +25,14 @@ class Cubism::PresenceChannel < ActionCable::Channel::Base
21
25
 
22
26
  def appear
23
27
  resource.set_present_users_for_scope(resource.present_users_for_scope(scope).add(user.id), scope) if scope
28
+ rescue ActiveRecord::RecordNotFound
29
+ # do nothing if the user wasn't found
24
30
  end
25
31
 
26
32
  def disappear
27
33
  resource.set_present_users_for_scope(resource.present_users_for_scope(scope).delete(user.id), scope) if scope
34
+ rescue ActiveRecord::RecordNotFound
35
+ # do nothing if the user wasn't found
28
36
  end
29
37
 
30
38
  private
@@ -2,11 +2,20 @@ module CubismHelper
2
2
  include CableReady::StreamIdentifier
3
3
 
4
4
  def cubicle_for(resource, user, scope: "", html_options: {}, appear_trigger: :connect, disappear_trigger: nil, trigger_root: nil, exclude_current_user: true, &block)
5
+ return if Cubism.skip_in_test? && Rails.env.test?
6
+
5
7
  block_location = block.source_location.join(":")
6
8
  block_source = Cubism::BlockSource.find_or_create(
7
9
  location: block_location,
8
10
  view_context: self
9
11
  )
12
+ if block_source.variable_name.blank?
13
+ block_variable_name = block.parameters.find { |type, _| [:req, :opt, :rest].include?(type) }&.last
14
+ if block_variable_name.present?
15
+ block_source.variable_name = block_variable_name.to_s
16
+ Cubism.source_store[block_source.digest] = block_source
17
+ end
18
+ end
10
19
 
11
20
  resource_gid = resource.to_gid.to_s
12
21
 
data/cubism.gemspec CHANGED
@@ -27,10 +27,11 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency "rails", ">= 6.0"
28
28
  spec.add_dependency "kredis", ">= 0.4"
29
29
  spec.add_dependency "cable_ready", ">= 5.0.0"
30
+ spec.add_dependency "observer"
30
31
 
31
32
  spec.add_development_dependency "standard"
32
33
  spec.add_development_dependency "nokogiri"
33
34
  spec.add_development_dependency "mocha"
34
35
  spec.add_development_dependency "appraisal"
35
- spec.add_development_dependency "sqlite3"
36
+ spec.add_development_dependency "sqlite3", ">= 2.1"
36
37
  end
data/cubism.gemspec~ CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_dependency "rails", ">= 6.0"
28
28
  spec.add_dependency "kredis", ">= 0.4"
29
- spec.add_dependency "cable_ready", "= 5.0.0.rc2"
29
+ spec.add_dependency "cable_ready", ">= 5.0.0"
30
30
 
31
31
  spec.add_development_dependency "standard"
32
32
  spec.add_development_dependency "nokogiri"
@@ -21,7 +21,9 @@ module Cubism
21
21
 
22
22
  block_source = block_container.block_source
23
23
 
24
- html = ApplicationController.render(inline: block_source.source, locals: {"#{block_source.variable_name}": present_users})
24
+ inline_source = block_source.source
25
+ inline_source = inline_source.dup if inline_source.frozen?
26
+ html = ApplicationController.render(inline: inline_source, locals: {"#{block_source.variable_name}": present_users})
25
27
 
26
28
  selector = "cubicle-element#cubicle-#{element_id}[identifier='#{signed_stream_identifier(resource.to_global_id.to_s)}']"
27
29
 
@@ -14,6 +14,7 @@ module Cubism
14
14
  begin
15
15
  do_parse
16
16
  rescue NameError
17
+ # TODO we need a better way to handle this, leads to false negatives
17
18
  # we ignore any name errors from unset instance variables or local assigns here
18
19
  end
19
20
 
@@ -23,11 +24,21 @@ module Cubism
23
24
  private
24
25
 
25
26
  def do_parse
26
- ActionView::Template::Handlers::ERB::Erubi.new(@source).evaluate(@view_context)
27
+ erubi = ActionView::Template::Handlers::ERB::Erubi.new(@source)
28
+
29
+ evaluate_view(erubi, @view_context)
27
30
  rescue SyntaxError
28
31
  end_at_end = /(<%\s+end\s+%>)\z/.match(@source)
29
32
  @source = end_at_end ? @source[..-(end_at_end[0].length + 1)] : @source[..-2]
30
33
  do_parse
31
34
  end
35
+
36
+ def evaluate_view(erubi, view_context)
37
+ view = Class.new(ActionView::Base) {
38
+ include view_context._routes.url_helpers
39
+ class_eval("define_method(:_template) { |local_assigns, output_buffer| #{erubi.src} }", erubi.filename.nil? ? "(erubi)" : erubi.filename, 0)
40
+ }.empty
41
+ view._run(:_template, nil, {}, ActionView::OutputBuffer.new)
42
+ end
32
43
  end
33
44
  end
@@ -1,3 +1,3 @@
1
1
  module Cubism
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/cubism.rb CHANGED
@@ -16,4 +16,10 @@ module Cubism
16
16
 
17
17
  mattr_accessor :block_store, instance_reader: false
18
18
  mattr_accessor :source_store, instance_reader: false
19
+
20
+ mattr_accessor :skip_in_test, default: false
21
+
22
+ def self.skip_in_test?
23
+ skip_in_test.present?
24
+ end
19
25
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minthesize/cubism",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Lightweight Resource-Based Presence Solution with CableReady.",
5
5
  "main": "./dist/cubism.umd.min.js",
6
6
  "module": "./dist/cubism.min.js",
data/test/test_helper.rb CHANGED
@@ -4,13 +4,19 @@ ENV["RAILS_ENV"] = "test"
4
4
  require_relative "../test/dummy/config/environment"
5
5
  ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)]
6
6
  require "rails/test_help"
7
- require "minitest/unit"
8
7
  require "mocha/minitest"
9
8
 
10
9
  # Load fixtures from the engine
11
- if ActiveSupport::TestCase.respond_to?(:fixture_path=)
12
- ActiveSupport::TestCase.fixture_path = File.expand_path("dummy/test/fixtures", __dir__)
13
- ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
14
- ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files"
10
+ fixtures_path = File.expand_path("dummy/test/fixtures", __dir__)
11
+
12
+ if ActiveSupport::TestCase.respond_to?(:fixture_paths=)
13
+ ActiveSupport::TestCase.fixture_paths = [fixtures_path]
14
+ ActionDispatch::IntegrationTest.fixture_paths = ActiveSupport::TestCase.fixture_paths if ActionDispatch::IntegrationTest.respond_to?(:fixture_paths=)
15
+ ActiveSupport::TestCase.file_fixture_path = "#{fixtures_path}/files"
16
+ ActiveSupport::TestCase.fixtures :all
17
+ elsif ActiveSupport::TestCase.respond_to?(:fixture_path=)
18
+ ActiveSupport::TestCase.fixture_path = fixtures_path
19
+ ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path if ActionDispatch::IntegrationTest.respond_to?(:fixture_path=)
20
+ ActiveSupport::TestCase.file_fixture_path = "#{fixtures_path}/files"
15
21
  ActiveSupport::TestCase.fixtures :all
16
22
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cubism
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Rubisch
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-09-25 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rails
@@ -52,6 +51,20 @@ dependencies:
52
51
  - - ">="
53
52
  - !ruby/object:Gem::Version
54
53
  version: 5.0.0
54
+ - !ruby/object:Gem::Dependency
55
+ name: observer
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
55
68
  - !ruby/object:Gem::Dependency
56
69
  name: standard
57
70
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +127,14 @@ dependencies:
114
127
  requirements:
115
128
  - - ">="
116
129
  - !ruby/object:Gem::Version
117
- version: '0'
130
+ version: '2.1'
118
131
  type: :development
119
132
  prerelease: false
120
133
  version_requirements: !ruby/object:Gem::Requirement
121
134
  requirements:
122
135
  - - ">="
123
136
  - !ruby/object:Gem::Version
124
- version: '0'
137
+ version: '2.1'
125
138
  description: Lightweight Resource-Based Presence Solution with CableReady
126
139
  email:
127
140
  - julian@julianrubisch.at
@@ -217,7 +230,6 @@ licenses:
217
230
  metadata:
218
231
  homepage_uri: https://github.com/julianrubisch/cubism
219
232
  source_code_uri: https://github.com/julianrubisch/cubism.git
220
- post_install_message:
221
233
  rdoc_options: []
222
234
  require_paths:
223
235
  - lib
@@ -232,52 +244,51 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
244
  - !ruby/object:Gem::Version
233
245
  version: '0'
234
246
  requirements: []
235
- rubygems_version: 3.1.4
236
- signing_key:
247
+ rubygems_version: 3.6.7
237
248
  specification_version: 4
238
249
  summary: Lightweight Resource-Based Presence Solution with CableReady
239
250
  test_files:
251
+ - test/block_container_test.rb
252
+ - test/block_source_test.rb
253
+ - test/broadcaster_test.rb
254
+ - test/channels/cubism/presence_channel_test.rb
255
+ - test/cubicle_store_test.rb
256
+ - test/cubism_test.rb
257
+ - test/dummy/app/channels/application_cable/channel.rb
258
+ - test/dummy/app/channels/application_cable/connection.rb
259
+ - test/dummy/app/controllers/application_controller.rb
260
+ - test/dummy/app/helpers/application_helper.rb
261
+ - test/dummy/app/jobs/application_job.rb
240
262
  - test/dummy/app/mailers/application_mailer.rb
241
263
  - test/dummy/app/models/application_record.rb
242
264
  - test/dummy/app/models/post.rb
243
265
  - test/dummy/app/models/user.rb
244
- - test/dummy/app/jobs/application_job.rb
245
- - test/dummy/app/controllers/application_controller.rb
246
- - test/dummy/app/helpers/application_helper.rb
247
- - test/dummy/app/channels/application_cable/connection.rb
248
- - test/dummy/app/channels/application_cable/channel.rb
249
- - test/dummy/test/models/post_test.rb
250
- - test/dummy/test/models/user_test.rb
251
- - test/dummy/config/routes.rb
252
- - test/dummy/config/environments/production.rb
253
- - test/dummy/config/environments/development.rb
254
- - test/dummy/config/environments/test.rb
255
- - test/dummy/config/environment.rb
256
266
  - test/dummy/config/application.rb
257
- - test/dummy/config/puma.rb
258
267
  - test/dummy/config/boot.rb
268
+ - test/dummy/config/environment.rb
269
+ - test/dummy/config/environments/development.rb
270
+ - test/dummy/config/environments/production.rb
271
+ - test/dummy/config/environments/test.rb
259
272
  - test/dummy/config/initializers/application_controller_renderer.rb
260
- - test/dummy/config/initializers/backtrace_silencers.rb
261
- - test/dummy/config/initializers/mime_types.rb
262
- - test/dummy/config/initializers/filter_parameter_logging.rb
263
- - test/dummy/config/initializers/wrap_parameters.rb
264
273
  - test/dummy/config/initializers/assets.rb
265
- - test/dummy/config/initializers/cookies_serializer.rb
266
- - test/dummy/config/initializers/permissions_policy.rb
274
+ - test/dummy/config/initializers/backtrace_silencers.rb
267
275
  - test/dummy/config/initializers/content_security_policy.rb
276
+ - test/dummy/config/initializers/cookies_serializer.rb
277
+ - test/dummy/config/initializers/filter_parameter_logging.rb
268
278
  - test/dummy/config/initializers/inflections.rb
269
- - test/dummy/db/schema.rb
279
+ - test/dummy/config/initializers/mime_types.rb
280
+ - test/dummy/config/initializers/permissions_policy.rb
281
+ - test/dummy/config/initializers/wrap_parameters.rb
282
+ - test/dummy/config/puma.rb
283
+ - test/dummy/config/routes.rb
270
284
  - test/dummy/db/migrate/20220102072929_create_posts.rb
271
285
  - test/dummy/db/migrate/20220102073003_create_users.rb
286
+ - test/dummy/db/schema.rb
287
+ - test/dummy/test/models/post_test.rb
288
+ - test/dummy/test/models/user_test.rb
289
+ - test/helpers/cubism_helper_test.rb
272
290
  - test/integration/navigation_test.rb
273
- - test/broadcaster_test.rb
274
- - test/cubicle_store_test.rb
275
291
  - test/models/concerns/presence_test.rb
276
292
  - test/models/concerns/user_test.rb
277
- - test/block_container_test.rb
278
- - test/cubism_test.rb
279
293
  - test/rendering/preprocessor_test.rb
280
294
  - test/test_helper.rb
281
- - test/helpers/cubism_helper_test.rb
282
- - test/block_source_test.rb
283
- - test/channels/cubism/presence_channel_test.rb