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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db9122f08319c04ac5b369965004710158895525de8b4cd5318a217e6ffaebb8
4
- data.tar.gz: 71e3290a92de20a8b7fa7def761759b9d706a400e06238f3d4e252a43c323277
3
+ metadata.gz: e7f141c3d5be51f76b78a748d5521d24a7f1921e2eb0a6167490c4706a3dd925
4
+ data.tar.gz: 510744019aa67d13ced99d9ead12b65e415412c5e19065b68bdb52442e0e9cda
5
5
  SHA512:
6
- metadata.gz: ef39b27f0398e92ce27544077907575070f096e283dc27187c3461a6ce3a7350f7dc8a5a285b792d0354d427bea053949a13c5ec9afcb821a5b3ac227cc1c00d
7
- data.tar.gz: 07ab2b7fea19fe05454fbb521719fcde95d4039a48be01f43bdc480176630ee88671c057e006e581529d6050ac15e8ce065379617d45d7da66ca6d869fbad1cf
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 map Ui::Bentries::Home
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
- ### Visualized files structure
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
- ## Actor Specification example
209
-
210
- ```ruby
211
- class AngryCatActor::AngryCatActorSpecification
212
- def initialize(msg)
213
- parsed_msg = JSON.parse(msg)
214
- @msg = parsed_msg.transform_keys(&:to_sym)
215
- end
216
-
217
- def inputs
218
- [
219
- { name: "customer", type: "string" },
220
- { name: "items", type: "array" }
221
- ]
222
- end
223
-
224
- def outputs
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
- res[:callback][:resourceId] = method_res[:resource_id].present? ? method_res[:resource_id] : false
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Birdel
4
- VERSION = "3.1.0"
4
+ VERSION = "3.2.0"
5
5
  end
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.1.0
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-05-15 00:00:00.000000000 Z
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.