cable_streams 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 57ca136e081b470c8cafb90704ed1076d05ccadcfb667bd08121ee82e4bee991
4
+ data.tar.gz: f71a6dc50129583580751c7a08c9edb152a60ad43c1e584f97ce49b8fb893313
5
+ SHA512:
6
+ metadata.gz: 88b893edb4714b78eead519089cac8bc8a7053fa55902d61f91ccf7c2e2689bdb9e1756d198d2641c8ad1e66b1f6f5a2a1e2fde0ee5ffd7468f542192fbceb4c
7
+ data.tar.gz: e148b44f0fc42c803563bac8a807c0af3e4263dcc271774e8f8f52bf7b02c6cc5f221ee8b7c2713d8f4f281997e7bafb5eef0e322ead2d92cc6161ed4a950179
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ ## CableStreams Rails
2
+
3
+ This is a Rails helper gem for the [`cable-streams`](https://github.com/marcoroth/cable-streams) NPM package. CableStreams extends Turbo Streams with Custom Turbo Stream Actions and all CableReady operations.
4
+
5
+ ### Installation
6
+
7
+ ```bash
8
+ bundle add cable_streams
9
+ ```
10
+
11
+ ### Using the Tag Helpers
12
+
13
+ The `cable_streams` gem ships view helpers for all CableReady operations. All options are identical to [the regular CableReady operations](https://cableready.stimulusreflex.com/v/v5/reference/operations).
14
+
15
+ Here's an example of the `console_log` operation:
16
+
17
+ ```html+erb
18
+ <%= turbo_stream.console_log(message: "hello world") %>
19
+ ```
20
+
21
+ Which renders to:
22
+ ```html
23
+ <turbo-stream action="consoleLog" target="body">
24
+ <template>
25
+ [
26
+ { "message": "hello world", "operation": "consoleLog" }
27
+ ]
28
+ </template>
29
+ </turbo-stream>
30
+ ```
@@ -0,0 +1,23 @@
1
+ require "cable_ready"
2
+ require "turbo-rails"
3
+
4
+ module CableStreams
5
+ module Streams
6
+ module ActionHelper
7
+ include CableReady::Broadcaster
8
+
9
+ IGNORE_LIST = [:after, :append, :before, :prepend, :remove, :replace, :update]
10
+
11
+ (CableReady.config.operation_names - IGNORE_LIST).each do |name|
12
+ define_method(name) do |args|
13
+ operation = cable_car.send(name, args).dispatch.to_json
14
+ target = (args.to_h.pluck(:selector) || 'body') rescue "body"
15
+
16
+ turbo_stream_action_tag name.to_s.camelize(:lower), target: target, template: operation
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ Turbo::Streams::TagBuilder.prepend(CableStreams::Streams::ActionHelper)
@@ -0,0 +1,6 @@
1
+ require "rails/engine"
2
+
3
+ module CableStreams
4
+ class Engine < Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module CableStreams
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,4 @@
1
+ require "cable_streams/engine"
2
+
3
+ module CableStreams
4
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cable_streams
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Marco Roth
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-04-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionpack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 6.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 6.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: railties
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 6.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 6.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: cable_ready
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 5.0.0.pre9
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 5.0.0.pre9
55
+ - !ruby/object:Gem::Dependency
56
+ name: turbo-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email: marco.roth@hey.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - README.md
76
+ - app/helpers/cable_streams/streams/action_helper.rb
77
+ - lib/cable_streams.rb
78
+ - lib/cable_streams/engine.rb
79
+ - lib/cable_streams/version.rb
80
+ homepage: https://github.com/marcoroth/cable-streams-rails
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 2.6.0
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubygems_version: 3.3.3
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: Extend Turbo Streams with Custom Turbo Stream Actions or CableReady operations
103
+ test_files: []