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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4204ab4a146dba0a5c2be32845880e17d576b12d807f58de9024e8f31db8268
4
- data.tar.gz: e5afe1588d9597034a3931a86631d1cc6f35cb63c4d03fa45a64bef30494c127
3
+ metadata.gz: 662d0d94e4f29f53da650705c4f04b15739ef9fc22d18e06e5f26ba9c5180a7b
4
+ data.tar.gz: 470c43de0b06a51164c499a83d34bdf361a9b3f9433a43d0b971395f4149494d
5
5
  SHA512:
6
- metadata.gz: 814450e1ae8f4fd6e206aa7fcfc0b021901bd00a4c7e8831ff94df5cae97d4c019981b4870310048977a5ff4f5cc6160d876bd91fc035fdb236988759d550c1a
7
- data.tar.gz: 389a39ca1bd6f3853a53aa918c4e658de405bf035b53b98f14aa9e428b9bf27b1fd0cb8ba8b62190f446d0e932b11d743d194b265c401bba37866df98280dbb1
6
+ metadata.gz: ab5b1e90290b4f2aefc52ca52187c8a8811d6d5e11016fbb826afb2aa119881aa4593d8d7cdc3c19c6aeb1a0a0f64695bae04897ff99dae1a2c3552b1ee1348b
7
+ data.tar.gz: 3bb1991be93a8cd7aedf38dad66355f79a35cdd6b0724508c4c5d8c5e951bcb457ead32edcb7cb52999550a9dd90482c50f84faaf16e613afdc73e02f5b5fce3
data/lib/db/test.db CHANGED
Binary file
@@ -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
@@ -20,7 +20,7 @@ module Rubee
20
20
  RUBEE_SUPPORT = { "Rubee::Support::Hash" => Hash, "Rubee::Support::String" => String }
21
21
  end
22
22
 
23
- VERSION = '2.4.1'
23
+ VERSION = '2.5.0'
24
24
 
25
25
  require_relative 'rubee/router'
26
26
  require_relative 'rubee/logger'
@@ -27,7 +27,7 @@ describe 'TestAsyncRunnner' do
27
27
  subject
28
28
 
29
29
  Timeout.timeout(1) do
30
- sleep(0.05) until User.count == 5
30
+ sleep(0.1) until User.count == 5
31
31
  end
32
32
 
33
33
  assert_equal 5, User.count
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ru.Bee
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Saltykov