birdel 3.1.0 β 3.2.0
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.
- checksums.yaml +4 -4
- data/README.md +26 -236
- data/lib/birdel/rona/rona_actor.rb +7 -1
- data/lib/birdel/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7f141c3d5be51f76b78a748d5521d24a7f1921e2eb0a6167490c4706a3dd925
|
4
|
+
data.tar.gz: 510744019aa67d13ced99d9ead12b65e415412c5e19065b68bdb52442e0e9cda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45de59d0371824a3d04928e9b29a11c58aeb194389178ec70e7f2baf4d124d8a8f2cb63b928e56d72e6755f723b5b160ad74607a60fe3510966891fcf2e6bbf2
|
7
|
+
data.tar.gz: f17fd2d63c274875b715ebb1cd0c937d2f17f7190fa31771dbc0b2723a5ac79aeb739f4acfdde073aa9953fbd878ea6fae9a3844f2bbbea357c34c9e34ee3c4f
|
data/README.md
CHANGED
@@ -1,242 +1,32 @@
|
|
1
1
|
# Birdel - microframework for rails
|
2
|
-
The new coding way to server<->client speaking and assets management
|
3
|
-
## π£οΈ Rona
|
4
|
-
This module proces JSON request and send inputs to actor method. Inside actor method you can write your custom code and response some output values. If request has required_component field - Rona module will authomatically render that component by passing outputs values to this component.
|
5
|
-
|
6
|
-
### Rona usage example
|
7
|
-
|
8
|
-
```js
|
9
|
-
// Birdel.js request
|
10
|
-
window.Birdel.send({
|
11
|
-
"actor": "ui__sunny_squirrel_actor",
|
12
|
-
"method": "get_article",
|
13
|
-
"required_component": "home--article-component",
|
14
|
-
"inputs": {
|
15
|
-
"articleId": 69
|
16
|
-
},
|
17
|
-
"callback": {
|
18
|
-
"component": "home--articles-component",
|
19
|
-
"actor": "articles-component-actor",
|
20
|
-
"method": "renderArticle",
|
21
|
-
"resource_id": false
|
22
|
-
}
|
23
|
-
});
|
24
|
-
|
25
|
-
//Response example
|
26
|
-
{
|
27
|
-
"ok": true,
|
28
|
-
"message": "Rendered article",
|
29
|
-
"data": {
|
30
|
-
"actor": "ui__sunny_squirrel_actor",
|
31
|
-
"method": "get_article",
|
32
|
-
"outputs": {
|
33
|
-
"article": {id:...}
|
34
|
-
},
|
35
|
-
"html": "<div>My Article component html</div>",
|
36
|
-
},
|
37
|
-
"callback": {
|
38
|
-
"component": "home--articles-component",
|
39
|
-
"actor": "articles-component-actor",
|
40
|
-
"method": "renderArticle",
|
41
|
-
"resource_id": false
|
42
|
-
}
|
43
|
-
}
|
44
|
-
```
|
45
|
-
|
46
|
-
```js
|
47
|
-
// Birdel.js Direct request
|
48
|
-
window.Birdel.sendDirect({
|
49
|
-
"required_component": "home--confirm-modal-component",
|
50
|
-
"inputs": {
|
51
|
-
"confirmMessage": "Are you sure?"
|
52
|
-
},
|
53
|
-
"callback": {
|
54
|
-
"component": "home--modals-component",
|
55
|
-
"actor": "modals-component-actor",
|
56
|
-
"method": "appendModal",
|
57
|
-
"resource_id": false
|
58
|
-
}
|
59
|
-
});
|
60
|
-
|
61
|
-
//Response example
|
62
|
-
{
|
63
|
-
"ok": true,
|
64
|
-
"message": "Actor Direct",
|
65
|
-
"data": {
|
66
|
-
"outputs": {
|
67
|
-
"confirmMessage": "Are you sure?"
|
68
|
-
},
|
69
|
-
"html": "<div>My confirmation modal component html</div>",
|
70
|
-
},
|
71
|
-
"callback": {
|
72
|
-
"component": "home--articles-component",
|
73
|
-
"actor": "articles-component-actor",
|
74
|
-
"method": "renderArticle",
|
75
|
-
"resource_id": false
|
76
|
-
}
|
77
|
-
}
|
78
|
-
```
|
79
|
-
|
80
|
-
|
81
|
-
```ruby
|
82
|
-
# Actor processor
|
83
|
-
class SunnySquirrelActor::SunnySquirrelActor
|
84
|
-
def get_article(inputs, current_user)
|
85
|
-
article_id = inputs.fetch("articleId")
|
86
|
-
article = Article.find_by(id: cupboard_id)
|
87
|
-
return {ok: false, message: "Article not found", outputs: {}} unless article
|
88
|
-
return {ok: true, message: "Article", outputs: {article: article}}
|
89
|
-
end
|
90
|
-
end
|
91
|
-
```
|
92
|
-
|
93
|
-
```ruby
|
94
|
-
#Your main channel for current entry page
|
95
|
-
class HomeChannel < ApplicationCable::Channel
|
96
|
-
state_attr_accessor :first_stream
|
97
|
-
include Birdel::Rona
|
98
|
-
|
99
|
-
def subscribed
|
100
|
-
self.first_stream = "#{params[:channel]}_#{params[:id]}"
|
101
|
-
stream_from self.first_stream
|
102
|
-
end
|
103
|
-
end
|
104
|
-
```
|
105
|
-
|
106
|
-
## Blah Blah Blah
|
107
|
-
|
108
|
-
- [ ] Cif - Chain of Responsibility pattern
|
109
|
-
- [x] Components generator
|
110
|
-
- [ ] Actors generator
|
111
|
-
- [ ] Actors specifications
|
112
|
-
- [x] Synth - rewrite CSS ans JS indexes
|
113
|
-
- [x] Map - generate entry page
|
114
|
-
|
115
|
-
## π Map
|
116
|
-
|
117
|
-
Entry pages indexes generator module
|
118
2
|
|
3
|
+
Generate component
|
119
4
|
```bash
|
120
|
-
$ birdel
|
121
|
-
# + app/assets/stylesheets/ui/bentries/home/components.css.json
|
122
|
-
# + app/assets/stylesheets/ui/bentries/home/precomponents.css.json
|
123
|
-
# + app/assets/stylesheets/ui/bentries/home/components.css
|
124
|
-
# + app/assets/stylesheets/ui/bentries/home/precomponents.css
|
125
|
-
# + app/assets/stylesheets/ui/bentries/home/index.css
|
126
|
-
|
127
|
-
# + app/javascript/ui/bentries/home/components.js.json
|
128
|
-
# + app/javascript/ui/bentries/home/components.js
|
129
|
-
# + app/javascript/ui/bentries/home/index.js
|
130
|
-
|
131
|
-
# + app/viewslayouts/ui/bentries/home/index.html.erb
|
5
|
+
$ birdel gcom Ui::Bentries::Home::HomeComponent
|
132
6
|
```
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
# Css structure
|
137
|
-
app/
|
138
|
-
ββ assets/
|
139
|
-
β ββ stylesheets/
|
140
|
-
β β ββ ui/
|
141
|
-
β β β ββ bentries/
|
142
|
-
β β β β ββ some_page/
|
143
|
-
β β β β β ββ index.css
|
144
|
-
β β β β β ββ components.css
|
145
|
-
β β β β β ββ precomponents.css.json
|
146
|
-
β β β β β ββ components.css.json
|
147
|
-
|
148
|
-
# Javascript structure
|
149
|
-
ββ javascript/
|
150
|
-
β ββ ui/
|
151
|
-
β β ββ bentries/
|
152
|
-
β β β ββ some_page/
|
153
|
-
β β β β ββ index.js
|
154
|
-
β β β β ββ components.js
|
155
|
-
β β β β ββ components.js.json
|
156
|
-
|
157
|
-
# Actors structure
|
158
|
-
app/
|
159
|
-
ββ ui/
|
160
|
-
β ββ bactors/
|
161
|
-
β β ββ angry_cat_actor/
|
162
|
-
β β β ββ angry_cat_actor.rb
|
163
|
-
|
164
|
-
# Component structure random example
|
165
|
-
app/
|
166
|
-
ββ ui/
|
167
|
-
β ββ bentries/
|
168
|
-
β β ββ home/
|
169
|
-
β β β ββ home_component/
|
170
|
-
β β β β ββ home_component.rb
|
171
|
-
β β β β ββ home_component.js
|
172
|
-
β β β β ββ home_component.css
|
173
|
-
β β β β ββ home_component_controller.js
|
174
|
-
β β β β ββ home_component_actor.js
|
175
|
-
β ββ mix/
|
176
|
-
β β ββ home/
|
177
|
-
β β β ββ top_bar_component/
|
178
|
-
β β β β ββ top_bar_component.rb
|
179
|
-
β β β β ββ top_bar_component.js
|
180
|
-
β β β β ββ top_bar_component.css
|
181
|
-
β β β β ββ top_bar_component_controller.js
|
182
|
-
β β β β ββ top_bar_component_actor.js
|
7
|
+
Generate entry
|
8
|
+
```bash
|
9
|
+
$ birdel gent Home
|
183
10
|
```
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
```ruby
|
188
|
-
# app/assets/stylesheets/ui/home/precomponents.json
|
189
|
-
|
190
|
-
[
|
191
|
-
"ui/birdel/dropdown",
|
192
|
-
"ui/birdel/layout"
|
193
|
-
]
|
194
|
-
|
195
|
-
# app/assets/stylesheets/ui/home/components.css.json
|
196
|
-
[
|
197
|
-
"ui/bentries/home/home_component/home_component",
|
198
|
-
"ui/mix/home/mini_product_component/mini_product_component"
|
199
|
-
]
|
200
|
-
|
201
|
-
# app/views/layouts/ui/bentries/home/index.html.erb
|
202
|
-
...
|
203
|
-
<%= stylesheet_link_tag "ui/bentries/home/index", "data-turbo-track": "reload" %>
|
204
|
-
<%= javascript_include_tag "ui/bentries/home/index", "data-turbo-track": "reload", defer: true, type: "module" %>
|
205
|
-
...
|
11
|
+
Sync css and js
|
12
|
+
```bash
|
13
|
+
$ birdel synth
|
206
14
|
```
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
[
|
226
|
-
{ name: "order_id", type: "integer" },
|
227
|
-
{ name: "total_amount", type: "float" }
|
228
|
-
]
|
229
|
-
end
|
230
|
-
|
231
|
-
def methods
|
232
|
-
[
|
233
|
-
{ name: "process_order", input: ["customer", "items"], output: ["order_id", "total_amount"] }
|
234
|
-
]
|
235
|
-
end
|
236
|
-
|
237
|
-
def msg_valid?
|
238
|
-
@msg[:inputs]&.keys.to_set == inputs.map { |i| i[:name] }.to_set &&
|
239
|
-
inputs.all? { |i| @msg[:inputs][i[:name]].is_a?(i[:type].camelize.constantize) }
|
240
|
-
end
|
241
|
-
end
|
242
|
-
```
|
15
|
+
Send request
|
16
|
+
```js
|
17
|
+
window.Birdel.actor("ui__angry_cat_actor")
|
18
|
+
.method("get_article")
|
19
|
+
.required_component("ui--mix--article-component") // or false
|
20
|
+
.inputs({
|
21
|
+
articleId: 69
|
22
|
+
})
|
23
|
+
.callback({
|
24
|
+
"component": "ui--entries--home-component",
|
25
|
+
"actor": "home-component-actor",
|
26
|
+
"method": "showArticle",
|
27
|
+
"resource_id": false //or ID of your actor
|
28
|
+
})
|
29
|
+
.send()
|
30
|
+
```
|
31
|
+
|
32
|
+
Full documentation is not ready and will be at https://digitalthing.io/docs/birdel, well, sorryπ
|
@@ -28,7 +28,13 @@ module Birdel
|
|
28
28
|
end
|
29
29
|
if callback
|
30
30
|
res[:callback] = callback
|
31
|
-
|
31
|
+
# first - check if Actor method returned specific resource_id
|
32
|
+
# otherwise - set resource_id from callback if it exists or set false
|
33
|
+
if method_res[:resource_id].present?
|
34
|
+
res[:callback][:resourceId] = method_res[:resource_id]
|
35
|
+
else
|
36
|
+
res[:callback][:resourceId] = callback[:resourceId].present? ? callback[:resourceId] : false
|
37
|
+
end
|
32
38
|
ActionCable.server.broadcast(self.first_stream, res)
|
33
39
|
end
|
34
40
|
end
|
data/lib/birdel/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: birdel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serhii
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Send json messages to your actors and get view_components back! Now you
|
14
14
|
can be sure that your actors are processed correctly.
|