cable_ready 3.0.1 → 4.0.0

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: 0afe729d16f2eb1a30dbca2a72a3cf76f48162e5ec9629a9776f7e0c2f6f529c
4
- data.tar.gz: 16c548eb1197af15b8dff9410156edf8b8f200c1f81ea5ab8b984594b9293af6
3
+ metadata.gz: 73065e8ab511c51935a0132b5431ef753bbe42b299ea0312ee2e2d7fae3d96b3
4
+ data.tar.gz: 390d8ce6658cab338bfa9df8984225d56040f6d1d69c2064abf46d06fd30dd92
5
5
  SHA512:
6
- metadata.gz: bbf0d1114a8fc4ea78923caa2d53565c210d01f1b4e4268f956b99c8c16cb9528208bb1bc579c6772b148357fcb754236166bb2ac20a65897c4f253622e0073f
7
- data.tar.gz: 6370fae04446a42f4f422a59ba41ad395ab5a9114369329792cdba88521e533487eceacf98791547c67ad4c385f29225a831a832427704f9faf793426af5b01a
6
+ metadata.gz: ea5513eb0cdddbeec39d38228b5d294c97152a77801b8d1b21dc8653544bb20bd498b41800e7fd404315fae4b46771d9e6d934776ee8d32e17959cf3b334596b
7
+ data.tar.gz: 62fcb32d1bf01a74dafa6bd6a6573f02caf55ee2756bd9a58e153c93a86ec52b6d34fb3f4914a177bf3f200d42c7ecee643dbafb6b986b66cdd4bd31c39102e3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cable_ready (3.0.1)
4
+ cable_ready (4.0.0)
5
5
  activesupport (>= 5.0.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
- [![Lines of Code](http://img.shields.io/badge/lines_of_code-238-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
2
- [![Code Status](https://img.shields.io/codeclimate/maintainability/hopsoft/cable_ready.svg?style=flat)](https://codeclimate.com/github/hopsoft/cable_ready)
1
+ [![Lines of Code](http://img.shields.io/badge/lines_of_code-118-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
2
+ [![Maintainability](https://api.codeclimate.com/v1/badges/83ddf1fee4af7e51a681/maintainability)](https://codeclimate.com/github/hopsoft/cable_ready/maintainability)
3
3
  [![Ruby Dependency Graph](https://img.shields.io/badge/deps-ruby-informational.svg?style=flat)](https://github.com/hopsoft/cable_ready/blob/master/gem_graph.svg)
4
4
  [![JavaScript Dependency Graph](https://img.shields.io/badge/deps-javascript-informational.svg?style=flat)](https://github.com/hopsoft/cable_ready/blob/master/javascript_graph.txt)
5
5
 
@@ -10,23 +10,30 @@
10
10
  CableReady provides a simple interface for triggering client-side DOM operations
11
11
  from the server via [ActionCable](http://guides.rubyonrails.org/action_cable_overview.html).
12
12
 
13
- ## Quick Start
13
+ Please read the official [ActionCable docs](http://guides.rubyonrails.org/action_cable_overview.html)
14
+ to learn more about ActionCable before proceeding.
14
15
 
15
- > Please read the official [ActionCable docs](http://guides.rubyonrails.org/action_cable_overview.html) to learn more about ActionCable before proceeding.
16
+ ## Setup
17
+
18
+ ### JavaScript
19
+
20
+ ```
21
+ yarn install cable_ready
22
+ ```
23
+
24
+ ### Gemfile
16
25
 
17
26
  ```ruby
18
- # Gemfile
19
27
  gem "cable_ready"
20
28
  ```
21
29
 
22
- ```javascript
23
- // app/assets/javascripts/cable.js
24
- //= require action_cable
25
- //= require cable_ready
26
- ```
30
+ ## Usage
31
+
32
+ ### app/assets/javascripts/channels/user.js
27
33
 
28
34
  ```javascript
29
- // app/assets/javascripts/channels/user.js
35
+ import CableReady from 'cable_ready';
36
+
30
37
  App.cable.subscriptions.create({ channel: "UserChannel" }, {
31
38
  received: function (data) {
32
39
  if (data.cableReady) {
@@ -36,8 +43,9 @@ App.cable.subscriptions.create({ channel: "UserChannel" }, {
36
43
  });
37
44
  ```
38
45
 
46
+ ### app/models/user.rb
47
+
39
48
  ```ruby
40
- # app/models/user.rb
41
49
  class User < ApplicationRecord
42
50
  include CableReady::Broadcaster
43
51
 
@@ -48,9 +56,6 @@ class User < ApplicationRecord
48
56
  end
49
57
  ```
50
58
 
51
- See [CableReady TodoMVC](https://github.com/hopsoft/cable_ready_todomvc)
52
- for a more complete reference implementation.
53
-
54
59
  ## Supported DOM Operations
55
60
 
56
61
  - [dispatchEvent](#dispatchevent)
@@ -341,11 +346,4 @@ cable_ready["MyChannel"].set_dataset_property(
341
346
 
342
347
  ## JavaScript Development
343
348
 
344
- The JavaScript source is located in `app/assets/javascripts/cable_ready/src`
345
- & transpiles to `app/assets/javascripts/cable_ready.js` via Webpack.
346
-
347
- ```sh
348
- # build javascript
349
- ./bin/yarn
350
- ./bin/webpack
351
- ```
349
+ The JavaScript library is hosted at: https://github.com/hopsoft/cable_ready
data/bin/deps CHANGED
@@ -1,5 +1,3 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  bundle viz --version --format svg --without development test
4
- cd ./app/assets/javascripts/cable_ready/src
5
- yarn list -s --prod > ../../../../../javascript_graph.txt
data/bin/standardize CHANGED
@@ -1,4 +1,3 @@
1
1
  #!/bin/bash
2
2
 
3
3
  bundle exec standardrb --fix
4
- prettier --no-config --single-quote --trailing-comma es5 --write app/assets/javascripts/cable_ready/src/*.js
@@ -1,3 +1,3 @@
1
1
  module CableReady
2
- VERSION = "3.0.1"
2
+ VERSION = "4.0.0"
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: 3.0.1
4
+ version: 4.0.0
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-05-13 00:00:00.000000000 Z
11
+ date: 2019-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -78,14 +78,10 @@ files:
78
78
  - LICENSE.txt
79
79
  - README.md
80
80
  - Rakefile
81
- - app/assets/javascripts/cable_ready.js
82
- - bin/cloc
83
81
  - bin/console
84
82
  - bin/deps
85
83
  - bin/setup
86
84
  - bin/standardize
87
- - bin/webpack
88
- - bin/yarn
89
85
  - lib/cable_ready.rb
90
86
  - lib/cable_ready/broadcaster.rb
91
87
  - lib/cable_ready/channel.rb
@@ -1 +0,0 @@
1
- window.CableReady=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";var n;r.r(t);var o="http://www.w3.org/1999/xhtml",a="undefined"==typeof document?void 0:document;function c(e,t){var r=e.nodeName,n=t.nodeName;return r===n||!!(t.actualize&&r.charCodeAt(0)<91&&n.charCodeAt(0)>90)&&r===n.toUpperCase()}function l(e,t,r){e[r]!==t[r]&&(e[r]=t[r],e[r]?e.setAttribute(r,""):e.removeAttribute(r))}var i={OPTION:function(e,t){var r=e.parentNode;if(r){var n=r.nodeName.toUpperCase();"OPTGROUP"===n&&(n=(r=r.parentNode)&&r.nodeName.toUpperCase()),"SELECT"!==n||r.hasAttribute("multiple")||(e.hasAttribute("selected")&&!t.selected&&(e.setAttribute("selected","selected"),e.removeAttribute("selected")),r.selectedIndex=-1)}l(e,t,"selected")},INPUT:function(e,t){l(e,t,"checked"),l(e,t,"disabled"),e.value!==t.value&&(e.value=t.value),t.hasAttribute("value")||e.removeAttribute("value")},TEXTAREA:function(e,t){var r=t.value;e.value!==r&&(e.value=r);var n=e.firstChild;if(n){var o=n.nodeValue;if(o==r||!r&&o==e.placeholder)return;n.nodeValue=r}},SELECT:function(e,t){if(!t.hasAttribute("multiple")){for(var r,n,o=-1,a=0,c=e.firstChild;c;)if("OPTGROUP"===(n=c.nodeName&&c.nodeName.toUpperCase()))c=(r=c).firstChild;else{if("OPTION"===n){if(c.hasAttribute("selected")){o=a;break}a++}!(c=c.nextSibling)&&r&&(c=r.nextSibling,r=null)}e.selectedIndex=o}}},u=1,d=11,f=3,s=8;function m(){}function b(e){return e.id}var v=function(e){return function(t,r,l){if(l||(l={}),"string"==typeof r)if("#document"===t.nodeName||"HTML"===t.nodeName){var v=r;(r=a.createElement("html")).innerHTML=v}else r=function(e){var t;return!n&&a.createRange&&(n=a.createRange()).selectNode(a.body),n&&n.createContextualFragment?t=n.createContextualFragment(e):(t=a.createElement("body")).innerHTML=e,t.childNodes[0]}(r);var y,p=l.getNodeKey||b,h=l.onBeforeNodeAdded||m,S=l.onNodeAdded||m,N=l.onBeforeElUpdated||m,A=l.onElUpdated||m,C=l.onBeforeNodeDiscarded||m,g=l.onNodeDiscarded||m,T=l.onBeforeElChildrenUpdated||m,x=!0===l.childrenOnly,E={};function q(e){y?y.push(e):y=[e]}function O(e,t,r){!1!==C(e)&&(t&&t.removeChild(e),g(e),function e(t,r){if(t.nodeType===u)for(var n=t.firstChild;n;){var o=void 0;r&&(o=p(n))?q(o):(g(n),n.firstChild&&e(n,r)),n=n.nextSibling}}(e,r))}function j(e){S(e);for(var t=e.firstChild;t;){var r=t.nextSibling,n=p(t);if(n){var o=E[n];o&&c(t,o)&&(t.parentNode.replaceChild(o,t),P(o,t))}j(t),t=r}}function P(n,o,l){var d=p(o);if(d&&delete E[d],!r.isSameNode||!r.isSameNode(t)){if(!l){if(!1===N(n,o))return;if(e(n,o),A(n),!1===T(n,o))return}"TEXTAREA"!==n.nodeName?function(e,t){var r,n,o,l,d,m=t.firstChild,b=e.firstChild;e:for(;m;){for(l=m.nextSibling,r=p(m);b;){if(o=b.nextSibling,m.isSameNode&&m.isSameNode(b)){m=l,b=o;continue e}n=p(b);var v=b.nodeType,y=void 0;if(v===m.nodeType&&(v===u?(r?r!==n&&((d=E[r])?o===d?y=!1:(e.insertBefore(d,b),n?q(n):O(b,e,!0),b=d):y=!1):n&&(y=!1),(y=!1!==y&&c(b,m))&&P(b,m)):v!==f&&v!=s||(y=!0,b.nodeValue!==m.nodeValue&&(b.nodeValue=m.nodeValue))),y){m=l,b=o;continue e}n?q(n):O(b,e,!0),b=o}if(r&&(d=E[r])&&c(d,m))e.appendChild(d),P(d,m);else{var S=h(m);!1!==S&&(S&&(m=S),m.actualize&&(m=m.actualize(e.ownerDocument||a)),e.appendChild(m),j(m))}m=l,b=o}!function(e,t,r){for(;t;){var n=t.nextSibling;(r=p(t))?q(r):O(t,e,!0),t=n}}(e,b,n);var N=i[e.nodeName];N&&N(e,t)}(n,o):i.TEXTAREA(n,o)}}!function e(t){if(t.nodeType===u||t.nodeType===d)for(var r=t.firstChild;r;){var n=p(r);n&&(E[n]=r),e(r),r=r.nextSibling}}(t);var U=t,R=U.nodeType,w=r.nodeType;if(!x)if(R===u)w===u?c(t,r)||(g(t),U=function(e,t){for(var r=e.firstChild;r;){var n=r.nextSibling;t.appendChild(r),r=n}return t}(t,function(e,t){return t&&t!==o?a.createElementNS(t,e):a.createElement(e)}(r.nodeName,r.namespaceURI))):U=r;else if(R===f||R===s){if(w===R)return U.nodeValue!==r.nodeValue&&(U.nodeValue=r.nodeValue),U;U=r}if(U===r)g(t);else if(P(U,r,x),y)for(var L=0,M=y.length;L<M;L++){var V=E[y[L]];V&&O(V,V.parentNode,!1)}return!x&&U!==t&&t.parentNode&&(U.actualize&&(U=U.actualize(t.ownerDocument||a)),t.parentNode.replaceChild(U,t)),U}}(function(e,t){var r,n,o,a,c,l=t.attributes;for(r=l.length-1;r>=0;--r)o=(n=l[r]).name,a=n.namespaceURI,c=n.value,a?(o=n.localName||o,e.getAttributeNS(a,o)!==c&&e.setAttributeNS(a,o,c)):e.getAttribute(o)!==c&&e.setAttribute(o,c);for(r=(l=e.attributes).length-1;r>=0;--r)!1!==(n=l[r]).specified&&(o=n.name,(a=n.namespaceURI)?(o=n.localName||o,t.hasAttributeNS(a,o)||e.removeAttributeNS(a,o)):t.hasAttribute(o)||e.removeAttribute(o))});r.d(t,"perform",function(){return h});var y=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};p.dispatchEvent({name:e,detail:t})},p={dispatchEvent:function(e){var t=document;e.selector&&(t=document.querySelector(e.selector)||document);var r=new Event(e.name);r.detail=e.detail,t.dispatchEvent(r)},morph:function(e){var t=document.createElement("template");t.innerHTML=String(e.html).trim(),y("cable-ready:before-morph",{config:e,content:t.content}),v(document.querySelector(e.selector),t.content,{childrenOnly:!!e.childrenOnly}),e.focusSelector&&document.querySelector(e.focusSelector).focus(),y("cable-ready:after-morph",{config:e,content:t.content})},innerHtml:function(e){y("cable-ready:before-inner-html",e),document.querySelector(e.selector).innerHTML=e.html,e.focusSelector&&document.querySelector(e.focusSelector).focus(),y("cable-ready:after-inner-html",e)},outerHtml:function(e){y("cable-ready:before-outer-html",e),document.querySelector(e.selector).outerHTML=e.html,e.focusSelector&&document.querySelector(e.focusSelector).focus(),y("cable-ready:after-outer-html",e)},textContent:function(e){y("cable-ready:before-text-content",e),document.querySelector(e.selector).textContent=e.text,y("cable-ready:after-text-content",e)},insertAdjacentHtml:function(e){y("cable-ready:before-insert-adjacent-html",e),document.querySelector(e.selector).insertAdjacentHTML(e.position||"beforeend",e.html),e.focusSelector&&document.querySelector(e.focusSelector).focus(),y("cable-ready:after-insert-adjacent-html",e)},insertAdjacentText:function(e){y("cable-ready:before-insert-adjacent-text",e),document.querySelector(e.querySelector).insertAdjacentText(e.position||"beforeend",e.text),y("cable-ready:after-insert-adjacent-text",e)},remove:function(e){y("cable-ready:before-remove",e),document.querySelector(e.selector).remove(),e.focusSelector&&document.querySelector(e.focusSelector).focus(),y("cable-ready:after-remove",e)},setValue:function(e){y("cable-ready:before-set-value",e),document.querySelector(e.selector).value=e.value,y("cable-ready:after-set-value",e)},setAttribute:function(e){y("cable-ready:before-set-attribute",e),document.querySelector(e.selector).setAttribute(e.name,e.value),y("cable-ready:after-set-attribute",e)},removeAttribute:function(e){y("cable-ready:before-remove-attribute",e),document.querySelector(e.selector).removeAttribute(e.name),y("cable-ready:after-remove-attribute",e)},addCssClass:function(e){y("cable-ready:before-add-css-class",e),document.querySelector(e.selector).classList.add(e.name),y("cable-ready:after-add-css-class",e)},removeCssClass:function(e){y("cable-ready:before-remove-css-class",e),document.querySelector(e.selector).classList.remove(e.name),y("cable-ready:after-remove-css-class",e)},setDatasetProperty:function(e){y("cable-ready:before-set-dataset-property",e),document.querySelector(e.selector).dataset[e.name]=e.value,y("cable-ready:after-set-dataset-property",e)}},h=function(e){for(var t in e)if(e.hasOwnProperty(t))for(var r=e[t],n=0;n<r.length;n++)try{var o=r[n];p[t](o)}catch(e){console.log("CableReady detected an error in ".concat(t,"! ").concat(e.message))}}}]);
data/bin/cloc DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- cloc lib app/assets/javascripts/cable_ready/src/index.js
data/bin/webpack DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- cd ./app/assets/javascripts/cable_ready/src
4
- ./node_modules/webpack/bin/webpack.js "$@"
data/bin/yarn DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- cd ./app/assets/javascripts/cable_ready/src
4
- yarn "$@"