ru.Bee 1.6.0 → 1.7.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/bin/rubee +6 -300
- data/lib/app/views/index.html +1 -1
- data/lib/inits/charged_hash.rb +16 -0
- data/lib/inits/charged_string.rb +12 -0
- data/lib/js/app.js +3 -3
- data/lib/rubee/async/thread_async.rb +1 -1
- data/lib/rubee/async/thread_pool.rb +2 -2
- data/lib/rubee/autoload.rb +21 -8
- data/lib/rubee/cli/attach.rb +124 -0
- data/lib/rubee/cli/command.rb +41 -0
- data/lib/rubee/cli/console.rb +39 -0
- data/lib/rubee/cli/db.rb +105 -0
- data/lib/rubee/cli/generate.rb +33 -0
- data/lib/rubee/cli/project.rb +124 -0
- data/lib/rubee/cli/react.rb +28 -0
- data/lib/rubee/cli/routes.rb +18 -0
- data/lib/rubee/cli/server.rb +52 -0
- data/lib/rubee/cli/test.rb +24 -0
- data/lib/rubee/cli/version.rb +15 -0
- data/lib/rubee/configuration.rb +41 -18
- data/lib/rubee/controllers/base_controller.rb +12 -6
- data/lib/rubee/controllers/extensions/auth_tokenable.rb +2 -2
- data/lib/rubee/generator.rb +26 -18
- data/lib/rubee/models/database_objectable.rb +1 -1
- data/lib/rubee/models/sequel_object.rb +2 -1
- data/lib/rubee/router.rb +2 -3
- data/lib/rubee.rb +7 -4
- data/lib/tests/cli/attach_test.rb +36 -0
- data/lib/tests/controllers/rubeeapp_test.rb +1 -1
- data/lib/tests/rubee_attach_test.rb +0 -0
- data/lib/tests/test.db +0 -0
- data/lib/tests/test_helper.rb +1 -0
- data/readme.md +105 -12
- metadata +16 -2
- /data/lib/app/views/{app.tsx → App.tsx} +0 -0
data/lib/rubee/generator.rb
CHANGED
@@ -2,6 +2,7 @@ module Rubee
|
|
2
2
|
class Generator
|
3
3
|
require_relative '../inits/charged_string'
|
4
4
|
using ChargedString
|
5
|
+
|
5
6
|
def initialize(model_name, model_attributes, controller_name, action_name, **options)
|
6
7
|
@model_name = model_name&.downcase
|
7
8
|
@model_attributes = model_attributes || []
|
@@ -10,6 +11,8 @@ module Rubee
|
|
10
11
|
@plural_name = @base_name.plural? ? @base_name : @base_name.pluralize
|
11
12
|
@action_name = action_name
|
12
13
|
@react = options[:react] || {}
|
14
|
+
@app_name = options[:app_name] || :app
|
15
|
+
@namespace = @app_name == :app ? '' : "#{@app_name.camelize}::"
|
13
16
|
end
|
14
17
|
|
15
18
|
def call
|
@@ -22,14 +25,14 @@ module Rubee
|
|
22
25
|
private
|
23
26
|
|
24
27
|
def generate_model
|
25
|
-
model_file = File.join(Rubee::APP_ROOT, Rubee::LIB, "
|
28
|
+
model_file = File.join(Rubee::APP_ROOT, Rubee::LIB, "#{@app_name.to_s.snakeize}/models/#{@model_name}.rb")
|
26
29
|
if File.exist?(model_file)
|
27
30
|
puts "Model #{@model_name} already exists. Remove it if you want to regenerate"
|
28
31
|
return
|
29
32
|
end
|
30
33
|
|
31
34
|
content = <<~RUBY
|
32
|
-
class #{@model_name.
|
35
|
+
class #{@namespace}#{@model_name.camelize} < Rubee::SequelObject
|
33
36
|
#{'attr_accessor ' + @model_attributes.map { |hash| ":#{hash[:name]}" }.join(', ') unless @model_attributes.empty?}
|
34
37
|
end
|
35
38
|
RUBY
|
@@ -39,14 +42,14 @@ module Rubee
|
|
39
42
|
end
|
40
43
|
|
41
44
|
def generate_controller
|
42
|
-
controller_file = File.join(Rubee::APP_ROOT, Rubee::LIB, "
|
45
|
+
controller_file = File.join(Rubee::APP_ROOT, Rubee::LIB, "#{@app_name}/controllers/#{@base_name}_controller.rb")
|
43
46
|
if File.exist?(controller_file)
|
44
47
|
puts "Controller #{@base_name} already exists. Remove it if you want to regenerate"
|
45
48
|
return
|
46
49
|
end
|
47
50
|
|
48
51
|
content = <<~RUBY
|
49
|
-
class #{@base_name.
|
52
|
+
class #{@namespace}#{@base_name.camelize}Controller < Rubee::BaseController
|
50
53
|
def #{@action_name}
|
51
54
|
response_with
|
52
55
|
end
|
@@ -58,29 +61,33 @@ module Rubee
|
|
58
61
|
end
|
59
62
|
|
60
63
|
def generate_view
|
64
|
+
prefix = @namespace == "" ? "" : "#{@app_name.snakeize}_"
|
61
65
|
if @react[:view_name]
|
62
|
-
view_file = File.join(Rubee::APP_ROOT, Rubee::LIB, "
|
66
|
+
view_file = File.join(Rubee::APP_ROOT, Rubee::LIB, "#{@app_name}/views/#{@react[:view_name]}")
|
63
67
|
content = <<~JS
|
64
68
|
import React, { useEffect, useState } from "react";
|
65
69
|
// 1. Add your logic that fetches data
|
66
70
|
// 2. Do not forget to add respective react route
|
67
|
-
export function #{@react[:view_name].gsub(/\.(.*)+$/, '').
|
71
|
+
export function #{@react[:view_name].gsub(/\.(.*)+$/, '').camelize}() {
|
68
72
|
|
69
73
|
return (
|
70
74
|
<div>
|
71
|
-
<h2>#{@react[:view_name]} view</h2>
|
75
|
+
<h2>#{@react[:view_name].gsub(/\.(.*)+$/, '').camelize} view</h2>
|
72
76
|
</div>
|
73
77
|
);
|
74
78
|
}
|
75
79
|
JS
|
76
|
-
else
|
77
|
-
view_file = File.join(
|
80
|
+
else # erb
|
81
|
+
view_file = File.join(
|
82
|
+
Rubee::APP_ROOT, Rubee::LIB,
|
83
|
+
"#{@app_name}/views/#{prefix}#{@plural_name}_#{@action_name}.erb"
|
84
|
+
)
|
78
85
|
content = <<~ERB
|
79
|
-
<h1>#{@plural_name}_#{@action_name} View</h1>
|
86
|
+
<h1>#{prefix}#{@plural_name}_#{@action_name} View</h1>
|
80
87
|
ERB
|
81
88
|
end
|
82
89
|
|
83
|
-
name = @react[:view_name] || "#{@plural_name}_#{@action_name}"
|
90
|
+
name = @react[:view_name] || "#{prefix}#{@plural_name}_#{@action_name}"
|
84
91
|
|
85
92
|
if File.exist?(view_file)
|
86
93
|
puts "View #{name} already exists. Remove it if you want to regenerate"
|
@@ -92,18 +99,19 @@ module Rubee
|
|
92
99
|
end
|
93
100
|
|
94
101
|
def generate_db_file
|
95
|
-
|
102
|
+
table_name = @namespace == "" ? @plural_name : "#{@namespace.snakeize}_#{@plural_name}"
|
103
|
+
db_file = File.join(Rubee::APP_ROOT, Rubee::LIB, "db/create_#{table_name}.rb")
|
96
104
|
if File.exist?(db_file)
|
97
|
-
puts "DB file for #{
|
105
|
+
puts "DB file for #{table_name} already exists. Remove it if you want to regenerate"
|
98
106
|
return
|
99
107
|
end
|
100
108
|
|
101
109
|
content = <<~RUBY
|
102
|
-
class Create#{
|
110
|
+
class Create#{table_name.camelize}
|
103
111
|
def call
|
104
|
-
return if Rubee::SequelObject::DB.tables.include?(:#{
|
112
|
+
return if Rubee::SequelObject::DB.tables.include?(:#{table_name})
|
105
113
|
|
106
|
-
Rubee::SequelObject::DB.create_table(:#{
|
114
|
+
Rubee::SequelObject::DB.create_table(:#{table_name}) do
|
107
115
|
#{@model_attributes.map { |attribute| generate_sequel_schema(attribute) }.join("\n\t\t\t")}
|
108
116
|
end
|
109
117
|
end
|
@@ -111,7 +119,7 @@ module Rubee
|
|
111
119
|
RUBY
|
112
120
|
|
113
121
|
File.open(db_file, 'w') { |file| file.write(content) }
|
114
|
-
color_puts("DB file for #{
|
122
|
+
color_puts("DB file for #{table_name} created", color: :green)
|
115
123
|
end
|
116
124
|
|
117
125
|
def generate_sequel_schema(attribute)
|
@@ -149,4 +157,4 @@ module Rubee
|
|
149
157
|
statement
|
150
158
|
end
|
151
159
|
end
|
152
|
-
end
|
160
|
+
end
|
@@ -2,6 +2,7 @@ module Rubee
|
|
2
2
|
class SequelObject
|
3
3
|
include Rubee::DatabaseObjectable
|
4
4
|
using ChargedString
|
5
|
+
using ChargedHash
|
5
6
|
|
6
7
|
def destroy(cascade: false, **_options)
|
7
8
|
if cascade
|
@@ -179,7 +180,7 @@ module Rubee
|
|
179
180
|
def serialize(suquel_dataset, klass = nil)
|
180
181
|
klass ||= self
|
181
182
|
suquel_dataset.map do |record_hash|
|
182
|
-
target_klass_fields = DB[klass.name.pluralize.downcase.to_sym].columns
|
183
|
+
target_klass_fields = DB[klass.name.pluralize.downcase.camelize.to_sym].columns
|
183
184
|
klass_attributes = record_hash.filter { target_klass_fields.include?(_1) }
|
184
185
|
klass.new(**klass_attributes)
|
185
186
|
end
|
data/lib/rubee/router.rb
CHANGED
@@ -2,7 +2,7 @@ module Rubee
|
|
2
2
|
class Router
|
3
3
|
include Singleton
|
4
4
|
|
5
|
-
HTTP_METHODS = %i[get post put patch delete head connect options trace].freeze
|
5
|
+
HTTP_METHODS = %i[get post put patch delete head connect options trace].freeze unless defined?(HTTP_METHODS)
|
6
6
|
|
7
7
|
attr_reader :request, :routes
|
8
8
|
|
@@ -14,7 +14,6 @@ module Rubee
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def route_for(request)
|
17
|
-
puts request.request_method
|
18
17
|
method = (request.params['_method'] || request.request_method).downcase.to_sym
|
19
18
|
@routes.find do |route|
|
20
19
|
return route if request.path == route[:path] && request.request_method&.downcase&.to_sym == route[:method]
|
@@ -38,4 +37,4 @@ module Rubee
|
|
38
37
|
end
|
39
38
|
end
|
40
39
|
end
|
41
|
-
end
|
40
|
+
end
|
data/lib/rubee.rb
CHANGED
@@ -15,7 +15,8 @@ module Rubee
|
|
15
15
|
IMAGE_DIR = File.join(APP_ROOT, LIB, 'images') unless defined?(IMAGE_DIR)
|
16
16
|
JS_DIR = File.join(APP_ROOT, LIB, 'js') unless defined?(JS_DIR)
|
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
|
+
VERSION = '1.7.0'
|
19
20
|
|
20
21
|
require_relative 'rubee/router'
|
21
22
|
require_relative 'rubee/logger'
|
@@ -25,13 +26,15 @@ module Rubee
|
|
25
26
|
|
26
27
|
class Application
|
27
28
|
include Singleton
|
29
|
+
using(ChargedString)
|
28
30
|
|
29
31
|
def call(env)
|
30
32
|
# autoload rb files
|
31
33
|
Autoload.call
|
34
|
+
|
32
35
|
# register images paths
|
33
36
|
request = Rack::Request.new(env)
|
34
|
-
# Add default path for
|
37
|
+
# Add default path for assets
|
35
38
|
Router.draw do |route|
|
36
39
|
route.get('/images/{path}', to: 'base#image', namespace: 'Rubee')
|
37
40
|
route.get('/js/{path}', to: 'base#js', namespace: 'Rubee')
|
@@ -48,9 +51,9 @@ module Rubee
|
|
48
51
|
return [404, { 'content-type' => 'text/plain' }, ['Route not found']] unless route
|
49
52
|
# init controller class
|
50
53
|
controller_class = if route[:namespace]
|
51
|
-
"#{route[:namespace]}::#{route[:controller].
|
54
|
+
"#{route[:namespace].to_s.camelize}::#{route[:controller].camelize}Controller"
|
52
55
|
else
|
53
|
-
"#{route[:controller].
|
56
|
+
"#{route[:controller].camelize}Controller"
|
54
57
|
end
|
55
58
|
# instantiate controller
|
56
59
|
controller = Object.const_get(controller_class).new(request, route)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
|
3
|
+
describe 'Rubee::CLI::Attach' do
|
4
|
+
describe 'when run attach command over cli' do
|
5
|
+
it 'calls Rubee::CLI::Attach.call' do
|
6
|
+
called = false
|
7
|
+
|
8
|
+
Rubee::CLI::Attach.stub(:call, ->(*_args) { called = true }) do
|
9
|
+
Rubee::CLI::Command.new(['attach', 'carrot']).call
|
10
|
+
end
|
11
|
+
|
12
|
+
assert called, "Expected Rubee::CLI::Attach.run to be called"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'when attach executed' do
|
17
|
+
it 'creates new folder carrot' do
|
18
|
+
Rubee::CLI::Command.new(['attach', 'carrot']).call unless Dir.exist?('carrot')
|
19
|
+
assert Dir.exist?('carrot'), "Expected 'carrot' folder to be created"
|
20
|
+
FileUtils.rm_rf('carrot')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'creates inside of the project folder expected content' do
|
24
|
+
Rubee::CLI::Command.new(['attach', 'carrot']).call unless Dir.exist?('carrot')
|
25
|
+
%w[controllers models views].each do |dir|
|
26
|
+
assert Dir.exist?("carrot/#{dir}"), "Expected 'carrot/#{dir}' folder to be created"
|
27
|
+
end
|
28
|
+
|
29
|
+
%w[carrot_configuration carrot_routes carrot_namespace].each do |file|
|
30
|
+
assert File.exist?("carrot/#{file}.rb"), "Expected 'carrot/#{file}.rb' file to be created"
|
31
|
+
end
|
32
|
+
|
33
|
+
FileUtils.rm_rf('carrot')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -27,7 +27,7 @@ class RubeeAppTest < Minitest::Test
|
|
27
27
|
get('/home')
|
28
28
|
|
29
29
|
assert_equal(200, last_response.status)
|
30
|
-
assert_includes(last_response.body, '<div id="
|
30
|
+
assert_includes(last_response.body, '<div id="App">')
|
31
31
|
assert_includes(last_response.body, 'bundle.js')
|
32
32
|
|
33
33
|
Rubee::Configuration.setup(env = :test) { _1.react = { on: false, env: } }
|
File without changes
|
data/lib/tests/test.db
CHANGED
Binary file
|
data/lib/tests/test_helper.rb
CHANGED
data/readme.md
CHANGED
@@ -16,31 +16,35 @@ Want to get a quick API server up and runing? You can do it for real quick!
|
|
16
16
|
<br />
|
17
17
|
[](https://www.youtube.com/watch?v=ko7H70s7qq0)
|
18
18
|
|
19
|
-
All
|
19
|
+
All great features are yet to come!
|
20
20
|
|
21
21
|
## Content:
|
22
22
|
|
23
23
|
- [Installation](#Installation)
|
24
|
-
- [Run tests](#
|
25
|
-
- [Draw contract](#
|
24
|
+
- [Run tests](#run-tests)
|
25
|
+
- [Draw contract](#draw-contract)
|
26
26
|
- [Model](#Model)
|
27
27
|
- [Routing](#Routing)
|
28
28
|
- [Database](#Database)
|
29
29
|
- [Views](#Views)
|
30
30
|
- [Hooks](#Hooks)
|
31
|
-
- [JWT based authentification](#JWT
|
32
|
-
- [Rubee commands](#Rubee
|
33
|
-
- [Generate commands](#Generate
|
34
|
-
- [Migration commands](#Migration
|
35
|
-
- [Rubee console](#Rubee
|
31
|
+
- [JWT based authentification](#JWT-based-authentification)
|
32
|
+
- [Rubee commands](#Rubee-commands)
|
33
|
+
- [Generate commands](#Generate-commands)
|
34
|
+
- [Migration commands](#Migration-commands)
|
35
|
+
- [Rubee console](#Rubee-console)
|
36
36
|
- [Testing](#Testing)
|
37
|
-
- [Background jobs](#Background
|
37
|
+
- [Background jobs](#Background-jobs)
|
38
|
+
- [Modular](#Modular application)
|
38
39
|
- [Logger](#Logger)
|
39
40
|
|
40
41
|
## Features
|
41
42
|
|
42
43
|
- **Lightweight**: A minimal footprint that focuses on serving Ruby applications efficiently.
|
43
|
-
- **
|
44
|
+
- **Moduled** A modular approach to application development. Build modular monolith applications with ease by \
|
45
|
+
attaching as many subprojects you need.
|
46
|
+
- **Contract driven**: Define your API contracts in a simple, declarative manner.\
|
47
|
+
Then generate the biolerplate files you need.
|
44
48
|
- **Fast**: Optimized for speed, providing a quick response to requests. Everything is relative, I know!
|
45
49
|
- **Rack**: Rack backed. All Rack api is available for integration.
|
46
50
|
- **Databases**: Sqlite3, Postgres, Mysql and many more supported by sequel gem.
|
@@ -49,8 +53,8 @@ All greaet features are yet to come!
|
|
49
53
|
- **Bundlable** Charge your ruBee with any gem you need and update your project with bundle.
|
50
54
|
- **ORM** All models are natively ORM objects, however you can use it as a blueurpint for any datasources.
|
51
55
|
- **Authentificatable** Add JWT authentification easily to any controller action.
|
52
|
-
- **Hooks**
|
53
|
-
- **Test** Run all or selected tests witin minitest.
|
56
|
+
- **Hooks** Add logic before, after and around any action.
|
57
|
+
- **Test** Run all or selected tests witin fast and beloved minitest.
|
54
58
|
- **Asyncable** Add async adapter and pick any popular background job queue enginee
|
55
59
|
- **Console** Start the interactive console and reload it on the fly
|
56
60
|
- **Background jobs** Add async adapter and pick any popular background job queue engine
|
@@ -67,6 +71,8 @@ gem install ru.Bee
|
|
67
71
|
rubee project my_project
|
68
72
|
cd my_project
|
69
73
|
```
|
74
|
+
- [Back to content](#Content)
|
75
|
+
|
70
76
|
|
71
77
|
3. Install dependencies
|
72
78
|
|
@@ -90,6 +96,7 @@ rubee start
|
|
90
96
|
```bash
|
91
97
|
rubee test
|
92
98
|
```
|
99
|
+
- [Back to content](#Content)
|
93
100
|
|
94
101
|
## Draw contract
|
95
102
|
1. Add the routes to the routes.rb
|
@@ -126,6 +133,7 @@ This will generate the following files
|
|
126
133
|
```
|
127
134
|
|
128
135
|
5. Fill the generated files with the logic you need and run the server again!
|
136
|
+
- [Back to content](#Content)
|
129
137
|
|
130
138
|
## Model
|
131
139
|
Model in ruBee is just simple ruby object that can be serilalized in the view
|
@@ -174,6 +182,7 @@ So in the controller you would need to query your target object now.
|
|
174
182
|
end
|
175
183
|
end
|
176
184
|
```
|
185
|
+
- [Back to content](#Content)
|
177
186
|
|
178
187
|
#### Rubee::SequelObject base methods:
|
179
188
|
|
@@ -304,6 +313,7 @@ irb(main):010> .then { |dataset| Comment.serialize(dataset) }
|
|
304
313
|
```
|
305
314
|
This is recommended when you want to run one query and serialize it back to Rubee object only once.
|
306
315
|
So it may safe some resources.
|
316
|
+
- [Back to content](#Content)
|
307
317
|
|
308
318
|
## Routing
|
309
319
|
Rubee uses explicit routes. In the routes.rb yout can define routes for any of the main HTTP methods. You can also add any matched parameter denoted by a pair of `{ }` in the path of the route. Eg. `/path/to/{a_key}/somewhere`
|
@@ -436,6 +446,80 @@ Will generate:
|
|
436
446
|
./db/create_apples.rb # Database migration file needed for creating repsective table
|
437
447
|
```
|
438
448
|
|
449
|
+
### Modualar application
|
450
|
+
|
451
|
+
You can also use ruBee to create modular applications.\
|
452
|
+
And attach as many subprojects you need.
|
453
|
+
Main philosophy of attach functinality is to keep the main project clean and easy to maintain. It will still\
|
454
|
+
share data with the main app. So where to define a border between main app and subprojects is up to developer.
|
455
|
+
Howerver by attching new subproject you will get a new folder and files configured and namespaced respectively.
|
456
|
+
|
457
|
+
So if you need to extend your main app with a separate project you can do it easily in ruBee.
|
458
|
+
1. Attach new subrpoject
|
459
|
+
|
460
|
+
```bash
|
461
|
+
rubee attach admin
|
462
|
+
```
|
463
|
+
This will create a dedicated folder in the project root called admin and all the MVC setup, route and configuraion \
|
464
|
+
files will be created there.
|
465
|
+
|
466
|
+
2. Add routes
|
467
|
+
|
468
|
+
```ruby
|
469
|
+
# admin_routes.rb
|
470
|
+
Rubee::Router.draw do |router|
|
471
|
+
...
|
472
|
+
# draw the contract
|
473
|
+
router.get '/admin/cabages', to: 'cabages#index',
|
474
|
+
model: {
|
475
|
+
name: 'cabage',
|
476
|
+
attributes: [
|
477
|
+
{ name: 'id', type: :primary },
|
478
|
+
{ name: 'name', type: :string }
|
479
|
+
]
|
480
|
+
},
|
481
|
+
namespace: :admin # mandatory option for supporting namespacing
|
482
|
+
end
|
483
|
+
```
|
484
|
+
3. Run gen command
|
485
|
+
|
486
|
+
```bash
|
487
|
+
rubee gen get /admin/cabages app:admin
|
488
|
+
```
|
489
|
+
|
490
|
+
This will generate the bolierplate files:
|
491
|
+
|
492
|
+
```bash
|
493
|
+
./admin/controllers/cabages_controller.rb
|
494
|
+
./admin/views/cabages_index.erb
|
495
|
+
./admin/models/cabage.rb
|
496
|
+
./db/create_cabages.rb
|
497
|
+
```
|
498
|
+
|
499
|
+
4. Perform migrations
|
500
|
+
|
501
|
+
```bash
|
502
|
+
rubee db run:create_cabages
|
503
|
+
```
|
504
|
+
5. Fill the views and controller with the content
|
505
|
+
|
506
|
+
```ruby
|
507
|
+
# ./admin/controllers/cabages_controller.rb
|
508
|
+
class Admin::CabagesController < Rubee::BaseController
|
509
|
+
def index
|
510
|
+
response_with object: Cabage.all, type: :json
|
511
|
+
end
|
512
|
+
end
|
513
|
+
```
|
514
|
+
|
515
|
+
6. Run the rubee server
|
516
|
+
|
517
|
+
```bash
|
518
|
+
rubee start # or rubee start_dev for development
|
519
|
+
```
|
520
|
+
|
521
|
+
- [Back to content](#Content)
|
522
|
+
|
439
523
|
## Views
|
440
524
|
View in ruBee is just a plain html/erb/react file that can be rendered from the controller.
|
441
525
|
|
@@ -570,6 +654,7 @@ function Users() {
|
|
570
654
|
}
|
571
655
|
|
572
656
|
```
|
657
|
+
- [Back to content](#Content)
|
573
658
|
|
574
659
|
## Object hooks
|
575
660
|
|
@@ -612,6 +697,8 @@ after index2
|
|
612
697
|
after log around
|
613
698
|
127.0.0.1 - - [17/Feb/2025:11:42:14 -0500] "GET /apples HTTP/1.1" 401 - 0.0359
|
614
699
|
```
|
700
|
+
- [Back to content](#Content)
|
701
|
+
|
615
702
|
|
616
703
|
## JWT based authentification
|
617
704
|
Charge you rpoject with token based authentification system and customize it for your needs.
|
@@ -661,6 +748,7 @@ class UsersController < Rubee::BaseController
|
|
661
748
|
end
|
662
749
|
end
|
663
750
|
```
|
751
|
+
- [Back to content](#Content)
|
664
752
|
|
665
753
|
## Rubee commands
|
666
754
|
```bash
|
@@ -695,6 +783,8 @@ rubee console # start the console
|
|
695
783
|
rubee test # run all tests
|
696
784
|
rubee test auth_tokenable_test.rb # run specific tests
|
697
785
|
```
|
786
|
+
- [Back to content](#Content)
|
787
|
+
|
698
788
|
|
699
789
|
If you want to run any ruBee command within a specific ENV make sure you added it before a command.
|
700
790
|
For instance if you want to run console in test environment you need to run the following command
|
@@ -776,6 +866,8 @@ end
|
|
776
866
|
|
777
867
|
TestAsyncRunnner.new.perform_async(options: {"email"=> "new@new.com", "password"=> "123"})
|
778
868
|
```
|
869
|
+
- [Back to content](#Content)
|
870
|
+
|
779
871
|
### Logger
|
780
872
|
|
781
873
|
You can use your own logger by setting it in the /config/base_configuration.rb.
|
@@ -821,6 +913,7 @@ When you trigger the controller action, the logs will look like this:
|
|
821
913
|
[2025-04-26 12:32:33] INFO [method: show][class_name: WelcomeController] Execution Time: 0.000655 seconds
|
822
914
|
[2025-04-26 12:32:33] DEBUG [method: show][class_name: WelcomeController] #<User:0x000000012c5c63e0 @id=4545, @email="ok@op.com", @password="123">
|
823
915
|
```
|
916
|
+
- [Back to content](#Content)
|
824
917
|
|
825
918
|
### Contributing
|
826
919
|
|
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: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleg Saltykov
|
@@ -43,7 +43,7 @@ files:
|
|
43
43
|
- lib/Dockerfile
|
44
44
|
- lib/app/controllers/welcome_controller.rb
|
45
45
|
- lib/app/models/user.rb
|
46
|
-
- lib/app/views/
|
46
|
+
- lib/app/views/App.tsx
|
47
47
|
- lib/app/views/index.html
|
48
48
|
- lib/app/views/layout.erb
|
49
49
|
- lib/app/views/utils/redirectToBackend.tsx
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- lib/db/structure.rb
|
62
62
|
- lib/esbuild.config.js
|
63
63
|
- lib/images/rubee.svg
|
64
|
+
- lib/inits/charged_hash.rb
|
64
65
|
- lib/inits/charged_string.rb
|
65
66
|
- lib/inits/print_colors.rb
|
66
67
|
- lib/js/app.js
|
@@ -233,6 +234,17 @@ files:
|
|
233
234
|
- lib/rubee/async/thread_async.rb
|
234
235
|
- lib/rubee/async/thread_pool.rb
|
235
236
|
- lib/rubee/autoload.rb
|
237
|
+
- lib/rubee/cli/attach.rb
|
238
|
+
- lib/rubee/cli/command.rb
|
239
|
+
- lib/rubee/cli/console.rb
|
240
|
+
- lib/rubee/cli/db.rb
|
241
|
+
- lib/rubee/cli/generate.rb
|
242
|
+
- lib/rubee/cli/project.rb
|
243
|
+
- lib/rubee/cli/react.rb
|
244
|
+
- lib/rubee/cli/routes.rb
|
245
|
+
- lib/rubee/cli/server.rb
|
246
|
+
- lib/rubee/cli/test.rb
|
247
|
+
- lib/rubee/cli/version.rb
|
236
248
|
- lib/rubee/configuration.rb
|
237
249
|
- lib/rubee/controllers/base_controller.rb
|
238
250
|
- lib/rubee/controllers/extensions/auth_tokenable.rb
|
@@ -246,6 +258,7 @@ files:
|
|
246
258
|
- lib/rubee/models/sequel_object.rb
|
247
259
|
- lib/rubee/router.rb
|
248
260
|
- lib/tests/async/thread_async_test.rb
|
261
|
+
- lib/tests/cli/attach_test.rb
|
249
262
|
- lib/tests/controllers/auth_tokenable_test.rb
|
250
263
|
- lib/tests/controllers/base_controller_test.rb
|
251
264
|
- lib/tests/controllers/hookable_test.rb
|
@@ -261,6 +274,7 @@ files:
|
|
261
274
|
- lib/tests/models/db_objectable_test.rb
|
262
275
|
- lib/tests/models/seralizable_test.rb
|
263
276
|
- lib/tests/models/user_model_test.rb
|
277
|
+
- lib/tests/rubee_attach_test.rb
|
264
278
|
- lib/tests/rubee_generator_test.rb
|
265
279
|
- lib/tests/test.db
|
266
280
|
- lib/tests/test_helper.rb
|
File without changes
|