birdel 3.1.1 β†’ 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: 0d8dc0e1d0da67142ec9296c5e70777e05d9f8b87d28d6b21756b936b4cc1a84
4
- data.tar.gz: d77fbe9c10748d5e0bc2fe9b2742c4d28850284547d5ba7fbe0c9a625e8dffb8
3
+ metadata.gz: e7f141c3d5be51f76b78a748d5521d24a7f1921e2eb0a6167490c4706a3dd925
4
+ data.tar.gz: 510744019aa67d13ced99d9ead12b65e415412c5e19065b68bdb52442e0e9cda
5
5
  SHA512:
6
- metadata.gz: 4ee6adc2be2799c44781375f11a3eecc1aa47624950a1fff35c6b18e3bb07f5ab4bea04d374e3fe35549f13655979393d9fa19a5e4951f75d5d968cd63aba9fe
7
- data.tar.gz: 32e59e1b6d4e11e8ca800c0cf29f7185bb35c401a1e2240dfc86ac09f35f278789b9dd230a9506335659ca5833f661795df5b119cb792b2fa345c3afb4d26327
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πŸ˜„
@@ -33,7 +33,7 @@ module Birdel
33
33
  if method_res[:resource_id].present?
34
34
  res[:callback][:resourceId] = method_res[:resource_id]
35
35
  else
36
- res[:callback][:resourceId] = callback[:resource_id].present? ? callback[:resource_id] : false
36
+ res[:callback][:resourceId] = callback[:resourceId].present? ? callback[:resourceId] : false
37
37
  end
38
38
  ActionCable.server.broadcast(self.first_stream, res)
39
39
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Birdel
4
- VERSION = "3.1.1"
4
+ VERSION = "3.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: birdel
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serhii