cable_ready 4.0.6 → 4.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b121b1e33a62d1196e08b55b1a2c8a89d53e54ec1d5880264624714aaf57cdd
4
- data.tar.gz: 8218ea4e5fce9728eee4b5979df81f7e4a6752f1f7dcea33746d38b460d45321
3
+ metadata.gz: 0e50431320c8001f455dcbc16f47eddc35752fb3e98b199861673ffc1f05d71f
4
+ data.tar.gz: 9b510c240c183ffe9ead18c896bd5748e8e9305223006eec8968ada79e438595
5
5
  SHA512:
6
- metadata.gz: fbee1b6a0cdcadbb565441617e9c8f09bb13b915fb8858cdc3b6d13ef9bc22b79d7a9b5149d9c6f5834356cd9b884197ba92cd6a4e9b6d9b9d73b3ae903e7191
7
- data.tar.gz: d407c484474ed1f3acf46adaed5c96af4067d58f75252bcf395eaa98fa7c857cc8438f68735d6b15e7852ef8d326258b09ad6a4bc4c8da2e0caac5eca371a2f6
6
+ metadata.gz: 354e3e6b94cb9adef0a1428d30f1e571d0893204e1bdff3317502000d2d97e2747f8cfb8fdb3d04f818cc55ac506f87e0753aa67290b82b0844b53f4edec7090
7
+ data.tar.gz: 267d1c79f31c10d070bdde344897ef6cfeae7e900924f1ac14d6e04eab216f969eb45f72c4faf55ad9a45ff0bfd1de4fb10d51336ee60f5d483a1f20c4589433
@@ -0,0 +1,76 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ - Using welcoming and inclusive language
18
+ - Being respectful of differing viewpoints and experiences
19
+ - Gracefully accepting constructive criticism
20
+ - Focusing on what is best for the community
21
+ - Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ - The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ - Trolling, insulting/derogatory comments, and personal or political attacks
28
+ - Public or private harassment
29
+ - Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ - Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at natehop@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
+
73
+ [homepage]: https://www.contributor-covenant.org
74
+
75
+ For answers to common questions about this code of conduct, see
76
+ https://www.contributor-covenant.org/faq
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cable_ready (4.0.6)
4
+ cable_ready (4.0.7)
5
5
  rails (>= 5.2)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  [![Lines of Code](http://img.shields.io/badge/lines_of_code-268-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
2
2
  [![Maintainability](https://api.codeclimate.com/v1/badges/83ddf1fee4af7e51a681/maintainability)](https://codeclimate.com/github/hopsoft/cable_ready/maintainability)
3
+ ![Prettier-Standard](https://github.com/hopsoft/cable_ready/workflows/Prettier-Standard/badge.svg)
4
+ ![StandardRB](https://github.com/hopsoft/cable_ready/workflows/StandardRB/badge.svg)
3
5
 
4
6
  # CableReady
5
7
 
@@ -11,361 +13,22 @@ from the server via [ActionCable](http://guides.rubyonrails.org/action_cable_ove
11
13
  Please read the official [ActionCable docs](http://guides.rubyonrails.org/action_cable_overview.html)
12
14
  to learn more about ActionCable before proceeding.
13
15
 
14
- ## Setup
16
+ ## Docs
15
17
 
16
- ### JavaScript
18
+ - [Official Documentation](https://cableready.stimulusreflex.com)
19
+ - [Documentation Source Code](https://github.com/hopsoft/cable_ready/tree/master/docs)
17
20
 
18
- ```
19
- yarn install cable_ready
20
- ```
21
-
22
- ### Gemfile
23
-
24
- ```ruby
25
- gem "cable_ready"
26
- ```
27
-
28
- ## Usage
29
-
30
- ### app/assets/javascripts/channels/user.js
31
-
32
- ```javascript
33
- import CableReady from 'cable_ready';
34
-
35
- App.cable.subscriptions.create({ channel: "UserChannel" }, {
36
- received: function (data) {
37
- if (data.cableReady) {
38
- CableReady.perform(data.operations);
39
- }
40
- }
41
- });
42
- ```
43
-
44
- ### app/models/user.rb
45
-
46
- ```ruby
47
- class User < ApplicationRecord
48
- include CableReady::Broadcaster
49
-
50
- def broadcast_name_change
51
- cable_ready["UserChannel"].text_content selector: "#user-name", text: name
52
- cable_ready.broadcast
53
- end
54
- end
55
- ```
56
-
57
- ## Supported DOM Operations
58
-
59
- - [dispatchEvent](#dispatchevent)
60
- - [morph](#morph)
61
- - [innerHTML](#innerhtml)
62
- - [outerHTML](#outerhtml)
63
- - [insertAdjacentHTML](#insertAdjacentHTML)
64
- - [insertAdjacentText](#insertadjacenttext)
65
- - [remove](#remove)
66
- - [setValue](#setvalue)
67
- - [setAttribute](#setattribute)
68
- - [removeAttribute](#removeattribute)
69
- - [addCssClass](#addcssclass)
70
- - [removeCssClass](#removecssclass)
71
- - [setDatasetProperty](#setdatasetproperty)
72
-
73
- > The `selector` options use [document.querySelector()](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector) to find an element by default. [XPath](https://developer.mozilla.org/en-US/docs/Web/XPath) expressions can also be used if the `xpath` option is set to `true`. As with CSS selectors, the XPath expression must resolve to a single element and not a collection.
74
-
75
- > It's possible to invoke multiple DOM operations with a single ActionCable broadcast.
76
-
77
- > All DOM mutations have corresponding `before/after` events triggered on `document`.
78
- > These events expose `event.detail` set to the arguments from the server.
79
-
80
- ## Xpath Example
81
-
82
- ### app/models/user.rb
83
-
84
- ```ruby
85
- class User < ApplicationRecord
86
- include CableReady::Broadcaster
87
-
88
- def broadcast_name_change
89
- cable_ready["UserChannel"].text_content selector: "/html/body/div[1]/form/input[1]", text: name, xpath: true
90
- cable_ready.broadcast
91
- end
92
- end
93
- ```
94
-
95
- ### DOM Events
96
-
97
- #### [dispatchEvent](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent)
98
-
99
- Dispatches a DOM event in the browser.
100
-
101
- ```ruby
102
- cable_ready["MyChannel"].dispatch_event(
103
- name: "string", # required - the name of the DOM event to dispatch (can be custom)
104
- detail: "object", # [null] - assigned to event.detail
105
- selector: "string" # [window] - string containing a CSS selector or XPath expression
106
- )
107
- ```
108
-
109
- ### Element Mutations
110
-
111
- #### [morph](https://github.com/patrick-steele-idem/morphdom)
112
-
113
- [Fast lightweight DOM diffing/patching](https://github.com/patrick-steele-idem/morphdom) without a virtual DOM.
114
-
115
- ```ruby
116
- cable_ready["MyChannel"].morph(
117
- selector: "string", # required - string containing a CSS selector or XPath expression
118
- html: "string", # [null] - the HTML to assign
119
- children_only: true|false, # [null] - indicates if only child nodes should be morphed... skipping the parent element
120
- permanent_attribute_name: "string", # [null] - an attribute name that prevents elements from being updated i.e. "data-permanent"
121
- focus_selector: "string", # [null] - string containing a CSS selector
122
- )
123
- ```
124
-
125
- ##### JavaScript Events
126
-
127
- - `cable-ready:before-morph`
128
- - `cable-ready:after-morph`
129
-
130
- ##### Stimulus Gotchas
131
-
132
- For some reason [Stimulus](https://github.com/stimulusjs/stimulus) controllers don't reconnect after DOM mutations triggered by [Morphdom](https://github.com/patrick-steele-idem/morphdom).
133
- You can force your controllers to reconnect with the following code.
134
-
135
- ```javascript
136
- import { Controller } from "stimulus"
137
-
138
- export default class extends Controller {
139
- connect() {
140
- this.name = this.element.dataset.controller;
141
- document.addEventListener('cable-ready:after-morph', this.reconnect.bind(this));
142
- );
143
- }
144
-
145
- reconnect() {
146
- setTimeout(() => this.element.setAttribute('data-controller', this.name), 1);
147
- this.element.setAttribute('data-controller', '');
148
- }
149
- }
150
- ```
151
-
152
- #### [innerHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML)
153
-
154
- Sets the innerHTML of a DOM element.
155
-
156
- ```ruby
157
- cable_ready["MyChannel"].inner_html(
158
- selector: "string", # required - string containing a CSS selector or XPath expression
159
- focus_selector: "string", # [null] - string containing a CSS selector
160
- html: "string" # [null] - the HTML to assign
161
- )
162
- ```
163
-
164
- ##### JavaScript Events
165
-
166
- - `cable-ready:before-inner-html`
167
- - `cable-ready:after-inner-html`
168
-
169
- #### [outerHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/outerHTML)
170
-
171
- Replaces a DOM element with new HTML.
172
-
173
- ```ruby
174
- cable_ready["MyChannel"].outerHTML(
175
- selector: "string", # required - string containing a CSS selector or XPath expression
176
- focus_selector: "string", # [null] - string containing a CSS selector
177
- html: "string" # [null] - the HTML to use as replacement
178
- )
179
- ```
180
-
181
- ##### JavaScript Events
182
-
183
- - `cable-ready:before-outer-html`
184
- - `cable-ready:after-outer-html`
185
-
186
- #### [textContent](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent)
187
-
188
- Sets the text content of a DOM element.
189
-
190
- ```ruby
191
- cable_ready["MyChannel"].text_content(
192
- selector: "string", # required - string containing a CSS selector or XPath expression
193
- text: "string" # [null] - the text to assign
194
- )
195
- ```
196
-
197
- ##### JavaScript Events
198
-
199
- - `cable-ready:before-text-content`
200
- - `cable-ready:after-text-content`
201
-
202
- #### [insertAdjacentHTML](https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentHTML)
203
-
204
- Inserts HTML into the DOM relative to an element.
205
- Supports behavior akin to prepend & append.
206
-
207
- ```ruby
208
- cable_ready["MyChannel"].insert_adjacent_html(
209
- selector: "string", # required - string containing a CSS selector or XPath expression
210
- focus_selector: "string", # [null] - string containing a CSS selector
211
- position: "string", # [beforeend] - the relative position to the DOM element (beforebegin, afterbegin, beforeend, afterend)
212
- html: "string" # [null] - the HTML to insert
213
- )
214
- ```
215
-
216
- ##### JavaScript Events
217
-
218
- - `cable-ready:before-insert-adjacent-html`
219
- - `cable-ready:after-insert-adjacent-html`
220
-
221
- #### [insertAdjacentText](https://developer.mozilla.org/en-US/docs/Web/API/Element/insertAdjacentText)
222
-
223
- Inserts text into the DOM relative to an element.
224
- Supports behavior akin to prepend & append.
225
-
226
- ```ruby
227
- cable_ready["MyChannel"].insert_adjacent_text(
228
- selector: "string", # required - string containing a CSS selector or XPath expression
229
- position: "string", # [beforeend] - the relative position to the DOM element (beforebegin, afterbegin, beforeend, afterend)
230
- text: "string" # [null] - the text to insert
231
- )
232
- ```
233
-
234
- ##### JavaScript Events
235
-
236
- - `cable-ready:before-insert-adjacent-text`
237
- - `cable-ready:after-insert-adjacent-text`
238
-
239
- #### [remove](https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove)
240
-
241
- Removes an element from the DOM.
242
-
243
- ```ruby
244
- cable_ready["MyChannel"].remove(
245
- selector: "string", # required - string containing a CSS selector or XPath expression
246
- focus_selector: "string" # [null] - string containing a CSS selector
247
- )
248
- ```
249
-
250
- ##### JavaScript Events
251
-
252
- - `cable-ready:before-remove`
253
- - `cable-ready:after-remove`
254
-
255
- #### [setValue](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement)
256
-
257
- Sets the value of an element.
258
-
259
- ```ruby
260
- cable_ready["MyChannel"].set_value(
261
- selector: "string", # required - string containing a CSS selector or XPath expression
262
- value: "string" # [null] - the value to assign to the attribute
263
- )
264
- ```
265
-
266
- ##### JavaScript Events
267
-
268
- - `cable-ready:before-set-value`
269
- - `cable-ready:after-set-value`
270
-
271
- ### Attribute Mutations
272
-
273
- #### [setAttribute](https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute)
274
-
275
- Sets an attribute on an element.
276
-
277
- ```ruby
278
- cable_ready["MyChannel"].set_attribute(
279
- selector: "string", # required - string containing a CSS selector or XPath expression
280
- name: "string", # required - the attribute to set
281
- value: "string" # [null] - the value to assign to the attribute
282
- )
283
- ```
284
-
285
- ##### JavaScript Events
286
-
287
- - `cable-ready:before-set-attribute`
288
- - `cable-ready:after-set-attribute`
289
-
290
- #### [removeAttribute](https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute)
291
-
292
- Removes an attribute from an element.
293
-
294
- ```ruby
295
- cable_ready["MyChannel"].remove_attribute(
296
- selector: "string", # required - string containing a CSS selector or XPath expression
297
- name: "string" # required - the attribute to remove
298
- )
299
- ```
300
-
301
- ##### JavaScript Events
302
-
303
- - `cable-ready:before-remove-attribute`
304
- - `cable-ready:after-remove-attribute`
305
-
306
- ### CSS Class Mutations
307
-
308
- #### [addCssClass](https://developer.mozilla.org/en-US/docs/Web/API/Element/classList)
309
-
310
- Adds a css class to an element.
311
- This is a `noop` if the css class is already assigned.
312
-
313
- ```ruby
314
- cable_ready["MyChannel"].add_css_class(
315
- selector: "string", # required - string containing a CSS selector or XPath expression
316
- name: "string" # [null] - the CSS class to add
317
- )
318
-
319
- ```
320
-
321
- ##### JavaScript Events
322
-
323
- - `cable-ready:before-add-css-class`
324
- - `cable-ready:after-add-css-class`
325
-
326
- #### [removeCssClass](https://developer.mozilla.org/en-US/docs/Web/API/Element/classList)
327
-
328
- Removes a css class from an element.
329
-
330
- ```ruby
331
- cable_ready["MyChannel"].add_css_class(
332
- selector: "string", # required - string containing a CSS selector or XPath expression
333
- name: "string" # [null] - the CSS class to remove
334
- )
335
- ```
336
-
337
- ##### JavaScript Events
338
-
339
- - `cable-ready:before-remove-css-class`
340
- - `cable-ready:after-remove-css-class`
341
-
342
- ### Dataset Mutations
343
-
344
- #### [setDatasetProperty](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset)
345
-
346
- Sets an dataset property (data-* attribute) on an element.
347
-
348
- ```ruby
349
- cable_ready["MyChannel"].set_dataset_property(
350
- selector: "string", # required - string containing a CSS selector or XPath expression
351
- name: "string", # required - the property to set
352
- value: "string" # [null] - the value to assign to the dataset
353
- )
354
- ```
355
-
356
- ##### JavaScript Events
357
-
358
- - `cable-ready:before-set-dataset-property`
359
- - `cable-ready:after-set-dataset-property`
21
+ ## Contributing
360
22
 
361
- ## JavaScript Development
23
+ ### Code of Conduct
362
24
 
363
- Please run `bin/standardize` on your codebase before submitting commits.
25
+ Everyone interacting with CableReady is expected to follow the [Code of Conduct](CODE_OF_CONDUCT.md)
364
26
 
365
- ## Contributing
27
+ ### Coding Standards
366
28
 
367
29
  This project uses [Standard](https://github.com/testdouble/standard)
368
- and [Prettier](https://github.com/prettier/prettier) to minimize bike shedding related to code formatting.
30
+ and [prettier-standard](https://github.com/sheerun/prettier-standard) to minimize bike shedding related to code formatting.
31
+
369
32
  Please run `./bin/standardize` prior submitting pull requests.
370
33
 
371
34
  ### Releasing
@@ -1,3 +1,3 @@
1
1
  module CableReady
2
- VERSION = "4.0.6"
2
+ VERSION = "4.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cable_ready
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.6
4
+ version: 4.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hopkins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-03 00:00:00.000000000 Z
11
+ date: 2019-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -87,6 +87,7 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - CODE_OF_CONDUCT.md
90
91
  - Gemfile
91
92
  - Gemfile.lock
92
93
  - LICENSE.txt