ru.Bee 2.4.1 → 2.5.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/lib/db/test.db +0 -0
- data/lib/rubee/cli/command.rb +2 -2
- data/lib/rubee/cli/db.rb +38 -0
- data/lib/rubee/models/sequel_object.rb +2 -1
- data/lib/rubee.rb +1 -1
- data/lib/tests/async/thread_async_test.rb +1 -1
- data/readme.md +26 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 662d0d94e4f29f53da650705c4f04b15739ef9fc22d18e06e5f26ba9c5180a7b
|
|
4
|
+
data.tar.gz: 470c43de0b06a51164c499a83d34bdf361a9b3f9433a43d0b971395f4149494d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ab5b1e90290b4f2aefc52ca52187c8a8811d6d5e11016fbb826afb2aa119881aa4593d8d7cdc3c19c6aeb1a0a0f64695bae04897ff99dae1a2c3552b1ee1348b
|
|
7
|
+
data.tar.gz: 3bb1991be93a8cd7aedf38dad66355f79a35cdd6b0724508c4c5d8c5e951bcb457ead32edcb7cb52999550a9dd90482c50f84faaf16e613afdc73e02f5b5fce3
|
data/lib/db/test.db
CHANGED
|
Binary file
|
data/lib/rubee/cli/command.rb
CHANGED
|
@@ -18,13 +18,13 @@ module Rubee
|
|
|
18
18
|
Rubee::CLI::React
|
|
19
19
|
in /^project$/
|
|
20
20
|
Rubee::CLI::Project
|
|
21
|
-
in /^version$/
|
|
21
|
+
in /^version|v$/
|
|
22
22
|
Rubee::CLI::Version
|
|
23
23
|
in /^routes$/
|
|
24
24
|
Rubee::CLI::Routes
|
|
25
25
|
in /^test$/
|
|
26
26
|
Rubee::CLI::Test
|
|
27
|
-
in /^(generate|gen)$/
|
|
27
|
+
in /^(generate|gen|g)$/
|
|
28
28
|
Rubee::CLI::Generate
|
|
29
29
|
in /^db$/
|
|
30
30
|
Rubee::CLI::Db
|
data/lib/rubee/cli/db.rb
CHANGED
|
@@ -37,6 +37,44 @@ module Rubee
|
|
|
37
37
|
generate_structure
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
+
def schema(_argv)
|
|
41
|
+
STRUCTURE.each do |table_name, columns|
|
|
42
|
+
# Table header
|
|
43
|
+
color_puts(
|
|
44
|
+
"--- #{table_name}",
|
|
45
|
+
color: :cyan,
|
|
46
|
+
style: :bold
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
columns.each do |column_name, meta|
|
|
50
|
+
parts = []
|
|
51
|
+
|
|
52
|
+
# column name
|
|
53
|
+
col_text = "- #{column_name}"
|
|
54
|
+
parts << col_text
|
|
55
|
+
|
|
56
|
+
# PK
|
|
57
|
+
if meta[:primary_key]
|
|
58
|
+
parts << "(PK)"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# type
|
|
62
|
+
if meta[:db_type]
|
|
63
|
+
parts << "type (#{meta[:db_type]})"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
line = parts.join(", ")
|
|
67
|
+
|
|
68
|
+
color_puts(
|
|
69
|
+
line,
|
|
70
|
+
color: meta[:primary_key] ? :yellow : :gray
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
puts
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
40
78
|
private
|
|
41
79
|
|
|
42
80
|
def generate_structure
|
|
@@ -102,6 +102,7 @@ module Rubee
|
|
|
102
102
|
# > user.comments
|
|
103
103
|
# > [<comment1>, <comment2>]
|
|
104
104
|
def owns_many(assoc, fk_name: nil, over: nil, **options)
|
|
105
|
+
original_assoc = assoc
|
|
105
106
|
singularized_assoc_name = assoc.to_s.singularize
|
|
106
107
|
fk_name ||= "#{name.to_s.downcase}_id"
|
|
107
108
|
namespace = options[:namespace]
|
|
@@ -116,7 +117,7 @@ module Rubee
|
|
|
116
117
|
if over
|
|
117
118
|
sequel_dataset = klass
|
|
118
119
|
.join(over.to_sym, "#{singularized_assoc_name.snakeize}_id".to_sym => :id)
|
|
119
|
-
.where(Sequel[over][fk_name.to_sym] => id)
|
|
120
|
+
.where(Sequel[over][fk_name.to_sym] => id).select_all(original_assoc).all
|
|
120
121
|
self.class.serialize(sequel_dataset, klass)
|
|
121
122
|
else
|
|
122
123
|
klass.where(fk_name.to_sym => id)
|
data/lib/rubee.rb
CHANGED
data/readme.md
CHANGED
|
@@ -221,6 +221,32 @@ This will generate the following files
|
|
|
221
221
|
|
|
222
222
|
4. Fill the generated files with the logic you need and run the server again!
|
|
223
223
|
|
|
224
|
+
5. You can find full snapshot of the schema in the STRUCTURE constant or in the db/structur.rb file.
|
|
225
|
+
|
|
226
|
+
6. You can use rubee cli for printing out lates schema, out of STRUCUTRE constant
|
|
227
|
+
```bash
|
|
228
|
+
-> rubee db schema
|
|
229
|
+
--- users
|
|
230
|
+
- id, (PK), type (INTEGER)
|
|
231
|
+
- email, type (varchar(255))
|
|
232
|
+
- password, type (varchar(255))
|
|
233
|
+
|
|
234
|
+
--- accounts
|
|
235
|
+
- id, (PK), type (INTEGER)
|
|
236
|
+
- addres, type (varchar(255))
|
|
237
|
+
- user_id, type (INTEGER)
|
|
238
|
+
|
|
239
|
+
--- posts
|
|
240
|
+
- id, (PK), type (INTEGER)
|
|
241
|
+
- user_id, type (INTEGER)
|
|
242
|
+
- comment_id, type (INTEGER)
|
|
243
|
+
|
|
244
|
+
--- comments
|
|
245
|
+
- id, (PK), type (INTEGER)
|
|
246
|
+
- text, type (varchar(255))
|
|
247
|
+
- user_id, type (INTEGER)
|
|
248
|
+
```
|
|
249
|
+
|
|
224
250
|
[Back to content](#content)
|
|
225
251
|
|
|
226
252
|
## Model
|