birdel 0.3.2 → 0.3.3
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 +174 -112
- data/lib/birdel/rona/rona_actor.rb +20 -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: 21efe23c6887077f40706fef43acca2ec2f963b5ca4d7e7b891c200f0b6962b7
|
4
|
+
data.tar.gz: 689f618982ec571ff2122a547c02f4eac43a1d61bcd6f6e168e908c2316d3007
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6258f33135d6ecaabb03786a0b2957967466555406eccb72019028ceabcc87afdde7a577c5b5f43f25eaee0f359b166008eb33610f967d67af0f32f75a3aefd
|
7
|
+
data.tar.gz: 47e43042afb020d52cb00843da62bb9f91cdd41b8f150f99a22f41cb780fd26d66b6a275cda7e1a94d2ee8ced22cea4b1858181f3a69ce6230cc75a83852e2ed
|
data/README.md
CHANGED
@@ -1,146 +1,208 @@
|
|
1
|
-
# Birdel -
|
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
|
+
```
|
2
45
|
|
3
|
-
|
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
|
+
```
|
4
79
|
|
5
|
-
## 🛣️ Rona - resolve request/respond
|
6
80
|
|
7
|
-
|
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
|
+
```
|
8
92
|
|
9
|
-
|
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
|
+
```
|
10
105
|
|
11
|
-
|
106
|
+
## Blah Blah Blah
|
12
107
|
|
13
|
-
|
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
|
14
114
|
|
15
|
-
|
115
|
+
## 📝 Map
|
16
116
|
|
17
|
-
|
18
|
-
# Nested namespace example
|
19
|
-
$ birdel act Ui::AngryCatActor
|
20
|
-
```
|
117
|
+
Entry pages indexes generator module
|
21
118
|
|
22
|
-
```
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
```
|
119
|
+
```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
|
30
126
|
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
34
130
|
|
35
|
-
|
36
|
-
app/
|
37
|
-
├─ components/
|
38
|
-
│ ├─ ui/
|
39
|
-
│ │ ├─ top_bar_component/
|
40
|
-
│ │ │ ├─ top_bar_component.rb
|
41
|
-
│ │ │ ├─ top_bar_component.js
|
42
|
-
│ │ │ ├─ top_bar_component.css
|
43
|
-
│ │ │ ├─ top_bar_component_controller.js
|
44
|
-
│ │ │ └─ top_bar_component_actor.js
|
131
|
+
# + app/viewslayouts/ui/bentries/home/index.html.erb
|
45
132
|
```
|
46
133
|
|
47
|
-
|
48
|
-
|
49
|
-
You should store your entries same to this:
|
134
|
+
### Visualized files structure
|
50
135
|
```
|
136
|
+
# Css structure
|
51
137
|
app/
|
52
138
|
├─ assets/
|
53
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/
|
54
151
|
│ │ ├─ bentries/
|
55
|
-
│ │ │ ├─ home/
|
56
|
-
│ │ │ │ ├─ index.css
|
57
|
-
│ │ │ │ ├─ components.css
|
58
|
-
│ │ │ │ ├─ precomponents.json
|
59
|
-
│ │ │ │ └─ components.json
|
60
152
|
│ │ │ ├─ some_page/
|
61
|
-
│ │ │ │ ├─ index.
|
62
|
-
│ │ │ │ ├─ components.
|
63
|
-
│ │ │ │
|
64
|
-
│ │ │ │ └─ components.json
|
153
|
+
│ │ │ │ ├─ index.js
|
154
|
+
│ │ │ │ ├─ components.js
|
155
|
+
│ │ │ │ └─ components.js.json
|
65
156
|
|
66
|
-
#
|
67
|
-
|
157
|
+
# Actors structure
|
158
|
+
app/
|
159
|
+
├─ ui/
|
160
|
+
│ ├─ bactors/
|
161
|
+
│ │ ├─ angry_cat_actor/
|
162
|
+
│ │ │ └─ angry_cat_actor.rb
|
68
163
|
|
69
|
-
|
70
|
-
|
71
|
-
|
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
|
72
183
|
```
|
73
184
|
|
74
|
-
|
75
|
-
|
185
|
+
|
186
|
+
|
187
|
+
```ruby
|
188
|
+
# app/assets/stylesheets/ui/home/precomponents.json
|
76
189
|
|
77
190
|
[
|
78
|
-
"ui/birdel/
|
191
|
+
"ui/birdel/dropdown",
|
79
192
|
"ui/birdel/layout"
|
80
193
|
]
|
81
194
|
|
82
|
-
# components.json
|
195
|
+
# app/assets/stylesheets/ui/home/components.css.json
|
83
196
|
[
|
84
|
-
"ui/bentries/home_component/home_component",
|
85
|
-
"ui/mix/mini_product_component/mini_product_component"
|
197
|
+
"ui/bentries/home/home_component/home_component",
|
198
|
+
"ui/mix/home/mini_product_component/mini_product_component"
|
86
199
|
]
|
87
|
-
```
|
88
|
-
|
89
|
-
## 📜 Request/Response specifications
|
90
200
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
"method": "process_order",
|
97
|
-
"required_component": "ui--bars--top-bar-component",
|
98
|
-
"inputs": {
|
99
|
-
"customer": "John Doe",
|
100
|
-
"items": [
|
101
|
-
{ "name": "Milk", "price": 1.5 },
|
102
|
-
{ "name": "Bread", "price": 2.5 }
|
103
|
-
]
|
104
|
-
},
|
105
|
-
"callback": {
|
106
|
-
"actor": "angry_swallow_actor",
|
107
|
-
"method": "process_bla",
|
108
|
-
"inputs": {
|
109
|
-
"customer": "John Doe",
|
110
|
-
"items": [
|
111
|
-
{ "name": "Milk", "price": 1.5 },
|
112
|
-
{ "name": "Bread", "price": 2.5 }
|
113
|
-
]
|
114
|
-
}
|
115
|
-
}
|
116
|
-
}
|
117
|
-
|
118
|
-
#Response
|
119
|
-
{
|
120
|
-
"ok": true,
|
121
|
-
"message": "Order processed successfully",
|
122
|
-
"data": {
|
123
|
-
"actor": "angry_cat_actor",
|
124
|
-
"method": "process_order",
|
125
|
-
"outputs": {
|
126
|
-
"order_id": 1234,
|
127
|
-
"total_amount": 4.0,
|
128
|
-
},
|
129
|
-
"html": "<div></div>",
|
130
|
-
}
|
131
|
-
}
|
132
|
-
```
|
133
|
-
|
134
|
-
## Actor
|
135
|
-
|
136
|
-
```ruby
|
137
|
-
class AngryCatActor::AngryCatActor < Birdel::BaseActor
|
138
|
-
def initialize()
|
139
|
-
end
|
140
|
-
def process_order
|
141
|
-
|
142
|
-
end
|
143
|
-
end
|
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
|
+
...
|
144
206
|
```
|
145
207
|
|
146
208
|
## Actor Specification example
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Routing Overlay Network Actor
|
2
2
|
module Birdel
|
3
3
|
module Rona
|
4
|
-
def
|
4
|
+
def actorThrough(data)
|
5
5
|
actor_name = data.fetch("actor")
|
6
6
|
inputs = data.fetch("inputs")
|
7
7
|
callback = data.fetch("callback")
|
@@ -32,5 +32,24 @@ module Birdel
|
|
32
32
|
ActionCable.server.broadcast(self.first_stream, res)
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
def actorDirect(data)
|
37
|
+
inputs = data.fetch("inputs")
|
38
|
+
callback = data.fetch("callback")
|
39
|
+
required_component = data.fetch("required_component")
|
40
|
+
component_name = required_component.split('--').map{|i| i.gsub("-", "_").camelize}.join('::') + '::' + required_component.split('--').last.gsub("-", "_").camelize
|
41
|
+
component = component_name.constantize.new(inputs: inputs)
|
42
|
+
res = {
|
43
|
+
"ok": true,
|
44
|
+
"message": "Actor Direct",
|
45
|
+
"data": {
|
46
|
+
"outputs": inputs,
|
47
|
+
"html": ApplicationController.render(component, layout: false)
|
48
|
+
}
|
49
|
+
}
|
50
|
+
res[:callback] = callback
|
51
|
+
res[:callback][:resourceId] = method_res[:resource_id] if method_res[:resource_id]
|
52
|
+
ActionCable.server.broadcast(self.first_stream, res)
|
53
|
+
end
|
35
54
|
end
|
36
55
|
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: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serhii
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03
|
11
|
+
date: 2023-05-03 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.
|