ru.Bee 1.1.1 → 1.1.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/bin/rubee +1 -17
- data/lib/app/tests/auth_tokenable_test.rb +29 -0
- data/lib/app/tests/rubeeapp_test.rb +24 -0
- data/lib/app/tests/test_helper.rb +10 -0
- data/lib/app/tests/user_model_test.rb +60 -0
- data/lib/rubee/tests/test_helper.rb +2 -3
- data/lib/rubee/tests/user_model_test.rb +9 -0
- data/lib/rubee.rb +3 -4
- data/lib/version.rb +1 -1
- data/readme.md +16 -13
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e8955bd33a079fb958c40784fa0eff94bae99964644fc03eeba77afb442382e
|
4
|
+
data.tar.gz: 605a6479ae2db28de410d9dd78c80995af794c1ccc8c0d02981241aa69e2a749
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 908ca83c33213cbe985b7b88a989b236aafe4a7ea02a1206da6bc4a25234f2fcc5188ea020cb9dc73424d5a9c50aa565f6edb7f83f5b4b5af46a5cad5090bdcf
|
7
|
+
data.tar.gz: f85099cede5b96316373f0b4babb062dff1dad206743042325e1afaca76ef9b6ee57464349c4b47c785e39798c76a6c3034ac8ba87925eb0a5d0713e9a3548b8
|
data/bin/rubee
CHANGED
@@ -107,6 +107,7 @@ elsif command == "project"
|
|
107
107
|
gem 'pry'
|
108
108
|
gem 'pry-byebug'
|
109
109
|
gem 'puma'
|
110
|
+
gem 'json'
|
110
111
|
|
111
112
|
group :development do
|
112
113
|
gem 'rerun'
|
@@ -119,23 +120,6 @@ elsif command == "project"
|
|
119
120
|
file.puts gemfile
|
120
121
|
end
|
121
122
|
|
122
|
-
# create a test folder
|
123
|
-
FileUtils.mkdir_p("#{target_dir}/tests")
|
124
|
-
# create a test_helper context
|
125
|
-
test_helper = <<~RUBY
|
126
|
-
require "bundler/setup"
|
127
|
-
Bundler.require(:test)
|
128
|
-
|
129
|
-
require 'minitest/autorun'
|
130
|
-
require 'rack/test'
|
131
|
-
require 'ru.Bee'
|
132
|
-
|
133
|
-
Rubee::Autoload.call
|
134
|
-
RUBY
|
135
|
-
File.open("#{target_dir}/tests/test_helper.rb", 'w') do |file|
|
136
|
-
file.puts test_helper
|
137
|
-
end
|
138
|
-
|
139
123
|
color_puts "Project #{project_name} created successfully at #{target_dir}", color: :green
|
140
124
|
|
141
125
|
elsif command == "version"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
class RubeeAppTest < Minitest::Test
|
4
|
+
include Rack::Test::Methods
|
5
|
+
|
6
|
+
def app
|
7
|
+
Rubee::Application.instance
|
8
|
+
end
|
9
|
+
|
10
|
+
def setup
|
11
|
+
Rubee::Autoload.call
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
# detach auth methods
|
16
|
+
if WelcomeController.instance_variable_defined?(:@auth_methods)
|
17
|
+
WelcomeController.send(:remove_instance_variable, :@auth_methods)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_welcome_controller_included_auth_tokenable
|
22
|
+
WelcomeController.include(AuthTokenable)
|
23
|
+
WelcomeController.auth_methods :show
|
24
|
+
|
25
|
+
get '/'
|
26
|
+
|
27
|
+
assert_equal last_response.status, 401
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
class RubeeAppTest < Minitest::Test
|
4
|
+
include Rack::Test::Methods
|
5
|
+
|
6
|
+
def app
|
7
|
+
Rubee::Application.instance
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
def test_welcome_route
|
12
|
+
get '/'
|
13
|
+
|
14
|
+
assert_equal 200, last_response.status, "Unexpected response: #{last_response.body}"
|
15
|
+
assert_includes last_response.body, 'All set up and running!'
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def test_not_found_route
|
20
|
+
get '/random'
|
21
|
+
|
22
|
+
assert_equal 404, last_response.status
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe 'User model' do
|
4
|
+
describe ".create" do
|
5
|
+
after do
|
6
|
+
User.destroy_all
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'when data is valid' do
|
10
|
+
it 'persists to db' do
|
11
|
+
user = User.create(email: "ok-test@test.com", password: "123")
|
12
|
+
|
13
|
+
_(user.persisted?).must_equal true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'when data is invalid' do
|
18
|
+
it 'is not changing users number' do
|
19
|
+
initial_count = User.all.count
|
20
|
+
User.create(wrong: "test@test") rescue nil
|
21
|
+
|
22
|
+
_(User.all.count).must_equal initial_count
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '.save' do
|
28
|
+
after do
|
29
|
+
User.destroy_all
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'when data is valid' do
|
33
|
+
it 'persists to db' do
|
34
|
+
user = User.new(email: "ok-test@test.com", password: "123")
|
35
|
+
user.save
|
36
|
+
|
37
|
+
_(user.persisted?).must_equal true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'when save existing user' do
|
42
|
+
it 'persists to db' do
|
43
|
+
user = User.new(email: "ok-test@test.com", password: "123")
|
44
|
+
user.save
|
45
|
+
|
46
|
+
_(user.reload.password).must_equal "123"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'when data is invalid' do
|
51
|
+
it 'is not changing users number' do
|
52
|
+
initial_count = User.all.count
|
53
|
+
user = User.new(wrong: "test@test") rescue nil
|
54
|
+
user.save rescue nil
|
55
|
+
|
56
|
+
_(User.all.count).must_equal initial_count
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -1,10 +1,9 @@
|
|
1
|
-
require_relative File.join(File.expand_path(Dir.pwd), 'lib', 'rubee.rb')
|
2
|
-
|
3
1
|
require "bundler/setup"
|
4
|
-
Bundler.require(:
|
2
|
+
Bundler.require(:test)
|
5
3
|
|
6
4
|
require 'minitest/autorun'
|
7
5
|
require 'rack/test'
|
6
|
+
require 'rubee'
|
8
7
|
|
9
8
|
Rubee::Autoload.call
|
10
9
|
|
@@ -38,6 +38,15 @@ describe 'User model' do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
describe 'when save existing user' do
|
42
|
+
it 'persists to db' do
|
43
|
+
user = User.new(email: "ok-test@test.com", password: "123")
|
44
|
+
user.save
|
45
|
+
|
46
|
+
_(user.reload.password).must_equal "123"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
41
50
|
describe 'when data is invalid' do
|
42
51
|
it 'is not changing users number' do
|
43
52
|
initial_count = User.all.count
|
data/lib/rubee.rb
CHANGED
@@ -138,8 +138,7 @@ module Rubee
|
|
138
138
|
require_relative file unless black_list.include?("#{file}.rb")
|
139
139
|
end
|
140
140
|
# app inits
|
141
|
-
|
142
|
-
Dir[File.join(APP_ROOT, lib_dir, 'inits/**', '*.rb')].each do |file|
|
141
|
+
Dir[File.join(APP_ROOT, 'inits/**', '*.rb')].each do |file|
|
143
142
|
require_relative file unless black_list.include?("#{file}.rb")
|
144
143
|
end
|
145
144
|
# rubee async
|
@@ -147,8 +146,8 @@ module Rubee
|
|
147
146
|
require_relative file unless black_list.include?("#{file}.rb")
|
148
147
|
end
|
149
148
|
# app config and routes
|
150
|
-
require_relative File.join(APP_ROOT,
|
151
|
-
require_relative File.join(APP_ROOT,
|
149
|
+
require_relative File.join(APP_ROOT, "config/base_configuration") unless black_list.include?('base_configuration.rb')
|
150
|
+
require_relative File.join(APP_ROOT, "config/routes") unless black_list.include?('routes.rb')
|
152
151
|
# rubee extensions
|
153
152
|
Dir[File.join(root_directory, "rubee/extensions/**", '*.rb')].each do |file|
|
154
153
|
require_relative file unless black_list.include?("#{file}.rb")
|
data/lib/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
VERSION = '1.1.
|
1
|
+
VERSION = '1.1.1'
|
data/readme.md
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|

|
2
2
|

|
3
|
+

|
4
|
+

|
5
|
+

|
3
6
|

|
4
7
|
|
5
8
|
|
6
|
-
# <img src="images/rubee.svg" alt="
|
9
|
+
# <img src="lib/images/rubee.svg" alt="ru.Bee" height="40"> ... ru.Bee
|
7
10
|
|
8
|
-
|
11
|
+
ru.Bee is a fast and lightweight Ruby application server designed for minimalism and flexibility .
|
9
12
|
|
10
|
-
The main philosophy of
|
13
|
+
The main philosophy of ru.Bee is to focus on Ruby language explicit implementation of the MVC web application.
|
11
14
|
|
12
15
|
Want to get a quick API server up and runing? You can do it for real quick!
|
13
16
|
<br />
|
14
|
-
|
17
|
+
[](https://www.youtube.com/watch?v=ko7H70s7qq0)
|
15
18
|
|
16
19
|
All greaet features are yet to come!
|
17
20
|
|
@@ -24,7 +27,7 @@ All greaet features are yet to come!
|
|
24
27
|
- **Router**: Router driven - generates all required files from the routes.
|
25
28
|
- **Databases**: Sqlite3, Postgres, Mysql and many more supported by sequel gem.
|
26
29
|
- **Views**: Json, ERB and plain HTML
|
27
|
-
- **Bundlable** Charge your
|
30
|
+
- **Bundlable** Charge your ru.Bee with any gem you need and update your project with bundle.
|
28
31
|
- **ORM** All models are natively ORM objects, however you can use it as a blueurpint for any datasources.
|
29
32
|
- **Authentificatable** Add JWT authentification easily to any controller action.
|
30
33
|
- **Hooks** Add logic before, after and around any action.
|
@@ -33,7 +36,7 @@ All greaet features are yet to come!
|
|
33
36
|
|
34
37
|
## Installation
|
35
38
|
|
36
|
-
1. Install
|
39
|
+
1. Install ru.Bee
|
37
40
|
```bash
|
38
41
|
gem install ru.Bee
|
39
42
|
```
|
@@ -47,7 +50,7 @@ cd my_project
|
|
47
50
|
3. Install dependencies
|
48
51
|
|
49
52
|
***Prerequisites***<br />
|
50
|
-
**
|
53
|
+
**ru.Bee** is using **Sqlite** as a default database. However you can pick up any other database supported by sequel gem.
|
51
54
|
Aside that, make sure:
|
52
55
|
**Ruby** language (3+) is installed
|
53
56
|
**Bundler** is installed
|
@@ -56,7 +59,7 @@ Aside that, make sure:
|
|
56
59
|
bundle install
|
57
60
|
```
|
58
61
|
|
59
|
-
4. Run
|
62
|
+
4. Run ru.Bee server. Default port is 7000
|
60
63
|
```bash
|
61
64
|
rubee start
|
62
65
|
```
|
@@ -94,7 +97,7 @@ rubee generate get /apples
|
|
94
97
|
4. Fill those files with the logic you need and run the server again!
|
95
98
|
|
96
99
|
## Model
|
97
|
-
Model in
|
100
|
+
Model in ru.Bee is just simple ruby object that can be serilalized in the view
|
98
101
|
in the way it required (ie json).
|
99
102
|
|
100
103
|
Here below is a simple example on how it can be used by rendering json from in memory object
|
@@ -143,11 +146,11 @@ So in the controller you would need to query your target object now.
|
|
143
146
|
```
|
144
147
|
|
145
148
|
## Views
|
146
|
-
View in
|
149
|
+
View in ru.Bee is just a plain html/erb file that can be rendered from the controller.
|
147
150
|
|
148
151
|
## Object hooks
|
149
152
|
|
150
|
-
In
|
153
|
+
In ru.Bee by extending Hookable module any Ruby object can be charged with hooks (logic),
|
151
154
|
that can be executed before, after and around a specific method execution.
|
152
155
|
|
153
156
|
Here below a controller example. However it can be used in any Ruby object, like Model etc.
|
@@ -225,7 +228,7 @@ class UsersController < Rubee::BaseController
|
|
225
228
|
# POST /usres/logout (logout logic)
|
226
229
|
def logout
|
227
230
|
unauthentificate! # AuthTokenable method aimed to handle logout action.
|
228
|
-
# Make sure @zeroed_token_header is
|
231
|
+
# Make sure @zeroed_token_header is paRssed within headers options
|
229
232
|
response_with type: :redirect, to: "/users/login", headers: @zeroed_token_header
|
230
233
|
end
|
231
234
|
|
@@ -265,7 +268,7 @@ rubee console # start the console
|
|
265
268
|
rubee test # run all tests
|
266
269
|
rubee test auth_tokenable_test.rb # run specific tests
|
267
270
|
```
|
268
|
-
If you want to run any
|
271
|
+
If you want to run any ru.Bee command within a specific ENV make sure you added it before a command.
|
269
272
|
For instance if you want to run console in test environment you need to run the following command
|
270
273
|
|
271
274
|
```bash
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ru.Bee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleg Saltykov
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-03-
|
10
|
+
date: 2025-03-17 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: bundler
|
@@ -42,6 +42,10 @@ files:
|
|
42
42
|
- lib/Dockerfile
|
43
43
|
- lib/app/controllers/welcome_controller.rb
|
44
44
|
- lib/app/models/user.rb
|
45
|
+
- lib/app/tests/auth_tokenable_test.rb
|
46
|
+
- lib/app/tests/rubeeapp_test.rb
|
47
|
+
- lib/app/tests/test_helper.rb
|
48
|
+
- lib/app/tests/user_model_test.rb
|
45
49
|
- lib/app/views/welcome_show.erb
|
46
50
|
- lib/config.ru
|
47
51
|
- lib/config/base_configuration.rb
|