ru.Bee 2.5.6 → 2.5.8

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: b3fd10a8289d2c40aa0f9709bdf87ad2d4ff6ad8238d76f321b7e534d365d84c
4
- data.tar.gz: 05c6c2f8dd162d9952204ef603d65de7f03d4be83b857440e50a5c92556caa54
3
+ metadata.gz: 326e4c90ee2f508b646bb859bc99b82a0b71e531528ccce28abf6c2871d7fa5c
4
+ data.tar.gz: e61f9e11b7fa099d5a602f61cac7a6929009d093ac925ad17f79373ba5ebc09d
5
5
  SHA512:
6
- metadata.gz: 75f0f5618b721651c6f2c3fdfe8cbd267b3b0a764b1bccbff39768b5f89903f16d8d435f5a3f4d4869635505afebf5870c2954448a780a0f3446767ffdcf2e35
7
- data.tar.gz: ec7ce9f2c15cbc4eaf53118bb71f0d8a6559cbd57f82584718d9379c285eee366f33f8b66ded0363ce432f8eee55b5b15e84838bde3d65a46d5aa1b357613897
6
+ metadata.gz: 966496daef2ad7efe7a918edee0f9074c5668cf7b60ec9c1c43a844fe5dfa3640514ee8e03d4a606a4e94b03779a5cfa3ec2b743cf6e53686fa3fac18cf12124
7
+ data.tar.gz: 52d9ae220542a33c969403cdf166ae6bbaa43162dadded67d9f3692891be84d9e5ca1053ad0616b5f12714ffe34ee110e1f0cfa2d1ebdae04b2025b20c6f7e2d
@@ -55,7 +55,7 @@ module Rubee
55
55
  name = ::Regexp.last_match(1)
56
56
  kind = :method
57
57
  break
58
- elsif l =~ /^\s*describe\s+['"](.*)['"]/
58
+ elsif l =~ /^\s*(describe|context)\s+['"](.*)['"]/
59
59
  name = ::Regexp.last_match(1)
60
60
  kind = :spec
61
61
  break
@@ -250,6 +250,10 @@ module Rubee
250
250
  end
251
251
  end)
252
252
  end
253
+
254
+ def find_or_new(attrs = {})
255
+ where(attrs).first || new(**attrs)
256
+ end
253
257
  end
254
258
  end
255
259
  end
@@ -23,6 +23,18 @@ module Rubee
23
23
  wrap(super(alt_key))
24
24
  end
25
25
 
26
+ def deep_dig(key)
27
+ return self[key] if self[key]
28
+
29
+ each do |_, v|
30
+ if v.is_a?(Hash)
31
+ return v.deep_dig(key)
32
+ end
33
+ end
34
+
35
+ nil
36
+ end
37
+
26
38
  private
27
39
 
28
40
  def wrap(value)
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.5.6'
23
+ VERSION = '2.5.8'
24
24
 
25
25
  require_relative 'rubee/router'
26
26
  require_relative 'rubee/logger'
data/readme.md CHANGED
@@ -260,6 +260,12 @@ This will generate the following files
260
260
  - comment_id → comments() on delete no_action on update no_action
261
261
  - user_id → users() on delete no_action on update no_action
262
262
  ```
263
+ 8. Drop all tables can be handy for development process. But be careful and make sure you pass desired environment
264
+ ```bash
265
+ RACK_ENV=test rubee db drop_tables
266
+ These tables has been dropped for test env
267
+ [:companies, :company_clients, :services]
268
+ ```
263
269
 
264
270
  [Back to content](#content)
265
271
 
@@ -395,6 +401,18 @@ irb(main):021> user.destroy(cascade: true)
395
401
  => 1
396
402
  ```
397
403
 
404
+ Find record in the databse or initialize the instance for following persistence
405
+ ```Ruby
406
+ irb(main):020> user = User.find_or_new(email: "ok23@ok.com")
407
+ => #<User:0x000000010cfaa5c0 @email="ok23@ok.com", @id=2, @password="123">
408
+ irb(main):021> user.persisted?
409
+ => true
410
+ irb(main):022> user = User.find_or_new(email: "new@ok.com")
411
+ => #<User:0x000000010cfaa5c0 @email="new@ok.com", @id=nil, @password=nil>
412
+ irb(main):023> user.persisted?
413
+ => false
414
+ ```
415
+
398
416
  Destroy all records one by one
399
417
  ```Ruby
400
418
  irb(main):022> User.destroy_all
@@ -417,7 +435,7 @@ class Comment < Rubee::SequelObject
417
435
  owns_many :users, over: :posts
418
436
  end
419
437
 
420
- # join post modenl
438
+ # join post model
421
439
  class Post < Rubee::SequelObject
422
440
  attr_accessor :id, :user_id, :comment_id, :created, :updated
423
441
  holds :comment
@@ -1104,6 +1122,10 @@ Here are list of additionl APIs extended for:
1104
1122
  "test".plural? # => false
1105
1123
  ```
1106
1124
 
1125
+ ```ruby
1126
+ {one: {two: 2}}.deep_dig(:two) # => 2
1127
+ ```
1128
+
1107
1129
  [Back to content](#content)
1108
1130
 
1109
1131
 
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.5.6
4
+ version: 2.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Saltykov
@@ -322,7 +322,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
322
322
  - !ruby/object:Gem::Version
323
323
  version: '0'
324
324
  requirements: []
325
- rubygems_version: 3.7.2
325
+ rubygems_version: 4.0.4
326
326
  specification_version: 4
327
327
  summary: Fast and lightweight Ruby application server designed for minimalism and
328
328
  flexibility