cubism 0.1.0.pre10 → 0.1.0.pre13

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.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/Appraisals +16 -0
  3. data/Appraisals~ +16 -0
  4. data/CHANGELOG.md +87 -0
  5. data/Gemfile +7 -0
  6. data/Gemfile.lock +220 -0
  7. data/Gemfile~ +9 -0
  8. data/README.md +35 -14
  9. data/README.md~ +191 -0
  10. data/app/assets/javascripts/cubism.js +141 -0
  11. data/app/assets/javascripts/cubism.min.js +2 -0
  12. data/app/assets/javascripts/cubism.min.js.map +1 -0
  13. data/app/assets/javascripts/cubism.umd.js +149 -0
  14. data/app/assets/javascripts/cubism.umd.min.js +2 -0
  15. data/app/assets/javascripts/cubism.umd.min.js.map +1 -0
  16. data/app/channels/cubism/presence_channel.rb +14 -5
  17. data/app/helpers/cubism_helper.rb +15 -17
  18. data/app/models/concerns/cubism/presence.rb +11 -3
  19. data/bin/rails +14 -0
  20. data/bin/standardize +4 -0
  21. data/bin/test +5 -0
  22. data/cubism.gemspec +36 -0
  23. data/cubism.gemspec~ +28 -0
  24. data/lib/cubism/broadcaster.rb +13 -6
  25. data/lib/cubism/cubicle_store.rb +141 -0
  26. data/lib/cubism/engine.rb +23 -2
  27. data/lib/cubism/importmap.rb +2 -0
  28. data/lib/cubism/preprocessor.rb +4 -1
  29. data/lib/cubism/version.rb +1 -1
  30. data/lib/cubism.rb +3 -2
  31. data/package.json +43 -0
  32. data/package.json~ +33 -0
  33. data/rollup.config.js +77 -0
  34. data/{lib/cubism/parser.rb~ → rollup.config.js~} +0 -0
  35. data/test/block_container_test.rb +105 -0
  36. data/test/block_source_test.rb +102 -0
  37. data/test/broadcaster_test.rb +66 -0
  38. data/test/channels/cubism/presence_channel_test.rb +72 -0
  39. data/test/cubicle_store_test.rb +34 -0
  40. data/test/cubism_test.rb +7 -0
  41. data/test/dummy/app/channels/application_cable/channel.rb +4 -0
  42. data/test/dummy/app/channels/application_cable/connection.rb +4 -0
  43. data/test/dummy/app/controllers/application_controller.rb +2 -0
  44. data/test/dummy/app/helpers/application_helper.rb +2 -0
  45. data/test/dummy/app/jobs/application_job.rb +7 -0
  46. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  47. data/test/dummy/app/models/application_record.rb +3 -0
  48. data/test/dummy/app/models/post.rb +3 -0
  49. data/test/dummy/app/models/user.rb +3 -0
  50. data/test/dummy/config/application.rb +22 -0
  51. data/test/dummy/config/boot.rb +5 -0
  52. data/test/dummy/config/environment.rb +5 -0
  53. data/test/dummy/config/environments/development.rb +76 -0
  54. data/test/dummy/config/environments/production.rb +120 -0
  55. data/test/dummy/config/environments/test.rb +59 -0
  56. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  57. data/test/dummy/config/initializers/assets.rb +12 -0
  58. data/test/dummy/config/initializers/backtrace_silencers.rb +8 -0
  59. data/test/dummy/config/initializers/content_security_policy.rb +28 -0
  60. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  61. data/test/dummy/config/initializers/filter_parameter_logging.rb +6 -0
  62. data/test/dummy/config/initializers/inflections.rb +16 -0
  63. data/test/dummy/config/initializers/mime_types.rb +4 -0
  64. data/test/dummy/config/initializers/permissions_policy.rb +11 -0
  65. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  66. data/test/dummy/config/puma.rb +43 -0
  67. data/test/dummy/config/routes.rb +3 -0
  68. data/test/dummy/db/migrate/20220102072929_create_posts.rb +10 -0
  69. data/test/dummy/db/migrate/20220102073003_create_users.rb +9 -0
  70. data/test/dummy/db/schema.rb +26 -0
  71. data/test/dummy/test/models/post_test.rb +7 -0
  72. data/test/dummy/test/models/user_test.rb +7 -0
  73. data/test/helpers/cubism_helper_test.rb +39 -0
  74. data/test/integration/navigation_test.rb +7 -0
  75. data/test/models/concerns/presence_test.rb +25 -0
  76. data/test/models/concerns/user_test.rb +9 -0
  77. data/test/rendering/preprocessor_test.rb +61 -0
  78. data/test/test_helper.rb +16 -0
  79. data/yarn.lock +2814 -0
  80. metadata +118 -18
  81. data/app/channels/cubism/presence_channel.rb~ +0 -52
  82. data/app/helpers/cubism_helper.rb~ +0 -34
  83. data/app/models/concerns/cubism/presence.rb~ +0 -13
  84. data/config/routes.rb +0 -2
  85. data/lib/cubism/broadcaster.rb~ +0 -50
  86. data/lib/cubism/cubicle_block_store.rb +0 -56
  87. data/lib/cubism/cubicle_block_store.rb~ +0 -43
  88. data/lib/cubism/engine.rb~ +0 -4
  89. data/lib/cubism/preprocessor.rb~ +0 -26
  90. data/lib/cubism/version.rb~ +0 -3
  91. data/lib/cubism.rb~ +0 -18
  92. data/lib/tasks/cubism_tasks.rake +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 976cb8cfb5c2fe6edb6dd6e541c74361ae17dd12ce717bafadcb6ff6bdd1b9f1
4
- data.tar.gz: a3e777efd1df0423ab4754ed30fe119b6497197ec2bc8ee564304385b907849d
3
+ metadata.gz: 4377fa1fd3645236a271528fa11475f4d13ab813c33bb7a4b1378581ca19f116
4
+ data.tar.gz: bb12db749b157287aa6898c234067b64bb30978ec221a67b64ea0c6f9db9c411
5
5
  SHA512:
6
- metadata.gz: 163db944110832cefb97406ebc7c4c98b231fdf98d9cce25abe164469eb64d9930d5aa1689c53426605dd11e42cbb721e314430a7b1ec1b7acc37449a676f702
7
- data.tar.gz: b1c4052e437c7ebe723615e4b3316f1ac5d538aa2008b87957aca8762cd04bf61aed0f930aac42256aa07340d1c05652611fdcd47cad2f4b2e9d870393999e18
6
+ metadata.gz: 6feee965fa20725ec7018af0371294707390d2649f554486fd8e91d9ee087cfb7a44e82ca653a660fb7fdb14e3a517aba3929ab11790686e54e89de00c92a67c
7
+ data.tar.gz: 7cc6318fb9cc6cdad4c1ce42d6a898b6819cc5184e11e3a0ed782976fcd33cacd9692c5e08ca64e7f7e25454065dba002be4d1a1118af1cfe47c6246df939d02
data/Appraisals ADDED
@@ -0,0 +1,16 @@
1
+ if RUBY_VERSION >= "2.7"
2
+ appraise "rails-7-0" do
3
+ gem "rails", "7.0.1"
4
+ gem "sqlite3", "~> 1.4"
5
+ end
6
+ end
7
+
8
+ appraise "rails-6-1" do
9
+ gem "rails", "~> 6.1"
10
+ gem "sqlite3", "~> 1.4"
11
+ end
12
+
13
+ appraise "rails-6-0" do
14
+ gem "rails", "~> 6.0"
15
+ gem "sqlite3", "~> 1.4"
16
+ end
data/Appraisals~ ADDED
@@ -0,0 +1,16 @@
1
+ if RUBY_VERSION >= "2.7"
2
+ appraise "rails-7-0" do
3
+ gem "rails", "7.0.0"
4
+ gem "sqlite3", "~> 1.4"
5
+ end
6
+ end
7
+
8
+ appraise "rails-6-1" do
9
+ gem "rails", "~> 6.1"
10
+ gem "sqlite3", "~> 1.4"
11
+ end
12
+
13
+ appraise "rails-6-0" do
14
+ gem "rails", "~> 6.0"
15
+ gem "sqlite3", "~> 1.4"
16
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,87 @@
1
+ # Changelog
2
+
3
+ ## [v0.1.0.pre12](https://github.com/julianrubisch/cubism/tree/v0.1.0.pre12) (2022-03-01)
4
+
5
+ [Full Changelog](https://github.com/julianrubisch/cubism/compare/v0.1.0.pre11...v0.1.0.pre12)
6
+
7
+ **Closed issues:**
8
+
9
+ - Scope leads to element not found errors [\#12](https://github.com/julianrubisch/cubism/issues/12)
10
+ - Add IntersectionObserver as appear trigger [\#9](https://github.com/julianrubisch/cubism/issues/9)
11
+
12
+ **Merged pull requests:**
13
+
14
+ - Intersect appear trigger [\#14](https://github.com/julianrubisch/cubism/pull/14) ([julianrubisch](https://github.com/julianrubisch))
15
+ - Fix scoping [\#13](https://github.com/julianrubisch/cubism/pull/13) ([julianrubisch](https://github.com/julianrubisch))
16
+ - Scope elements [\#11](https://github.com/julianrubisch/cubism/pull/11) ([julianrubisch](https://github.com/julianrubisch))
17
+
18
+ ## [v0.1.0.pre11](https://github.com/julianrubisch/cubism/tree/v0.1.0.pre11) (2022-02-16)
19
+
20
+ [Full Changelog](https://github.com/julianrubisch/cubism/compare/v0.1.0.pre10...v0.1.0.pre11)
21
+
22
+ **Closed issues:**
23
+
24
+ - Async DOM mutations [\#7](https://github.com/julianrubisch/cubism/issues/7)
25
+
26
+ **Merged pull requests:**
27
+
28
+ - Async dom mutations [\#10](https://github.com/julianrubisch/cubism/pull/10) ([julianrubisch](https://github.com/julianrubisch))
29
+ - Reuse block source [\#8](https://github.com/julianrubisch/cubism/pull/8) ([julianrubisch](https://github.com/julianrubisch))
30
+
31
+ ## [v0.1.0.pre10](https://github.com/julianrubisch/cubism/tree/v0.1.0.pre10) (2022-01-24)
32
+
33
+ [Full Changelog](https://github.com/julianrubisch/cubism/compare/v0.1.0.pre9...v0.1.0.pre10)
34
+
35
+ **Merged pull requests:**
36
+
37
+ - Multi worker setup [\#6](https://github.com/julianrubisch/cubism/pull/6) ([julianrubisch](https://github.com/julianrubisch))
38
+ - Add value proposition to README [\#5](https://github.com/julianrubisch/cubism/pull/5) ([fractaledmind](https://github.com/fractaledmind))
39
+
40
+ ## [v0.1.0.pre9](https://github.com/julianrubisch/cubism/tree/v0.1.0.pre9) (2022-01-09)
41
+
42
+ [Full Changelog](https://github.com/julianrubisch/cubism/compare/v0.1.0.pre8...v0.1.0.pre9)
43
+
44
+ ## [v0.1.0.pre8](https://github.com/julianrubisch/cubism/tree/v0.1.0.pre8) (2021-12-22)
45
+
46
+ [Full Changelog](https://github.com/julianrubisch/cubism/compare/v0.1.0.pre7...v0.1.0.pre8)
47
+
48
+ ## [v0.1.0.pre7](https://github.com/julianrubisch/cubism/tree/v0.1.0.pre7) (2021-12-22)
49
+
50
+ [Full Changelog](https://github.com/julianrubisch/cubism/compare/v0.1.0.pre6...v0.1.0.pre7)
51
+
52
+ ## [v0.1.0.pre6](https://github.com/julianrubisch/cubism/tree/v0.1.0.pre6) (2021-12-20)
53
+
54
+ [Full Changelog](https://github.com/julianrubisch/cubism/compare/v0.1.0.pre5...v0.1.0.pre6)
55
+
56
+ **Closed issues:**
57
+
58
+ - Register a channel for every identifier instead of filtering operations on the client [\#4](https://github.com/julianrubisch/cubism/issues/4)
59
+
60
+ ## [v0.1.0.pre5](https://github.com/julianrubisch/cubism/tree/v0.1.0.pre5) (2021-12-16)
61
+
62
+ [Full Changelog](https://github.com/julianrubisch/cubism/compare/v0.1.0.pre4...v0.1.0.pre5)
63
+
64
+ ## [v0.1.0.pre4](https://github.com/julianrubisch/cubism/tree/v0.1.0.pre4) (2021-12-15)
65
+
66
+ [Full Changelog](https://github.com/julianrubisch/cubism/compare/v0.1.0.pre3...v0.1.0.pre4)
67
+
68
+ **Merged pull requests:**
69
+
70
+ - docs: add julianrubisch as a contributor for code [\#3](https://github.com/julianrubisch/cubism/pull/3) ([allcontributors[bot]](https://github.com/apps/allcontributors))
71
+ - Block store [\#2](https://github.com/julianrubisch/cubism/pull/2) ([julianrubisch](https://github.com/julianrubisch))
72
+
73
+ ## [v0.1.0.pre3](https://github.com/julianrubisch/cubism/tree/v0.1.0.pre3) (2021-10-15)
74
+
75
+ [Full Changelog](https://github.com/julianrubisch/cubism/compare/v0.1.0.pre2...v0.1.0.pre3)
76
+
77
+ ## [v0.1.0.pre2](https://github.com/julianrubisch/cubism/tree/v0.1.0.pre2) (2021-10-15)
78
+
79
+ [Full Changelog](https://github.com/julianrubisch/cubism/compare/v0.1.0.pre1...v0.1.0.pre2)
80
+
81
+ ## [v0.1.0.pre1](https://github.com/julianrubisch/cubism/tree/v0.1.0.pre1) (2021-10-14)
82
+
83
+ [Full Changelog](https://github.com/julianrubisch/cubism/compare/8904f2c6d1eb5afe35e52bf773cbc9225d086e02...v0.1.0.pre1)
84
+
85
+
86
+
87
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ # Specify your gem's dependencies in cubism.gemspec.
5
+ gemspec
6
+
7
+ gem "pry", group: [:development, :test]
data/Gemfile.lock ADDED
@@ -0,0 +1,220 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cubism (0.1.0.pre13)
5
+ cable_ready (= 5.0.0.pre9)
6
+ kredis (>= 0.4)
7
+ rails (>= 6.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actioncable (7.0.2.3)
13
+ actionpack (= 7.0.2.3)
14
+ activesupport (= 7.0.2.3)
15
+ nio4r (~> 2.0)
16
+ websocket-driver (>= 0.6.1)
17
+ actionmailbox (7.0.2.3)
18
+ actionpack (= 7.0.2.3)
19
+ activejob (= 7.0.2.3)
20
+ activerecord (= 7.0.2.3)
21
+ activestorage (= 7.0.2.3)
22
+ activesupport (= 7.0.2.3)
23
+ mail (>= 2.7.1)
24
+ net-imap
25
+ net-pop
26
+ net-smtp
27
+ actionmailer (7.0.2.3)
28
+ actionpack (= 7.0.2.3)
29
+ actionview (= 7.0.2.3)
30
+ activejob (= 7.0.2.3)
31
+ activesupport (= 7.0.2.3)
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.2.3)
38
+ actionview (= 7.0.2.3)
39
+ activesupport (= 7.0.2.3)
40
+ rack (~> 2.0, >= 2.2.0)
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.2.3)
45
+ actionpack (= 7.0.2.3)
46
+ activerecord (= 7.0.2.3)
47
+ activestorage (= 7.0.2.3)
48
+ activesupport (= 7.0.2.3)
49
+ globalid (>= 0.6.0)
50
+ nokogiri (>= 1.8.5)
51
+ actionview (7.0.2.3)
52
+ activesupport (= 7.0.2.3)
53
+ 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.2.3)
58
+ activesupport (= 7.0.2.3)
59
+ globalid (>= 0.3.6)
60
+ activemodel (7.0.2.3)
61
+ activesupport (= 7.0.2.3)
62
+ activerecord (7.0.2.3)
63
+ activemodel (= 7.0.2.3)
64
+ activesupport (= 7.0.2.3)
65
+ activestorage (7.0.2.3)
66
+ actionpack (= 7.0.2.3)
67
+ activejob (= 7.0.2.3)
68
+ activerecord (= 7.0.2.3)
69
+ activesupport (= 7.0.2.3)
70
+ marcel (~> 1.0)
71
+ mini_mime (>= 1.1.0)
72
+ activesupport (7.0.2.3)
73
+ concurrent-ruby (~> 1.0, >= 1.0.2)
74
+ i18n (>= 1.6, < 2)
75
+ minitest (>= 5.1)
76
+ tzinfo (~> 2.0)
77
+ appraisal (2.4.1)
78
+ bundler
79
+ rake
80
+ thor (>= 0.14.0)
81
+ ast (2.4.2)
82
+ builder (3.2.4)
83
+ cable_ready (5.0.0.pre9)
84
+ actioncable (>= 5.2)
85
+ actionpack (>= 5.2)
86
+ actionview (>= 5.2)
87
+ activerecord (>= 5.2)
88
+ activesupport (>= 5.2)
89
+ railties (>= 5.2)
90
+ thread-local (>= 1.1.0)
91
+ coderay (1.1.3)
92
+ concurrent-ruby (1.1.10)
93
+ crass (1.0.6)
94
+ digest (3.1.0)
95
+ erubi (1.10.0)
96
+ globalid (1.0.0)
97
+ activesupport (>= 5.0)
98
+ i18n (1.10.0)
99
+ concurrent-ruby (~> 1.0)
100
+ kredis (1.1.0)
101
+ activesupport (>= 6.0.0)
102
+ redis (~> 4.2)
103
+ loofah (2.16.0)
104
+ crass (~> 1.0.2)
105
+ nokogiri (>= 1.5.9)
106
+ mail (2.7.1)
107
+ mini_mime (>= 0.1.1)
108
+ marcel (1.0.2)
109
+ method_source (1.0.0)
110
+ mini_mime (1.1.2)
111
+ mini_portile2 (2.7.1)
112
+ minitest (5.15.0)
113
+ mocha (1.13.0)
114
+ net-imap (0.2.3)
115
+ digest
116
+ net-protocol
117
+ strscan
118
+ net-pop (0.1.1)
119
+ digest
120
+ net-protocol
121
+ timeout
122
+ net-protocol (0.1.3)
123
+ timeout
124
+ net-smtp (0.3.1)
125
+ digest
126
+ net-protocol
127
+ timeout
128
+ nio4r (2.5.8)
129
+ nokogiri (1.13.0)
130
+ mini_portile2 (~> 2.7.0)
131
+ racc (~> 1.4)
132
+ nokogiri (1.13.0-arm64-darwin)
133
+ racc (~> 1.4)
134
+ parallel (1.21.0)
135
+ parser (3.1.0.0)
136
+ ast (~> 2.4.1)
137
+ pry (0.14.1)
138
+ coderay (~> 1.1)
139
+ method_source (~> 1.0)
140
+ racc (1.6.0)
141
+ rack (2.2.3)
142
+ rack-test (1.1.0)
143
+ rack (>= 1.0, < 3)
144
+ rails (7.0.2.3)
145
+ actioncable (= 7.0.2.3)
146
+ actionmailbox (= 7.0.2.3)
147
+ actionmailer (= 7.0.2.3)
148
+ actionpack (= 7.0.2.3)
149
+ actiontext (= 7.0.2.3)
150
+ actionview (= 7.0.2.3)
151
+ activejob (= 7.0.2.3)
152
+ activemodel (= 7.0.2.3)
153
+ activerecord (= 7.0.2.3)
154
+ activestorage (= 7.0.2.3)
155
+ activesupport (= 7.0.2.3)
156
+ bundler (>= 1.15.0)
157
+ railties (= 7.0.2.3)
158
+ rails-dom-testing (2.0.3)
159
+ activesupport (>= 4.2.0)
160
+ nokogiri (>= 1.6)
161
+ rails-html-sanitizer (1.4.2)
162
+ loofah (~> 2.3)
163
+ railties (7.0.2.3)
164
+ actionpack (= 7.0.2.3)
165
+ activesupport (= 7.0.2.3)
166
+ method_source
167
+ rake (>= 12.2)
168
+ thor (~> 1.0)
169
+ zeitwerk (~> 2.5)
170
+ rainbow (3.0.0)
171
+ rake (13.0.6)
172
+ redis (4.6.0)
173
+ regexp_parser (2.2.0)
174
+ rexml (3.2.5)
175
+ rubocop (1.23.0)
176
+ parallel (~> 1.10)
177
+ parser (>= 3.0.0.0)
178
+ rainbow (>= 2.2.2, < 4.0)
179
+ regexp_parser (>= 1.8, < 3.0)
180
+ rexml
181
+ rubocop-ast (>= 1.12.0, < 2.0)
182
+ ruby-progressbar (~> 1.7)
183
+ unicode-display_width (>= 1.4.0, < 3.0)
184
+ rubocop-ast (1.15.1)
185
+ parser (>= 3.0.1.1)
186
+ rubocop-performance (1.12.0)
187
+ rubocop (>= 1.7.0, < 2.0)
188
+ rubocop-ast (>= 0.4.0)
189
+ ruby-progressbar (1.11.0)
190
+ sqlite3 (1.4.2)
191
+ standard (1.5.0)
192
+ rubocop (= 1.23.0)
193
+ rubocop-performance (= 1.12.0)
194
+ strscan (3.0.1)
195
+ thor (1.2.1)
196
+ thread-local (1.1.0)
197
+ timeout (0.2.0)
198
+ tzinfo (2.0.4)
199
+ concurrent-ruby (~> 1.0)
200
+ unicode-display_width (2.1.0)
201
+ websocket-driver (0.7.5)
202
+ websocket-extensions (>= 0.1.0)
203
+ websocket-extensions (0.1.5)
204
+ zeitwerk (2.5.4)
205
+
206
+ PLATFORMS
207
+ arm64-darwin-21
208
+ ruby
209
+
210
+ DEPENDENCIES
211
+ appraisal
212
+ cubism!
213
+ mocha
214
+ nokogiri
215
+ pry
216
+ sqlite3
217
+ standard
218
+
219
+ BUNDLED WITH
220
+ 2.3.3
data/Gemfile~ ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ # Specify your gem's dependencies in cubism.gemspec.
5
+ gemspec
6
+
7
+ gem "appraisal", github: "excid3/appraisal", branch: "fix-bundle-env"
8
+
9
+ gem "pry", group: [:development, :test]
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
@@ -96,9 +113,10 @@ CableReady.initialize({ consumer });
96
113
 
97
114
  The `cubicle_for` helper accepts the following options as keyword arguments:
98
115
 
116
+ - `scope`: declare a scope in which presence indicators should appear. For example, if you want to divide between index and show views, do `scope: :index` and `scope: :show` respectively (default: `""`).
99
117
  - `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.
118
+ - `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. Another special value is `:intersect`, which fires when the `trigger_root` comes into the viewport.
119
+ - `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. Analoguous to above, `:intersect` means that `disappear` will fire when the `trigger_root` is scrolled out of the viewport.
102
120
  - `trigger_root`: a CSS selector to attach the appear/disappear events to. Defaults to the `cubicle-element` itself.
103
121
  - `html_options` are passed to the TagBuilder.
104
122
 
@@ -145,7 +163,7 @@ yarn link # set the local machine's cubism npm package's lookup to this local pa
145
163
 
146
164
  # Setup a sample project and edit Gemfile to point to local gem
147
165
  # (e.g. `gem "cubism", path: "../cubism"`)
148
- # yarn link @stimulus_reflex/cubism
166
+ # yarn link @minthesize/cubism
149
167
 
150
168
 
151
169
  # Do your work, Submit PR, Profit!
@@ -162,14 +180,17 @@ cd path/to/project
162
180
  yarn install --force
163
181
  ```
164
182
 
165
- ### Release
166
-
167
- 1. Update the version numbers in `javascript/package.json` and `lib/cubism/version.rb`
168
- 2. `git commit -m "Bump version to x.x.x"`
169
- 3. Run `bundle exec rake build`
170
- 4. Run `bundle exec rake release`
171
- 5. Run `npm publish --access public`
172
-
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
173
194
  ## License
174
195
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
175
196
 
data/README.md~ ADDED
@@ -0,0 +1,191 @@
1
+ # Cubism
2
+ <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
3
+ [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)
4
+ <!-- ALL-CONTRIBUTORS-BADGE:END -->
5
+ [![Twitter follow](https://img.shields.io/twitter/follow/julian_rubisch?style=social)](https://twitter.com/julian_rubisch)
6
+
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.
10
+
11
+ ## Table of Contents
12
+
13
+ - [Table of Contents](#table-of-contents)
14
+ - [Usage](#usage)
15
+ - [Installation](#installation)
16
+ - [API](#api)
17
+ - [Limitations](#limitations)
18
+ - [Gotchas](#gotchas)
19
+ - [Contributing](#contributing)
20
+ - [License](#license)
21
+ - [Contributors](#contributors)
22
+
23
+ ## Usage
24
+
25
+ ### Prepare your User Model
26
+ In your app's `User` model, include `Cubism::User`:
27
+
28
+ ```rb
29
+ class User < ApplicationRecord
30
+ include Cubism::User
31
+
32
+ # ...
33
+ end
34
+ ```
35
+
36
+ ### Track Present Users in your Models
37
+ In the models you'd like to track presence for, include the `Cubism::Presence` concern:
38
+
39
+ ```rb
40
+ class Project < ApplicationRecord
41
+ include Cubism::Presence
42
+
43
+ # ...
44
+ end
45
+ ```
46
+
47
+ ### Set Up the Cubicle Template
48
+
49
+ Using the `cubicle_for` helper, you can set up a presence indicator. It will
50
+
51
+ 1. subscribe to the respective resource, and
52
+ 2. render a block which is passed the list of present `users`:
53
+
54
+ ```erb
55
+ <%= cubicle_for @project, current_user do |users| %>
56
+ <%= users.map(&:username).join(", ")
57
+ <% end %>
58
+ ```
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
+
62
+ ## Installation
63
+ Add this line to your application's Gemfile:
64
+
65
+ ```ruby
66
+ gem 'cubism'
67
+ ```
68
+
69
+ And then execute:
70
+ ```bash
71
+ $ bundle
72
+ ```
73
+
74
+ After `bundle`, install the Javascript library:
75
+
76
+ ```bash
77
+ $ bin/yarn add @minthesize/cubism
78
+ ```
79
+
80
+ ### Kredis
81
+
82
+ This gem uses [kredis](https://github.com/rails/kredis) under the hood, so be sure to follow their [installation instructions](https://github.com/rails/kredis#installation). In other words, provide a Redis instance and configure it in `config/redis/shared.yml`.
83
+
84
+ ### Javascript
85
+
86
+ In your app's Javascript entrypoint (e.g. `app/javascript/packs/application.js`) import and initialize `CableReady` (cubism will make use of the injected ActionCable consumer):
87
+
88
+ ```js
89
+ import CableReady from "cable_ready";
90
+ import "@minthesize/cubism";
91
+
92
+ CableReady.initialize({ consumer });
93
+ ```
94
+
95
+ ## API
96
+
97
+ The `cubicle_for` helper accepts the following options as keyword arguments:
98
+
99
+ - `scope`: declare a scope in which presence indicators should appear. For example, if you want to divide between index and show views, do `scope: :index` and `scope: :show` respectively (default: `""`).
100
+ - `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`).
101
+ - `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. Another special value is `:intersect`, which fires when the `trigger_root` comes into the viewport.
102
+ - `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. Analoguous to above, `:intersect` means that `disappear` will fire when the `trigger_root` is scrolled out of the viewport.
103
+ - `trigger_root`: a CSS selector to attach the appear/disappear events to. Defaults to the `cubicle-element` itself.
104
+ - `html_options` are passed to the TagBuilder.
105
+
106
+ ## Limitations
107
+
108
+ ### Supported Template Handlers
109
+ - ERB
110
+
111
+ ## Gotchas
112
+
113
+ ### Usage with ViewComponent
114
+
115
+ Currently there's a bug in VC resulting in the `capture` helper not working correctly (https://github.com/github/view_component/pull/974). The current workaround is to assign a slot in your component and render the presence list from outside:
116
+
117
+ ```rb
118
+ class MyComponent < ViewComponent::Base
119
+ renders_one :presence_list
120
+
121
+ # ...
122
+ end
123
+ ```
124
+
125
+ ```erb
126
+ <%= render MyComponent.new do |c| %>
127
+ <% c.presence_list do %>
128
+ <%= cubicle_for @project, current_user do |users| %>
129
+ ...
130
+ <% end %>
131
+ <% end %>
132
+ <% end %>
133
+ ```
134
+
135
+ ## Contributing
136
+
137
+ ### Get local environment setup
138
+
139
+ Below are a set of instructions that may help you get a local development environment working
140
+
141
+ ```sh
142
+ # Get the gem/npm package source locally
143
+ git clone https://github.com/julianrubisch/cubism
144
+ yarn install # install all of the npm package's dependencies
145
+ yarn link # set the local machine's cubism npm package's lookup to this local path
146
+
147
+ # Setup a sample project and edit Gemfile to point to local gem
148
+ # (e.g. `gem "cubism", path: "../cubism"`)
149
+ # yarn link @stimulus_reflex/cubism
150
+
151
+
152
+ # Do your work, Submit PR, Profit!
153
+
154
+
155
+ # To stop using your local version of cubism
156
+ # change your Gemfile back to the published (e.g. `gem "cubism"`)
157
+ cd path/to/cubism/javascript
158
+ # Stop using the local npm package
159
+ yarn unlink
160
+
161
+ # Instruct your project to reinstall the published version of the npm package
162
+ cd path/to/project
163
+ yarn install --force
164
+ ```
165
+
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
+
174
+ ## License
175
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
176
+
177
+ ## Contributors
178
+
179
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
180
+ <!-- prettier-ignore-start -->
181
+ <!-- markdownlint-disable -->
182
+ <table>
183
+ <tr>
184
+ <td align="center"><a href="http://www.minthesize.com"><img src="https://avatars.githubusercontent.com/u/4352208?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Julian Rubisch</b></sub></a><br /><a href="https://github.com/julianrubisch/cubism/commits?author=julianrubisch" title="Code">💻</a></td>
185
+ </tr>
186
+ </table>
187
+
188
+ <!-- markdownlint-restore -->
189
+ <!-- prettier-ignore-end -->
190
+
191
+ <!-- ALL-CONTRIBUTORS-LIST:END -->