ru.Bee 3.0.0 → 3.0.1

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: 6a38b359191859d1d0d22a355a81a3b86c760c5ab3ba33f1ac13059f14c6b69b
4
- data.tar.gz: f0c8763134b4ad81e0db61b9926bb0f8e292ad4c0e328cbd1ae2960cf9155f3d
3
+ metadata.gz: b28e888cbb426de4174be8a59d2692b00fc3377992c9f5ec60c88f7192f92242
4
+ data.tar.gz: 35bef19fdb83b5fad826831fa6b70b79b93636673c09730e3eed5c2ec1cc982a
5
5
  SHA512:
6
- metadata.gz: e69bfd2ff4cae80bf4a2821feeb396f23da0dbdf3fd74f9405dd4e89feb0d2ba938d138372d140a921322916d70097766efd65a6cdf654ca6a469dcde29b1263
7
- data.tar.gz: 2f2cbf3d544b9c89322e2f79d7a10bd53d3aadb5d592dbc890f482a87efd021b1276c77ab7e2828a342443637cd21bfa9ea25db79778a46993284a4e8df8144e
6
+ metadata.gz: 68d08ae55a2058593c4d465bce2eb3d112bbfdc1f9772e8116e50ba0b0da062dc37cca9dd173fb35f479b7d9a18a39213492abdd83d050702d32463cef1a2e42
7
+ data.tar.gz: 11e6221754f7f854833a4eeebea16e0970a5ff5cddd1cda02b8208e10f4f3f686c7ffd549eaeaa22a357a714b5e465a514f7e2afffb58f7943f9727bb9563e67
data/lib/db/test.db CHANGED
Binary file
@@ -3,6 +3,8 @@ module Rubee
3
3
  BLACKLIST = ['rubee.rb', 'test_helper.rb', 'puma.rb']
4
4
  class << self
5
5
  def call(black_list = [], **options)
6
+ load_envs!
7
+
6
8
  load_whitelisted(options[:white_list_dirs]) && return if options[:white_list_dirs]
7
9
  # Autoload all rbs
8
10
  root_directory = File.join(Rubee::ROOT_PATH, '/lib')
@@ -60,7 +62,7 @@ module Rubee
60
62
  end
61
63
  end
62
64
 
63
- def load_envs!(prefix = ENV['RACK_ENV'], root_directory)
65
+ def load_envs!(prefix = ENV['RACK_ENV'], root_directory = File.join(Rubee::APP_ROOT, Rubee::LIB))
64
66
  env_file_name = "#{root_directory}/.#{prefix}.env"
65
67
  File.foreach(env_file_name) do |line|
66
68
  line = line.strip
@@ -86,7 +88,6 @@ module Rubee
86
88
  end
87
89
  load_support(root_directory, black_list)
88
90
 
89
- load_envs!(ENV['RACK_ENV'], root_directory)
90
91
  # app config and routes
91
92
  unless black_list.include?('base_configuration.rb')
92
93
  require_relative File.join(Rubee::APP_ROOT, Rubee::LIB, 'config/base_configuration')
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 = '3.0.0'
23
+ VERSION = '3.0.1'
24
24
 
25
25
  require_relative 'rubee/router'
26
26
  require_relative 'rubee/logger'
data/readme.md CHANGED
@@ -25,7 +25,7 @@ Starting from ru.Bee 2.0.0, ru.Bee supports WebSocket, which allows you to build
25
25
 
26
26
  ## Production ready
27
27
 
28
- Take a look at the ru.Bee demo site with full documentation: https://rubee.dedyn.io/
28
+ Take a look at the ru.Bee demo site with full documentation: https://rubee.dedyn.io/ (site is currently under maintenance)
29
29
  Want to explore how it was built? https://github.com/nucleom42/rubee-site
30
30
 
31
31
  ## Stress tested
@@ -83,12 +83,15 @@ The comparison is based on generic and subjective information available on the i
83
83
  - [Object hooks](#object-hooks)
84
84
  - [Validations](#validations)
85
85
  - [JWT based authentication](#jwt-based-authentication)
86
+ - [Authorizable](#authorizable)
86
87
  - [OAuth authentication](#oauth-authentication)
87
88
  - [ru.Bee commands](#rubee-commands)
88
89
  - [Generate commands](#generate-commands)
89
90
  - [Migration commands](#migration-commands)
90
91
  - [ru.Bee console](#rubee-console)
91
92
  - [Rubee::Support](#rubee-support)
93
+ - [Time Extensions](#time-extensions)
94
+ - [Environment Configuration](#environment-configuration)
92
95
  - [Testing](#testing)
93
96
  - [Background jobs](#background-jobs)
94
97
  - [Sidekiq engine](#sidekiq-engine)
@@ -97,7 +100,7 @@ The comparison is based on generic and subjective information available on the i
97
100
  - [Logger](#logger)
98
101
  - [WebSocket](#websocket)
99
102
  - [Bee assistant](#bee-assistant)
100
- - [Middleware integration](#middleware-integration)
103
+ - [Middleware integration](#middleware-integration))
101
104
 
102
105
 
103
106
  You can read the full docs on the demo site: [rubee.dedyn.io](https://rubee.dedyn.io/)
@@ -126,6 +129,12 @@ ORM-agnostic – Models are native ORM objects, but you can use them as blueprin
126
129
  <br>
127
130
  Authenticatable – Easily add JWT authentication to any controller action.
128
131
  <br>
132
+ Authorizable – Declarative role-based authorization for controller actions. (New in 3.0.0)
133
+ <br>
134
+ Time Extensions – Comprehensive helper methods for date and time manipulation. (New in 3.0.0)
135
+ <br>
136
+ Environment Configuration – Load environment variables from .env files per environment. (New in 3.0.0)
137
+ <br>
129
138
  Hooks – Add logic before, after, or around any controller action.
130
139
  <br>
131
140
  Testable – Run all or selected tests using fast, beloved Minitest.
@@ -1088,6 +1097,58 @@ Rubee::Configuration.development?
1088
1097
 
1089
1098
  [Back to content](#content)
1090
1099
 
1100
+ ## Time Extensions
1101
+
1102
+ The Time class includes a comprehensive set of helper methods for common date and time manipulations. (New in 3.0.0)
1103
+
1104
+ ### Instance Methods
1105
+
1106
+ | Method | Description | Example |
1107
+ | :--- | :--- | :--- |
1108
+ | `days_seconds` | Returns the total number of seconds elapsed since midnight. | `Time.now.days_seconds` |
1109
+ | `beginning_of_day` | Returns a new `Time` object set to the start of the day (00:00:00). | `Time.now.beginning_of_day` |
1110
+ | `end_of_day` | Returns a new `Time` object set to the end of the day (23:59:59). | `Time.now.end_of_day` |
1111
+ | `at(hour, min, sec)` | Returns a new `Time` object for the same date but with the specified time. | `Time.now.at(10, 30, 0)` |
1112
+ | `all_day` | Returns a `Range` from the beginning to the end of the day. | `Time.now.all_day` |
1113
+ | `add_days(n)` | Returns a new `Time` object `n` days in the future. | `Time.now.add_days(5)` |
1114
+ | `subtract_days(n)` | Returns a new `Time` object `n` days in the past. | `Time.now.subtract_days(5)` |
1115
+ | `closest_future_working_day` | Returns the next working day (Monday–Friday). | `Time.now.closest_future_working_day` |
1116
+ | `with_current_time` | Returns a new `Time` object with the same date but the current time of day. | `Time.now.with_current_time` |
1117
+
1118
+ ### Class Methods
1119
+
1120
+ | Method | Description |
1121
+ | :--- | :--- |
1122
+ | `Time.today` | Returns the current `Time` object for today. |
1123
+ | `Time.tomorrow` | Returns a `Time` object for tomorrow. |
1124
+ | `Time.yesterday` | Returns a `Time` object for yesterday. |
1125
+ | `Time.beginning_of_today` | Returns a `Time` object for the start of today (00:00:00). |
1126
+ | `Time.end_of_today` | Returns a `Time` object for the end of today (23:59:59). |
1127
+ | `Time.start_of_today` | Alias for `Time.beginning_of_today`. |
1128
+
1129
+ [Back to content](#content)
1130
+
1131
+ ## Environment Configuration
1132
+
1133
+ Starting from version 3.0.0, ru.Bee supports loading environment-specific variables from `.env` files, providing a more secure and organized way to manage configuration.
1134
+
1135
+ The system automatically loads files based on the `RACK_ENV` environment variable:
1136
+ - `.development.env` - loaded when `RACK_ENV=development`
1137
+ - `.test.env` - loaded when `RACK_ENV=test`
1138
+ - `.production.env` - loaded when `RACK_ENV=production`
1139
+
1140
+ ### Example `.env` file
1141
+
1142
+ ```bash
1143
+ # .development.env
1144
+ DATABASE_URL=postgres://localhost:5432/myapp_development
1145
+ SECRET_KEY_BASE=your_secret_key_here
1146
+ API_KEY=abc123
1147
+ ```
1148
+ Place your .env files in the root of your project. The variables will be automatically loaded when the application starts and will be available via ENV
1149
+
1150
+ [Back to content](#content)
1151
+
1091
1152
  ## JWT based authentication
1092
1153
 
1093
1154
  Include the `AuthTokenable` module in your controller and authenticate any action you need.
@@ -1146,6 +1207,41 @@ end
1146
1207
 
1147
1208
  [Back to content](#content)
1148
1209
 
1210
+ ## Authorizable
1211
+
1212
+ Starting from version 3.0.0, ru.Bee includes a declarative authorization system for controller actions. The `Authorizable` module is now part of `Rubee::BaseController` and allows you to restrict access based on user roles.
1213
+
1214
+ ### Basic Usage
1215
+
1216
+ ```ruby
1217
+ class AdminController < Rubee::BaseController
1218
+ authorize(admin: [:dashboard, :manage_users], model: :user, role_field: :role)
1219
+
1220
+ def dashboard
1221
+ response_with object: { message: "Admin dashboard" }, type: :json
1222
+ end
1223
+
1224
+ def manage_users
1225
+ response_with object: User.all, type: :json
1226
+ end
1227
+ end
1228
+ ```
1229
+ Parameters
1230
+
1231
+ role - The role required to access the actions (e.g., :admin, :user)
1232
+ model - The model class to check roles against (default: :user)
1233
+ role_field - The field in the model that stores the role (default: :role)
1234
+ response_hash - Custom response hash for unauthorized access (optional)
1235
+
1236
+ ```ruby
1237
+ class AdminController < Rubee::BaseController
1238
+ authorize(admin: [:dashboard],
1239
+ model: :user,
1240
+ response_hash: { object: { error: "Access denied" }, status: 403 })
1241
+ ```
1242
+
1243
+ [Back to content](#content)
1244
+
1149
1245
  ## OAuth authentication
1150
1246
 
1151
1247
  To plug in OAuth 2.0 authentication, add the `oauth2` gem to your Gemfile:
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: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Saltykov