ree_lib 1.0.76 → 1.0.78
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/.ruby-version +1 -1
- data/Gemfile.lock +2 -2
- data/lib/ree_lib/packages/ree_dao/package/ree_dao/dataset_extensions.rb +2 -2
- data/lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/build_pg_connection_spec.rb +10 -0
- data/lib/ree_lib/packages/ree_roda/package/ree_roda/plugins/ree_routes.rb +40 -36
- data/lib/ree_lib/packages/ree_roda/spec/ree_roda/app_spec.rb +20 -0
- data/lib/ree_lib/packages/ree_routes/package/ree_routes/route.rb +1 -1
- data/lib/ree_lib/packages/ree_routes/package/ree_routes/route_builder.rb +6 -0
- data/lib/ree_lib/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c3323a878bb1c2a2d2a629f616a31ff63bc8d64dbbc8c070aa82bc8483d920e
|
4
|
+
data.tar.gz: f9a81546f833cc528f7407f08bd1141553e38fe8124128924ca0a6cc963a4e20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ecd161b8070aec4e06e9c30f7397b139d9a954476db9a73ed42d927051b07ff24b30afef38421cf999711f2f3beeb51700246e1067e6e6db5da5a8f2b3c0200
|
7
|
+
data.tar.gz: 5d80bb2e3a93dd25190312c4eafba0d5680e8d13d63c85b645a9fbc71d2bce807ebd8d4255bc99f7d0bdb0d33c98a39b9e8a0809fca92227739a9c7c5df345c4
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.2.0
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ree_lib (1.0.
|
4
|
+
ree_lib (1.0.78)
|
5
5
|
binding_of_caller (~> 1.0.0)
|
6
6
|
i18n (~> 1.12.0)
|
7
7
|
loofah (~> 2.18.0)
|
@@ -45,7 +45,7 @@ GEM
|
|
45
45
|
oj (3.13.23)
|
46
46
|
pg (1.4.6)
|
47
47
|
public_suffix (5.0.1)
|
48
|
-
racc (1.7.
|
48
|
+
racc (1.7.3)
|
49
49
|
rack (3.0.5)
|
50
50
|
rack-test (2.0.2)
|
51
51
|
rack (>= 1.3)
|
@@ -83,14 +83,14 @@ module ReeDao
|
|
83
83
|
return if entities.empty?
|
84
84
|
|
85
85
|
mapper = opts[:schema_mapper]
|
86
|
-
columns = columns
|
86
|
+
columns = self.columns
|
87
87
|
raw = {}
|
88
88
|
|
89
89
|
columns.delete(:id)
|
90
90
|
columns.delete(:row)
|
91
91
|
|
92
92
|
data = entities.map do |entity|
|
93
|
-
hash = mapper.
|
93
|
+
hash = mapper.db_dump(entity)
|
94
94
|
raw[entity] = hash
|
95
95
|
|
96
96
|
columns.map { hash[_1] }
|
@@ -147,4 +147,14 @@ RSpec.describe :build_pg_connection do
|
|
147
147
|
expect(product.info[:price]).to eq(1440)
|
148
148
|
expect(product.labels).to eq(["Sale", "New"])
|
149
149
|
}
|
150
|
+
|
151
|
+
it "insert multiple records" do
|
152
|
+
products_dao.delete_all
|
153
|
+
|
154
|
+
products = Array.new(3) { |i| ReeDaoTestPg::Product.new(title: "Product#{i}", info: { price: 1337, count: 200 }, labels: ["Sale"]) }
|
155
|
+
|
156
|
+
products_dao.import_all(products)
|
157
|
+
|
158
|
+
expect(products_dao.count).to eq 3
|
159
|
+
end
|
150
160
|
end
|
@@ -71,50 +71,54 @@ class Roda
|
|
71
71
|
def route_proc(route, context)
|
72
72
|
Proc.new do |r|
|
73
73
|
r.send(route.request_method) do
|
74
|
-
|
75
|
-
|
74
|
+
if route.override
|
75
|
+
route.override.call(r)
|
76
|
+
else
|
77
|
+
r.send(route.respond_to) do
|
78
|
+
r.env["warden"].authenticate!(scope: route.warden_scope)
|
76
79
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
+
if context.opts[:ree_routes_before]
|
81
|
+
r.instance_exec(@_request, route.warden_scope, &r.scope.opts[:ree_routes_before])
|
82
|
+
end
|
80
83
|
|
81
|
-
|
84
|
+
params = r.params
|
82
85
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
86
|
+
if r.body
|
87
|
+
body = begin
|
88
|
+
JSON.parse(r.body.read)
|
89
|
+
rescue => e
|
90
|
+
{}
|
91
|
+
end
|
89
92
|
|
90
|
-
|
91
|
-
|
93
|
+
params = params.merge(body)
|
94
|
+
end
|
92
95
|
|
93
|
-
|
96
|
+
not_blank = ReeObject::NotBlank.new
|
94
97
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
+
filtered_params = ReeHash::TransformValues.new.call(params) do |k, v|
|
99
|
+
v.is_a?(Array) ? v.select { not_blank.call(_1) } : v
|
100
|
+
end
|
98
101
|
|
99
|
-
|
100
|
-
|
102
|
+
accessor = r.env["warden"].user(route.warden_scope)
|
103
|
+
action_result = get_cached_action(route).call(accessor, filtered_params)
|
101
104
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
105
|
+
if route.serializer
|
106
|
+
serialized_result = get_cached_serializer(route).serialize(action_result)
|
107
|
+
else
|
108
|
+
serialized_result = {}
|
109
|
+
end
|
107
110
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
111
|
+
case route.request_method
|
112
|
+
when :post
|
113
|
+
r.response.status = 201
|
114
|
+
ReeJson::ToJson.new.call(serialized_result)
|
115
|
+
when :put, :delete, :patch
|
116
|
+
r.response.status = 204
|
117
|
+
""
|
118
|
+
else
|
119
|
+
r.response.status = 200
|
120
|
+
ReeJson::ToJson.new.call(serialized_result)
|
121
|
+
end
|
118
122
|
end
|
119
123
|
end
|
120
124
|
|
@@ -152,7 +156,7 @@ class Roda
|
|
152
156
|
route_procs.each do |route_proc|
|
153
157
|
r.instance_exec(r, &route_proc)
|
154
158
|
end
|
155
|
-
|
159
|
+
|
156
160
|
nil
|
157
161
|
end
|
158
162
|
|
@@ -116,6 +116,20 @@ RSpec.describe ReeRoda::App do
|
|
116
116
|
serializer :serializer, **opts
|
117
117
|
end
|
118
118
|
|
119
|
+
get "api/action/:action_id/test_override" do
|
120
|
+
summary "Subaction"
|
121
|
+
warden_scope :visitor
|
122
|
+
sections "some_action"
|
123
|
+
action :action_cmd, **opts
|
124
|
+
serializer :serializer, **opts
|
125
|
+
override do |r|
|
126
|
+
r.json do
|
127
|
+
r.response.status = 200
|
128
|
+
"result"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
119
133
|
get "api/action/:id/subaction" do
|
120
134
|
summary "Subaction"
|
121
135
|
warden_scope :visitor
|
@@ -233,6 +247,12 @@ RSpec.describe ReeRoda::App do
|
|
233
247
|
expect(last_response.body).to eq("{\"result\":\"action_cmd\"}")
|
234
248
|
}
|
235
249
|
|
250
|
+
it {
|
251
|
+
get "api/action/:action_id/test_override"
|
252
|
+
expect(last_response.status).to eq(200)
|
253
|
+
expect(last_response.body).to eq("result")
|
254
|
+
}
|
255
|
+
|
236
256
|
it {
|
237
257
|
post "api/action/1/subaction/2"
|
238
258
|
expect(last_response.status).to eq(201)
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
class ReeRoutes::Route
|
4
4
|
attr_accessor :summary, :request_method, :serializer, :respond_to,
|
5
|
-
:sections, :action, :route, :warden_scope, :path
|
5
|
+
:sections, :action, :route, :warden_scope, :path, :override
|
6
6
|
|
7
7
|
def valid?
|
8
8
|
!action.nil? && !summary.nil? && !warden_scope.nil?
|
data/lib/ree_lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ree_lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.78
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruslan Gatiyatov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ree
|
@@ -1391,7 +1391,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1391
1391
|
- !ruby/object:Gem::Version
|
1392
1392
|
version: '0'
|
1393
1393
|
requirements: []
|
1394
|
-
rubygems_version: 3.
|
1394
|
+
rubygems_version: 3.4.1
|
1395
1395
|
signing_key:
|
1396
1396
|
specification_version: 4
|
1397
1397
|
summary: Ruby Standard Library Extensions
|