cable_ready 4.0.3 → 4.0.4

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: 4e3ee79d7ceb554a3266d00a314664dd6b4013b31bee26c2ffe9eea1731d8902
4
- data.tar.gz: e4a2e91f8d7a5ebc075f4b6779fe0596d8d818771d2c982573dd732a984df799
3
+ metadata.gz: f7dceb4cb5c1a5f1768435818fe3c0605de13b81be36cb6fafea38a3124dc08b
4
+ data.tar.gz: 573b35e97838527b2f8342a5e09ac62a0a9c211a8c6f6d4cdac2929e08a77780
5
5
  SHA512:
6
- metadata.gz: 663d675621ad4a81f8c3c5ce37c246c19106a1712bc0969258bd44f0283c562ffd07792ff7d4191eba29eb943697617063b0d93d7b07dc2ee585445ec1d1ec0a
7
- data.tar.gz: 71c5ecc3737f9528c6aa9ebbbc5f1ae85470fca5d8e5a56bef7b4beca7b1d251a681338c93314b06ddcdc3c71c529a7bc5b7e1cd2da3b4176b51378b218c78ca
6
+ metadata.gz: 6683fbb458ee7733cfaa6cc0daa7b030b1d2ee1e3e8573e80f6c7839ee90c644957ee5bee9aebc42d261e544bf04eb0af3988c142c6a331e91d8adf05a761837
7
+ data.tar.gz: ce2624613f73527d02e8a978747ac3c1386db77a2a8dacdb84178940be617a2da00906add1b28844a61975716fdb4811749afb26d9f2e3ca76fa38e201d828e2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cable_ready (4.0.3)
4
+ cable_ready (4.0.4)
5
5
  rails (>= 5.2)
6
6
 
7
7
  GEM
@@ -85,7 +85,7 @@ GEM
85
85
  mini_mime (1.0.2)
86
86
  mini_portile2 (2.4.0)
87
87
  minitest (5.11.3)
88
- nio4r (2.4.0)
88
+ nio4r (2.5.1)
89
89
  nokogiri (1.10.4)
90
90
  mini_portile2 (~> 2.4.0)
91
91
  parallel (1.17.0)
@@ -157,7 +157,7 @@ GEM
157
157
  websocket-driver (0.7.1)
158
158
  websocket-extensions (>= 0.1.0)
159
159
  websocket-extensions (0.1.4)
160
- zeitwerk (2.1.9)
160
+ zeitwerk (2.1.10)
161
161
 
162
162
  PLATFORMS
163
163
  ruby
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Lines of Code](http://img.shields.io/badge/lines_of_code-239-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
1
+ [![Lines of Code](http://img.shields.io/badge/lines_of_code-236-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
3
 
4
4
  # CableReady
@@ -70,12 +70,27 @@ end
70
70
  - [removeCssClass](#removecssclass)
71
71
  - [setDatasetProperty](#setdatasetproperty)
72
72
 
73
- > The `selector` options use [Document.querySelector()](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector) to find elements.
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
74
 
75
75
  > It's possible to invoke multiple DOM operations with a single ActionCable broadcast.
76
76
 
77
77
  > All DOM mutations have corresponding `before/after` events triggered on `document`.
78
- > These events expose `detail.config` set to the arguments from the server.
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
+ ```
79
94
 
80
95
  ### DOM Events
81
96
 
@@ -87,7 +102,7 @@ Dispatches a DOM event in the browser.
87
102
  cable_ready["MyChannel"].dispatch_event(
88
103
  name: "string", # required - the name of the DOM event to dispatch (can be custom)
89
104
  detail: "object", # [null] - assigned to event.detail
90
- selector: "string" # [window] - string containing one or more CSS selectors separated by commas
105
+ selector: "string" # [window] - string containing a CSS selector or XPath expression
91
106
  )
92
107
  ```
93
108
 
@@ -99,10 +114,10 @@ cable_ready["MyChannel"].dispatch_event(
99
114
 
100
115
  ```ruby
101
116
  cable_ready["MyChannel"].morph(
102
- selector: "string", # required - string containing one or more CSS selectors separated by commas
117
+ selector: "string", # required - string containing a CSS selector or XPath expression
103
118
  html: "string" # [null] - the HTML to assign
104
119
  children_only: true|false # [null] - indicates if only child nodes should be morphed... skipping the parent element
105
- focus_selector: "string", # [null] - string containing one or more CSS selectors separated by commas
120
+ focus_selector: "string", # [null] - string containing a CSS selector
106
121
  )
107
122
  ```
108
123
 
@@ -139,8 +154,8 @@ Sets the innerHTML of a DOM element.
139
154
 
140
155
  ```ruby
141
156
  cable_ready["MyChannel"].inner_html(
142
- selector: "string", # required - string containing one or more CSS selectors separated by commas
143
- focus_selector: "string", # [null] - string containing one or more CSS selectors separated by commas
157
+ selector: "string", # required - string containing a CSS selector or XPath expression
158
+ focus_selector: "string", # [null] - string containing a CSS selector
144
159
  html: "string" # [null] - the HTML to assign
145
160
  )
146
161
  ```
@@ -156,8 +171,8 @@ Replaces a DOM element with new HTML.
156
171
 
157
172
  ```ruby
158
173
  cable_ready["MyChannel"].outerHTML(
159
- selector: "string", # required - string containing one or more CSS selectors separated by commas
160
- focus_selector: "string", # [null] - string containing one or more CSS selectors separated by commas
174
+ selector: "string", # required - string containing a CSS selector or XPath expression
175
+ focus_selector: "string", # [null] - string containing a CSS selector
161
176
  html: "string" # [null] - the HTML to use as replacement
162
177
  )
163
178
  ```
@@ -173,7 +188,7 @@ Sets the text content of a DOM element.
173
188
 
174
189
  ```ruby
175
190
  cable_ready["MyChannel"].text_content(
176
- selector: "string", # required - string containing one or more CSS selectors separated by commas
191
+ selector: "string", # required - string containing a CSS selector or XPath expression
177
192
  text: "string" # [null] - the text to assign
178
193
  )
179
194
  ```
@@ -190,8 +205,8 @@ Supports behavior akin to prepend & append.
190
205
 
191
206
  ```ruby
192
207
  cable_ready["MyChannel"].insert_adjacent_html(
193
- selector: "string", # required - string containing one or more CSS selectors separated by commas
194
- focus_selector: "string", # [null] - string containing one or more CSS selectors separated by commas
208
+ selector: "string", # required - string containing a CSS selector or XPath expression
209
+ focus_selector: "string", # [null] - string containing a CSS selector
195
210
  position: "string", # [beforeend] - the relative position to the DOM element (beforebegin, afterbegin, beforeend, afterend)
196
211
  html: "string" # [null] - the HTML to insert
197
212
  )
@@ -209,7 +224,7 @@ Supports behavior akin to prepend & append.
209
224
 
210
225
  ```ruby
211
226
  cable_ready["MyChannel"].insert_adjacent_text(
212
- selector: "string", # required - string containing one or more CSS selectors separated by commas
227
+ selector: "string", # required - string containing a CSS selector or XPath expression
213
228
  position: "string", # [beforeend] - the relative position to the DOM element (beforebegin, afterbegin, beforeend, afterend)
214
229
  text: "string" # [null] - the text to insert
215
230
  )
@@ -226,8 +241,8 @@ Removes an element from the DOM.
226
241
 
227
242
  ```ruby
228
243
  cable_ready["MyChannel"].remove(
229
- selector: "string", # required - string containing one or more CSS selectors separated by commas
230
- focus_selector: "string" # [null] - string containing one or more CSS selectors separated by commas
244
+ selector: "string", # required - string containing a CSS selector or XPath expression
245
+ focus_selector: "string" # [null] - string containing a CSS selector
231
246
  )
232
247
  ```
233
248
 
@@ -242,7 +257,7 @@ Sets the value of an element.
242
257
 
243
258
  ```ruby
244
259
  cable_ready["MyChannel"].set_value(
245
- selector: "string", # required - string containing one or more CSS selectors separated by commas
260
+ selector: "string", # required - string containing a CSS selector or XPath expression
246
261
  value: "string" # [null] - the value to assign to the attribute
247
262
  )
248
263
  ```
@@ -260,7 +275,7 @@ Sets an attribute on an element.
260
275
 
261
276
  ```ruby
262
277
  cable_ready["MyChannel"].set_attribute(
263
- selector: "string", # required - string containing one or more CSS selectors separated by commas
278
+ selector: "string", # required - string containing a CSS selector or XPath expression
264
279
  name: "string", # required - the attribute to set
265
280
  value: "string" # [null] - the value to assign to the attribute
266
281
  )
@@ -277,7 +292,7 @@ Removes an attribute from an element.
277
292
 
278
293
  ```ruby
279
294
  cable_ready["MyChannel"].remove_attribute(
280
- selector: "string", # required - string containing one or more CSS selectors separated by commas
295
+ selector: "string", # required - string containing a CSS selector or XPath expression
281
296
  name: "string" # required - the attribute to remove
282
297
  )
283
298
  ```
@@ -296,7 +311,7 @@ This is a `noop` if the css class is already assigned.
296
311
 
297
312
  ```ruby
298
313
  cable_ready["MyChannel"].add_css_class(
299
- selector: "string", # required - string containing one or more CSS selectors separated by commas
314
+ selector: "string", # required - string containing a CSS selector or XPath expression
300
315
  name: "string" # [null] - the CSS class to add
301
316
  )
302
317
 
@@ -313,7 +328,7 @@ Removes a css class from an element.
313
328
 
314
329
  ```ruby
315
330
  cable_ready["MyChannel"].add_css_class(
316
- selector: "string", # required - string containing one or more CSS selectors separated by commas
331
+ selector: "string", # required - string containing a CSS selector or XPath expression
317
332
  name: "string" # [null] - the CSS class to remove
318
333
  )
319
334
  ```
@@ -331,7 +346,7 @@ Sets an dataset property (data-* attribute) on an element.
331
346
 
332
347
  ```ruby
333
348
  cable_ready["MyChannel"].set_dataset_property(
334
- selector: "string", # required - string containing one or more CSS selectors separated by commas
349
+ selector: "string", # required - string containing a CSS selector or XPath expression
335
350
  name: "string", # required - the property to set
336
351
  value: "string" # [null] - the value to assign to the dataset
337
352
  )
@@ -344,8 +359,22 @@ cable_ready["MyChannel"].set_dataset_property(
344
359
 
345
360
  ## JavaScript Development
346
361
 
347
- ```sh
348
- cd /path/to/cable_ready/javascript
349
- vim ./cable_ready.js
350
- yarn publish
351
- ```
362
+ Please run `bin/standardize` on your codebase before submitting commits.
363
+
364
+ ## Contributing
365
+
366
+ This project uses [Standard](https://github.com/testdouble/standard)
367
+ and [Prettier](https://github.com/prettier/prettier) to minimize bike shedding related to code formatting.
368
+ Please run `./bin/standardize` prior submitting pull requests.
369
+
370
+ ### Releasing
371
+
372
+ 1. Bump version number at `lib/cable_ready/version.rb`
373
+ 1. Run `rake build`
374
+ 1. Run `rake release`
375
+ 1. Change directories `cd ./javascript`
376
+ 1. Run `yarn publish` - NOTE: this will throw a fatal error because the tag already exists but the package will still publish
377
+
378
+ ## License
379
+
380
+ CableReady is released under the [MIT License](LICENSE.txt).
data/Rakefile CHANGED
@@ -3,5 +3,5 @@ require "bundler/gem_tasks"
3
3
  task default: [:test]
4
4
 
5
5
  task :test do
6
- exec "bundle exec pry-test --disable-pry"
6
+ puts "Please write some tests..."
7
7
  end
@@ -1,3 +1,4 @@
1
1
  #!/bin/bash
2
2
 
3
3
  bundle exec standardrb --fix
4
+ cd ./javascript && yarn run prettier --write cable_ready.js
@@ -1,3 +1,3 @@
1
1
  module CableReady
2
- VERSION = "4.0.3"
2
+ VERSION = "4.0.4"
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.3
4
+ version: 4.0.4
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-08-17 00:00:00.000000000 Z
11
+ date: 2019-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails