ru.Bee 2.4.2 → 2.5.1
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 +4 -2
- data/lib/rubee.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: 47aeb2d5c2977b5a43aa3e316548b391ded4310aa5687fc41ccc6526fbf72320
|
|
4
|
+
data.tar.gz: 5b913ab15c67a441e494d5fa79f693e7a4985b787c6fd71dd0655a3e0ed2045c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e6c6c022f4427f76b1e6a68caed12382f2881205fc1e90331e1722d97947b92539dfecb0cbb4210b72fb388a5cb2afd3a4646767ea6ec1464c4ba8b2f8217977
|
|
7
|
+
data.tar.gz: '0905fe0144ac5cdb68214afd2dfcb89b60e22a8728fce5e0b910857428fda4be9bd9c8ac062c84bc1b9329cf38316c9234b7672b22d6d52f04d6d1f7bc86e70a'
|
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
|
|
@@ -243,8 +243,10 @@ module Rubee
|
|
|
243
243
|
def validate_before_persist!
|
|
244
244
|
before(:save, proc { |model| raise Rubee::Validatable::Error, model.errors.to_s }, if: :invalid?)
|
|
245
245
|
before(:update, proc do |model, args|
|
|
246
|
-
|
|
247
|
-
|
|
246
|
+
dup__instance = model.dup
|
|
247
|
+
dup__instance.assign_attributes(**args[0])
|
|
248
|
+
if dup__instance.invalid?
|
|
249
|
+
raise Rubee::Validatable::Error, dup__instance.errors.to_s
|
|
248
250
|
end
|
|
249
251
|
end)
|
|
250
252
|
end
|
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
|