ru.Bee 2.2.1 → 2.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79e7b11e20b2e610c5559d28354d950b38a71e1bd19731b86f962ccc2f6851b0
4
- data.tar.gz: 27b7137b3328a511782c412efd960aa68c93c3ac54f261383014390f45bea3d1
3
+ metadata.gz: 4958166a93833b8937bd8fddff68db21fac7fe6c4b10c9f3ad41aa41c81342b6
4
+ data.tar.gz: 8317204f759ec29ec13aaaba6a6ceac200963298cfc07256f4d0b03cb249a1dc
5
5
  SHA512:
6
- metadata.gz: 05ac2caaca3d97b2c6eca2ba86848956406a68a871f30f9529be79ed95681f50f8beacadd32b0a0c537fbb6dd68581aeaaae2403804948526b83bad77e2657c5
7
- data.tar.gz: 57cdb088e5165d4374a929969b890443594f765f296ea80adc722be6ef232a6d98cec5d07ffb86890692fdefa94089c5509b3a5d9a2fb3cf7e0be761b5787153
6
+ metadata.gz: 8d3e0faa28a8aa69cf8aa0727b290bd6888f52241dd87b8cb59b3c9e725331c6c80779cf79ff63a7e73e588e1663ab1d2d050842d5f7fdeeea3b8e50b3016bdb
7
+ data.tar.gz: e636773215ef25384a159b49024b1d965f3dbc1e5fff08b696779a7000637536e85e492dd6228bdd38f06757c6762bed59b9f8b42749dba1ebc674df05be1aa0
@@ -12,5 +12,27 @@ module ChargedHash
12
12
  def wrap(value)
13
13
  value.is_a?(Hash) ? value.extend(ChargedHash) : value
14
14
  end
15
+
16
+ def keys_to_string!
17
+ keys_to(:string, self)
18
+ end
19
+
20
+ def keys_to_sym!
21
+ keys_to(:symbol, self)
22
+ end
23
+
24
+ def keys_to(type, obj)
25
+ case obj
26
+ when Hash
27
+ obj.each_with_object({}) do |(k, v), result|
28
+ key = k.to_s
29
+ result[key] = keys_to(type, v)
30
+ end
31
+ when Array
32
+ obj.map { |v| keys_to(type, v) }
33
+ else
34
+ obj
35
+ end
36
+ end
15
37
  end
16
38
  end
data/lib/inits/system.rb CHANGED
@@ -3,5 +3,3 @@ def reload
3
3
  app_files.each { |file| load(file) }
4
4
  puts "\e[32mReloaded..\e[0m"
5
5
  end
6
-
7
-
@@ -80,7 +80,7 @@ module Rubee
80
80
  react_app_file = <<~REACT_APP_FILE
81
81
  import React from 'react';
82
82
 
83
- export function #{new_app_name.camelize}App() {
83
+ export default function #{new_app_name.camelize}App() {
84
84
  return (
85
85
  <h1>#{new_app_name.camelize}App</h1>
86
86
  );
@@ -67,7 +67,7 @@ module Rubee
67
67
  in :unauthentificated
68
68
  [401, headers.merge('content-type' => 'text/plain'), ['Unauthentificated']]
69
69
  in :redirect
70
- [302, headers.merge('location' => to.to_s), ['Unauthentificated']]
70
+ [302, headers.merge('location' => to.to_s), []]
71
71
  in :not_found
72
72
  [404, { 'content-type' => 'text/plain' }, ['Route not found']]
73
73
  else # rendering erb view is a default behavior
@@ -34,7 +34,7 @@ module Rubee
34
34
  elsif @request.cookies['jwt'] && valid_token?
35
35
  token = @request.cookies['jwt']
36
36
  hash = ::JWT.decode(token, Rubee::AuthTokenable::KEY, true, { algorithm: 'HS256' })
37
- @authentificated_user ||= user_model.where(login => hash[0][login]).first
37
+ @authentificated_user ||= user_model.where(login => hash[0]["login"][login.to_s]).first
38
38
  end
39
39
  end
40
40
 
@@ -6,6 +6,7 @@ module Rubee
6
6
  def initialize(model_name, model_attributes, controller_name, action_name, **options)
7
7
  @model_name = model_name&.downcase
8
8
  @model_attributes = model_attributes || []
9
+ @filtered_attributes = model_attributes.select { |attribute| !attribute[:name].include?('index') }
9
10
  @base_name = controller_name.to_s.gsub('Controller', '').downcase.to_s
10
11
  color_puts("base_name: #{@base_name}", color: :gray)
11
12
  @plural_name = @base_name.plural? ? @base_name : @base_name.pluralize
@@ -33,7 +34,7 @@ module Rubee
33
34
 
34
35
  content = <<~RUBY
35
36
  class #{@namespace}#{@model_name.camelize} < Rubee::SequelObject
36
- #{'attr_accessor ' + @model_attributes.map { |hash| ":#{hash[:name]}" }.join(', ') unless @model_attributes.empty?}
37
+ #{'attr_accessor ' + @filtered_attributes.map { |hash| ":#{hash[:name]}" }.join(', ') unless @filtered_attributes.empty?}
37
38
  end
38
39
  RUBY
39
40
 
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.2.1'
20
+ VERSION = '2.2.3'
21
21
 
22
22
  require_relative 'rubee/router'
23
23
  require_relative 'rubee/logger'
@@ -1,12 +1,29 @@
1
1
  require_relative '../test_helper'
2
2
 
3
- class WebSocketControllerTest < Minitest::Test
3
+ class TestRedirectController < Rubee::BaseController
4
+ def index
5
+ response_with(type: :redirect, to: '/test')
6
+ end
7
+
8
+ def test
9
+ response_with(type: :json, object: { ok: :ok })
10
+ end
11
+ end
12
+
13
+ class BaseControllerTest < Minitest::Test
4
14
  include Rack::Test::Methods
5
15
 
6
16
  def app
7
17
  Rubee::Application.instance
8
18
  end
9
19
 
20
+ def setup
21
+ Rubee::Router.draw do |route|
22
+ route.get('/test', to: 'test_redirect#test')
23
+ route.get('/index', to: 'test_redirect#index')
24
+ end
25
+ end
26
+
10
27
  def test_retrieve_image
11
28
  get('/images/rubee.svg')
12
29
 
@@ -20,4 +37,12 @@ class WebSocketControllerTest < Minitest::Test
20
37
  assert_equal(200, last_response.status, "Unexpected response: #{last_response.body}")
21
38
  assert_equal('Image not found', last_response.body, "Unexpected response: #{last_response.body}")
22
39
  end
40
+
41
+ def test_redirect
42
+ get('/index')
43
+
44
+ assert_equal(302, last_response.status)
45
+ assert_equal('/test', last_response.headers['Location'])
46
+ assert_equal('', last_response.body)
47
+ end
23
48
  end
data/lib/tests/test.db CHANGED
Binary file
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.2.1
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Saltykov
@@ -45,10 +45,8 @@ files:
45
45
  - lib/app/controllers/welcome_controller.rb
46
46
  - lib/app/models/user.rb
47
47
  - lib/app/views/App.tsx
48
- - lib/app/views/apples_.erb
49
48
  - lib/app/views/index.html
50
49
  - lib/app/views/layout.erb
51
- - lib/app/views/s_.erb
52
50
  - lib/app/views/utils/redirectToBackend.tsx
53
51
  - lib/app/views/welcome_header.erb
54
52
  - lib/app/views/welcome_show.erb
@@ -1 +0,0 @@
1
- <h1>apples_ View</h1>
data/lib/app/views/s_.erb DELETED
@@ -1 +0,0 @@
1
- <h1>s_ View</h1>