ru.Bee 2.3.1 → 2.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/lib/db/create_comments.rb +2 -1
- data/lib/db/create_dummies.rb +13 -0
- data/lib/db/development.db +0 -0
- data/lib/db/test.db +0 -0
- data/lib/rubee/autoload.rb +0 -7
- data/lib/rubee/cli/console.rb +0 -6
- data/lib/rubee/cli/db.rb +4 -13
- data/lib/rubee/configuration.rb +1 -1
- data/lib/rubee/models/sequel_object.rb +8 -2
- data/lib/rubee.rb +1 -1
- data/lib/tests/cli/db_test.rb +29 -0
- data/lib/tests/test_helper.rb +0 -4
- data/readme.md +12 -2
- metadata +5 -3
- data/bin/test.db +0 -0
- data/lib/tests/test.db +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 23eb359b46246fbc2d1057d89e061984b56843972563e9525bd5b16bfd183ef6
|
|
4
|
+
data.tar.gz: 6bb72e7420d97a5b7cf30752bc90b73ccf29b9335754a057ee56148ec2d2f425
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 126206e8eb09b2a7902b2a9aee068f86599761b4ef76df56fe228de4a8cf3a649b5c2d1c9f693884f658d76c5646e27bfa8bf578021f8bcdea99d43375bcbbe5
|
|
7
|
+
data.tar.gz: 626b1627c969e0d0f9f941b4676fc07f9ddc784e5321dea1d987d0708502036b88f98f2337b6a62d6b5a41a45df061de4fb9f8db9bbee52c48bfaa538e95eff5
|
data/lib/db/create_comments.rb
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class CreateDummies
|
|
2
|
+
def call
|
|
3
|
+
return if Rubee::SequelObject::DB.tables.include?(:dummies)
|
|
4
|
+
|
|
5
|
+
Rubee::SequelObject::DB.create_table(:dummies) do
|
|
6
|
+
primary_key(:id)
|
|
7
|
+
String(:color, null: false)
|
|
8
|
+
# timestamps
|
|
9
|
+
datetime(:created)
|
|
10
|
+
datetime(:updated)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
File without changes
|
data/lib/db/test.db
ADDED
|
Binary file
|
data/lib/rubee/autoload.rb
CHANGED
|
@@ -56,13 +56,6 @@ module Rubee
|
|
|
56
56
|
require_relative File.join(Rubee::APP_ROOT, Rubee::LIB,
|
|
57
57
|
'config/base_configuration')
|
|
58
58
|
end
|
|
59
|
-
# This is necessary prerequisitedb init step
|
|
60
|
-
if Rubee::PROJECT_NAME == 'rubee'
|
|
61
|
-
Rubee::Configuration.setup(env = :test) do |config|
|
|
62
|
-
config.database_url = { url: 'sqlite://lib/tests/test.db', env: }
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
59
|
require_relative File.join(Rubee::APP_ROOT, Rubee::LIB, 'config/routes') unless black_list.include?('routes.rb')
|
|
67
60
|
# rubee extensions
|
|
68
61
|
Dir[File.join(root_directory, 'rubee/extensions/**', '*.rb')].each do |file|
|
data/lib/rubee/cli/console.rb
CHANGED
|
@@ -10,12 +10,6 @@ module Rubee
|
|
|
10
10
|
argv.clear
|
|
11
11
|
ENV['RACK_ENV'] ||= 'development'
|
|
12
12
|
|
|
13
|
-
if Rubee::PROJECT_NAME == 'rubee'
|
|
14
|
-
Rubee::Configuration.setup(env = :test) do |config|
|
|
15
|
-
config.database_url = { url: 'sqlite://lib/tests/test.db', env: }
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
13
|
begin
|
|
20
14
|
# Start IRB
|
|
21
15
|
IRB.start
|
data/lib/rubee/cli/db.rb
CHANGED
|
@@ -5,13 +5,6 @@ module Rubee
|
|
|
5
5
|
def call(command, argv)
|
|
6
6
|
command = argv[1].split(':').first
|
|
7
7
|
ENV['RACK_ENV'] ||= 'development'
|
|
8
|
-
if Rubee::PROJECT_NAME == 'rubee'
|
|
9
|
-
Rubee::Configuration.setup(env = :test) do |config|
|
|
10
|
-
config.database_url = { url: 'sqlite://lib/tests/test.db', env: }
|
|
11
|
-
end
|
|
12
|
-
Rubee::SequelObject.reconnect! unless command == 'init'
|
|
13
|
-
end
|
|
14
|
-
|
|
15
8
|
send(command, argv)
|
|
16
9
|
end
|
|
17
10
|
|
|
@@ -25,12 +18,9 @@ module Rubee
|
|
|
25
18
|
else
|
|
26
19
|
[file_name]
|
|
27
20
|
end
|
|
28
|
-
|
|
29
|
-
ENV['RACK_ENV']
|
|
30
|
-
|
|
31
|
-
color_puts("Run #{file} file for #{env} env", color: :cyan)
|
|
32
|
-
Object.const_get(file.split('_').map(&:capitalize).join).new.call
|
|
33
|
-
end
|
|
21
|
+
file_names.each do |file|
|
|
22
|
+
color_puts("Run #{file} file for #{ENV['RACK_ENV']} env", color: :cyan)
|
|
23
|
+
Object.const_get(file.split('_').map(&:capitalize).join).new.call
|
|
34
24
|
end
|
|
35
25
|
color_puts("Migration for #{file_name} completed", color: :green)
|
|
36
26
|
unless Rubee::PROJECT_NAME == 'rubee'
|
|
@@ -81,6 +71,7 @@ module Rubee
|
|
|
81
71
|
if File.exist?(db_path = db_url.sub(%r{^sqlite://}, ''))
|
|
82
72
|
color_puts("Database #{ENV['RACK_ENV']} exists", color: :cyan)
|
|
83
73
|
else
|
|
74
|
+
db_path = "#{Rubee::LIB}/#{db_path}" if Rubee::PROJECT_NAME == 'rubee'
|
|
84
75
|
Sequel.sqlite(db_path)
|
|
85
76
|
color_puts("Database #{ENV['RACK_ENV']} created", color: :green)
|
|
86
77
|
end
|
data/lib/rubee/configuration.rb
CHANGED
|
@@ -34,7 +34,7 @@ module Rubee
|
|
|
34
34
|
|
|
35
35
|
def database_url=(args)
|
|
36
36
|
args[:app] ||= :app
|
|
37
|
-
@configuraiton[args[:app].to_sym][args[:env].to_sym][:database_url] = args[:url]
|
|
37
|
+
@configuraiton[args[:app].to_sym][args[:env].to_sym][:database_url] = args[:url].gsub("//", "//#{Rubee::LIB}")
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def redis_url=(args)
|
|
@@ -27,7 +27,7 @@ module Rubee
|
|
|
27
27
|
if args[:id]
|
|
28
28
|
begin
|
|
29
29
|
update(args)
|
|
30
|
-
rescue StandardError =>
|
|
30
|
+
rescue StandardError => e
|
|
31
31
|
add_error(:base, sequel_error: e.message)
|
|
32
32
|
return false
|
|
33
33
|
end
|
|
@@ -160,13 +160,19 @@ module Rubee
|
|
|
160
160
|
end
|
|
161
161
|
|
|
162
162
|
def reconnect!
|
|
163
|
-
return if
|
|
163
|
+
return if db_set?
|
|
164
164
|
|
|
165
165
|
const_set(:DB, Sequel.connect(Rubee::Configuration.get_database_url))
|
|
166
166
|
|
|
167
167
|
Rubee::DBTools.set_prerequisites!
|
|
168
168
|
|
|
169
169
|
true
|
|
170
|
+
rescue Exception => e
|
|
171
|
+
false
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def db_set?
|
|
175
|
+
defined?(DB) && !DB.nil?
|
|
170
176
|
end
|
|
171
177
|
|
|
172
178
|
def dataset
|
data/lib/rubee.rb
CHANGED
|
@@ -17,7 +17,7 @@ module Rubee
|
|
|
17
17
|
CSS_DIR = File.join(APP_ROOT, LIB, 'css') unless defined?(CSS_DIR)
|
|
18
18
|
ROOT_PATH = File.expand_path(File.join(__dir__, '..')) unless defined?(ROOT_PATH)
|
|
19
19
|
|
|
20
|
-
VERSION = '2.3.
|
|
20
|
+
VERSION = '2.3.3'
|
|
21
21
|
|
|
22
22
|
require_relative 'rubee/router'
|
|
23
23
|
require_relative 'rubee/logger'
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require_relative '../test_helper'
|
|
2
|
+
|
|
3
|
+
describe 'Rubee::CLI::Db' do
|
|
4
|
+
describe 'when run db run:all with no ENV set' do
|
|
5
|
+
it 'goes with no errors' do
|
|
6
|
+
out = capture_stdout do
|
|
7
|
+
Rubee::CLI::Command.new(['db', 'run:create_dummies']).call
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
_(out).must_equal(
|
|
11
|
+
"\e[0;36mRun create_dummies file for test env\e[0m
|
|
12
|
+
\e[0;32mMigration for create_dummies completed\e[0m
|
|
13
|
+
"
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
Rubee::SequelObject::DB.drop_table(:dummies)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'cretes dummies table' do
|
|
20
|
+
Rubee::SequelObject::DB.drop_table(:dummies) if Rubee::SequelObject::DB.tables.include?(:dummies)
|
|
21
|
+
|
|
22
|
+
_(Rubee::SequelObject::DB.tables.include?(:dummies)).must_equal false
|
|
23
|
+
Rubee::CLI::Command.new(['db', 'run:create_dummies']).call
|
|
24
|
+
_(Rubee::SequelObject::DB.tables.include?(:dummies)).must_equal true
|
|
25
|
+
|
|
26
|
+
Rubee::SequelObject::DB.drop_table(:dummies)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/lib/tests/test_helper.rb
CHANGED
|
@@ -15,10 +15,6 @@ require 'stringio'
|
|
|
15
15
|
require_relative '../../lib/rubee'
|
|
16
16
|
|
|
17
17
|
Rubee::Autoload.call
|
|
18
|
-
Rubee::Configuration.setup(env = :test) do |config|
|
|
19
|
-
config.database_url = { url: 'sqlite://lib/tests/test.db', env: }
|
|
20
|
-
end
|
|
21
|
-
Rubee::SequelObject.reconnect!
|
|
22
18
|
|
|
23
19
|
def assert_difference(expression, difference = 1)
|
|
24
20
|
before = expression.call
|
data/readme.md
CHANGED
|
@@ -978,8 +978,9 @@ irb(main):047> foo.errors
|
|
|
978
978
|
Model example
|
|
979
979
|
```ruby
|
|
980
980
|
class User < Rubee::SequelObject
|
|
981
|
-
attr_accessor :id, :email, :password, :created
|
|
982
|
-
|
|
981
|
+
attr_accessor :id, :email, :password, :created
|
|
982
|
+
|
|
983
|
+
validate_after_setters # This will run validation after each setter.
|
|
983
984
|
validate_before_persist! # This will validate and raise error in case invalid before saving to DB
|
|
984
985
|
validate do
|
|
985
986
|
attribute(:email).required
|
|
@@ -1016,6 +1017,15 @@ irb(main):081> user
|
|
|
1016
1017
|
@password=123,
|
|
1017
1018
|
@updated=2025-11-30 17:18:52.254206 -0500>
|
|
1018
1019
|
```
|
|
1020
|
+
If you want to apply validation_before_persist! and validation_after_setters globally,
|
|
1021
|
+
add init/sequle_object_preloader.rb(you can chose any name)
|
|
1022
|
+
file withing set up those methods
|
|
1023
|
+
for Rubee::SequelObject parent class by adding:
|
|
1024
|
+
```
|
|
1025
|
+
Rubee::SequelObject.validate_befor_persist!
|
|
1026
|
+
Rubee::SequelObject.validate_after_setters
|
|
1027
|
+
```
|
|
1028
|
+
So you shouldn't add it to each model again and again.
|
|
1019
1029
|
[Back to content](#content)
|
|
1020
1030
|
|
|
1021
1031
|
## JWT based authentification
|
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.3.
|
|
4
|
+
version: 2.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Oleg Saltykov
|
|
@@ -39,7 +39,6 @@ extra_rdoc_files: []
|
|
|
39
39
|
files:
|
|
40
40
|
- LICENSE
|
|
41
41
|
- bin/rubee
|
|
42
|
-
- bin/test.db
|
|
43
42
|
- lib/Dockerfile
|
|
44
43
|
- lib/app/controllers/users_controller.rb
|
|
45
44
|
- lib/app/controllers/welcome_controller.rb
|
|
@@ -61,9 +60,12 @@ files:
|
|
|
61
60
|
- lib/db/create_carrots.rb
|
|
62
61
|
- lib/db/create_clients.rb
|
|
63
62
|
- lib/db/create_comments.rb
|
|
63
|
+
- lib/db/create_dummies.rb
|
|
64
64
|
- lib/db/create_posts.rb
|
|
65
65
|
- lib/db/create_users.rb
|
|
66
|
+
- lib/db/development.db
|
|
66
67
|
- lib/db/structure.rb
|
|
68
|
+
- lib/db/test.db
|
|
67
69
|
- lib/esbuild.config.js
|
|
68
70
|
- lib/images/rubee.svg
|
|
69
71
|
- lib/inits/charged_hash.rb
|
|
@@ -275,6 +277,7 @@ files:
|
|
|
275
277
|
- lib/rubee/websocket/websocket_connections.rb
|
|
276
278
|
- lib/tests/async/thread_async_test.rb
|
|
277
279
|
- lib/tests/cli/attach_test.rb
|
|
280
|
+
- lib/tests/cli/db_test.rb
|
|
278
281
|
- lib/tests/controllers/auth_tokenable_test.rb
|
|
279
282
|
- lib/tests/controllers/base_controller_test.rb
|
|
280
283
|
- lib/tests/controllers/hookable_test.rb
|
|
@@ -296,7 +299,6 @@ files:
|
|
|
296
299
|
- lib/tests/models/user_model_test.rb
|
|
297
300
|
- lib/tests/rubee_attach_test.rb
|
|
298
301
|
- lib/tests/rubee_generator_test.rb
|
|
299
|
-
- lib/tests/test.db
|
|
300
302
|
- lib/tests/test_helper.rb
|
|
301
303
|
- readme.md
|
|
302
304
|
homepage: https://github.com/nucleom42/rubee
|
data/bin/test.db
DELETED
|
Binary file
|
data/lib/tests/test.db
DELETED
|
Binary file
|