ree_lib 1.0.41 → 1.0.43
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/ree_lib/packages/ree_actions/Package.schema.json +3 -0
- data/lib/ree_lib/packages/ree_actions/package/ree_actions/dsl.rb +12 -0
- data/lib/ree_lib/packages/ree_actions/package/ree_actions.rb +1 -0
- data/lib/ree_lib/packages/ree_actions/spec/ree_actions/dsl_spec.rb +110 -0
- data/lib/ree_lib/packages/ree_dao/Package.schema.json +31 -0
- data/lib/ree_lib/packages/ree_dao/package/ree_dao/beans/dao_cache.rb +56 -0
- data/lib/ree_lib/packages/ree_dao/package/ree_dao/dataset_extensions.rb +39 -39
- data/lib/ree_lib/packages/ree_dao/package/ree_dao/functions/build_pg_connection.rb +1 -1
- data/lib/ree_lib/packages/ree_dao/package/ree_dao/functions/drop_cache.rb +15 -0
- data/lib/ree_lib/packages/ree_dao/package/ree_dao/functions/extract_changes.rb +26 -0
- data/lib/ree_lib/packages/ree_dao/package/ree_dao/functions/init_cache.rb +15 -0
- data/lib/ree_lib/packages/ree_dao/package/ree_dao.rb +9 -0
- data/lib/ree_lib/packages/ree_dao/schemas/ree_dao/beans/dao_cache.schema.json +22 -0
- data/lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/build_pg_connection.schema.json +1 -1
- data/lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/drop_cache.schema.json +31 -0
- data/lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/extract_changes.schema.json +45 -0
- data/lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/init_cache.schema.json +31 -0
- data/lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/build_pg_connection_spec.rb +150 -0
- data/lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/build_sqlite_connection_spec.rb +6 -5
- data/lib/ree_lib/packages/ree_mapper/package/ree_mapper.rb +4 -0
- data/lib/ree_lib/packages/ree_roda/package/ree_roda/plugins/ree_routes.rb +10 -6
- data/lib/ree_lib/packages/ree_roda/package/ree_roda/services/build_routing_tree.rb +49 -27
- data/lib/ree_lib/packages/ree_roda/spec/ree_roda/app_spec.rb +30 -1
- data/lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_routing_tree_spec.rb +6 -5
- data/lib/ree_lib/version.rb +1 -1
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1322fe618658e425a1614927faf1ed43252e3b49bc9c953d3ba10de162693217
|
4
|
+
data.tar.gz: 8843b92fb6f84cbd83b1966108ea2a541ae798067b6b1a379c1cb7a1baeebbfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41693ec34aff5834b7aba142dd2fb9a9a10146ce178091a8404d7c143bc6a1bce54b106fdbacac896ccc19df3ef5ef87d41a5a88cf2ad27646362839151a04cc
|
7
|
+
data.tar.gz: eb691d0b59814c5fab063627c6bea39ab8dcfec2f48643e17249a6175d2738c5867ba342776b7967626008757244848ad4abd95dd290f57de119a772b3167d81
|
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.43)
|
5
5
|
binding_of_caller (~> 1.0.0)
|
6
6
|
i18n (~> 1.12.0)
|
7
7
|
loofah (~> 2.18.0)
|
@@ -49,7 +49,7 @@ GEM
|
|
49
49
|
rack (>= 1.3)
|
50
50
|
rainbow (3.1.1)
|
51
51
|
rake (13.0.6)
|
52
|
-
ree (1.0.
|
52
|
+
ree (1.0.28)
|
53
53
|
commander (~> 4.6.0)
|
54
54
|
rexml (3.2.5)
|
55
55
|
roda (3.58.0)
|
@@ -3,11 +3,19 @@ module ReeActions
|
|
3
3
|
def self.included(base)
|
4
4
|
base.extend(ClassMethods)
|
5
5
|
base.include(ReeMapper::DSL)
|
6
|
+
link_dao_cache(base)
|
6
7
|
end
|
7
8
|
|
8
9
|
def self.extended(base)
|
9
10
|
base.extend(ClassMethods)
|
10
11
|
base.include(ReeMapper::DSL)
|
12
|
+
link_dao_cache(base)
|
13
|
+
end
|
14
|
+
|
15
|
+
private_class_method def self.link_dao_cache(base)
|
16
|
+
base.include(Ree::LinkDSL)
|
17
|
+
base.link :drop_cache, as: :__ree_dao_drop_cache, from: :ree_dao
|
18
|
+
base.link :init_cache, as: :__ree_dao_init_cache, from: :ree_dao
|
11
19
|
end
|
12
20
|
|
13
21
|
module ClassMethods
|
@@ -40,6 +48,8 @@ module ReeActions
|
|
40
48
|
alias_method(:__original_call, :call)
|
41
49
|
|
42
50
|
define_method :call do |user_access, attrs|
|
51
|
+
__ree_dao_init_cache
|
52
|
+
|
43
53
|
if self.class.const_defined?(:ActionCaster)
|
44
54
|
caster = self.class.const_get(:ActionCaster)
|
45
55
|
|
@@ -51,6 +61,8 @@ module ReeActions
|
|
51
61
|
else
|
52
62
|
__original_call(user_access, attrs)
|
53
63
|
end
|
64
|
+
ensure
|
65
|
+
__ree_dao_drop_cache
|
54
66
|
end
|
55
67
|
|
56
68
|
nil
|
@@ -1,6 +1,29 @@
|
|
1
1
|
package_require("ree_actions/dsl")
|
2
2
|
|
3
3
|
RSpec.describe ReeActions::DSL, type: [:autoclean] do
|
4
|
+
link :build_sqlite_connection, from: :ree_dao
|
5
|
+
|
6
|
+
before(:all) do
|
7
|
+
connection = build_sqlite_connection({database: 'sqlite_db'})
|
8
|
+
|
9
|
+
if connection.table_exists?(:users)
|
10
|
+
connection.drop_table(:users)
|
11
|
+
end
|
12
|
+
|
13
|
+
if connection.table_exists?(:products)
|
14
|
+
connection.drop_table(:products)
|
15
|
+
end
|
16
|
+
|
17
|
+
connection.create_table :users do
|
18
|
+
primary_key :id
|
19
|
+
|
20
|
+
column :name, 'varchar(256)'
|
21
|
+
column :age, :integer
|
22
|
+
end
|
23
|
+
|
24
|
+
connection.disconnect
|
25
|
+
end
|
26
|
+
|
4
27
|
before do
|
5
28
|
Ree.enable_irb_mode
|
6
29
|
end
|
@@ -15,6 +38,7 @@ RSpec.describe ReeActions::DSL, type: [:autoclean] do
|
|
15
38
|
|
16
39
|
package do
|
17
40
|
depends_on :ree_mapper
|
41
|
+
depends_on :ree_dao
|
18
42
|
end
|
19
43
|
|
20
44
|
class TestAction
|
@@ -42,6 +66,8 @@ RSpec.describe ReeActions::DSL, type: [:autoclean] do
|
|
42
66
|
include Ree::PackageDSL
|
43
67
|
|
44
68
|
package do
|
69
|
+
depends_on :ree_mapper
|
70
|
+
depends_on :ree_dao
|
45
71
|
end
|
46
72
|
|
47
73
|
class TestAction2
|
@@ -59,4 +85,88 @@ RSpec.describe ReeActions::DSL, type: [:autoclean] do
|
|
59
85
|
result = ReeActionsTest::TestAction2.new.call('user_access', {user_id: 1})
|
60
86
|
expect(result).to eq(1)
|
61
87
|
}
|
88
|
+
|
89
|
+
it {
|
90
|
+
module ReeActionsTest
|
91
|
+
include Ree::PackageDSL
|
92
|
+
|
93
|
+
package do
|
94
|
+
depends_on :ree_mapper
|
95
|
+
depends_on :ree_dao
|
96
|
+
end
|
97
|
+
|
98
|
+
class Db
|
99
|
+
include Ree::BeanDSL
|
100
|
+
|
101
|
+
bean :db do
|
102
|
+
singleton
|
103
|
+
factory :build
|
104
|
+
|
105
|
+
link :build_sqlite_connection, from: :ree_dao
|
106
|
+
end
|
107
|
+
|
108
|
+
def build
|
109
|
+
build_sqlite_connection({database: 'sqlite_db'})
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
class User
|
114
|
+
include ReeDto::EntityDSL
|
115
|
+
|
116
|
+
properties(
|
117
|
+
id: Nilor[Integer],
|
118
|
+
name: String,
|
119
|
+
age: Integer,
|
120
|
+
)
|
121
|
+
|
122
|
+
attr_accessor :name
|
123
|
+
end
|
124
|
+
|
125
|
+
class UsersDao
|
126
|
+
include ReeDao::DSL
|
127
|
+
|
128
|
+
dao :users_dao do
|
129
|
+
link :db
|
130
|
+
end
|
131
|
+
|
132
|
+
table :users
|
133
|
+
|
134
|
+
schema ReeActionsTest::User do
|
135
|
+
integer :id, null: true
|
136
|
+
string :name
|
137
|
+
integer :age
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
class TestAction3
|
142
|
+
include ReeActions::DSL
|
143
|
+
|
144
|
+
action :test_action3 do
|
145
|
+
link :users_dao
|
146
|
+
end
|
147
|
+
|
148
|
+
contract Any, Hash => Integer
|
149
|
+
def call(user_access, attrs)
|
150
|
+
user = ReeActionsTest::User.new(name: 'John', age: 30)
|
151
|
+
users_dao.put(user)
|
152
|
+
|
153
|
+
thr = Thread.new {
|
154
|
+
user2 = ReeActionsTest::User.new(name: 'Alex', age: 33)
|
155
|
+
users_dao.put(user2)
|
156
|
+
}
|
157
|
+
|
158
|
+
thr.join
|
159
|
+
|
160
|
+
$thread_group_cache = ReeDao::DaoCache.new.instance_variable_get(:@thread_groups)
|
161
|
+
.dig(Thread.current.group.object_id, :users)
|
162
|
+
|
163
|
+
attrs[:user_id]
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
ReeActionsTest::TestAction3.new.call('user_access', {user_id: 1})
|
169
|
+
expect($thread_group_cache.keys.count).to_not eq(0)
|
170
|
+
expect($thread_group_cache.keys.count).to eq(2)
|
171
|
+
}
|
62
172
|
end
|
@@ -19,6 +19,9 @@
|
|
19
19
|
{
|
20
20
|
"name": "ree_mapper"
|
21
21
|
},
|
22
|
+
{
|
23
|
+
"name": "ree_object"
|
24
|
+
},
|
22
25
|
{
|
23
26
|
"name": "ree_string"
|
24
27
|
}
|
@@ -62,6 +65,34 @@
|
|
62
65
|
"object"
|
63
66
|
]
|
64
67
|
},
|
68
|
+
{
|
69
|
+
"name": "dao_cache",
|
70
|
+
"schema": "packages/ree_dao/schemas/ree_dao/beans/dao_cache.schema.json",
|
71
|
+
"tags": [
|
72
|
+
"object"
|
73
|
+
]
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"name": "drop_cache",
|
77
|
+
"schema": "packages/ree_dao/schemas/ree_dao/functions/drop_cache.schema.json",
|
78
|
+
"tags": [
|
79
|
+
"fn"
|
80
|
+
]
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"name": "extract_changes",
|
84
|
+
"schema": "packages/ree_dao/schemas/ree_dao/functions/extract_changes.schema.json",
|
85
|
+
"tags": [
|
86
|
+
"fn"
|
87
|
+
]
|
88
|
+
},
|
89
|
+
{
|
90
|
+
"name": "init_cache",
|
91
|
+
"schema": "packages/ree_dao/schemas/ree_dao/functions/init_cache.schema.json",
|
92
|
+
"tags": [
|
93
|
+
"fn"
|
94
|
+
]
|
95
|
+
},
|
65
96
|
{
|
66
97
|
"name": "one_to_many",
|
67
98
|
"schema": "packages/ree_dao/schemas/ree_dao/functions/one_to_many.schema.json",
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class ReeDao::DaoCache
|
2
|
+
include Ree::BeanDSL
|
3
|
+
|
4
|
+
bean :dao_cache do
|
5
|
+
link :deep_dup, from: :ree_object
|
6
|
+
|
7
|
+
singleton
|
8
|
+
after_init :setup
|
9
|
+
end
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@thread_groups = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_thread_group_cache(thread_group)
|
16
|
+
@thread_groups[thread_group.object_id] ||= {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def drop_thread_group_cache(thread_group)
|
20
|
+
@thread_groups.delete(thread_group.object_id)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get(table_name, primary_key)
|
24
|
+
add_thread_group_cache(current_thread_group)
|
25
|
+
add_table_name(table_name)
|
26
|
+
|
27
|
+
@thread_groups[current_thread_group.object_id][table_name][primary_key]
|
28
|
+
end
|
29
|
+
|
30
|
+
def set(table_name, primary_key, data)
|
31
|
+
add_thread_group_cache(current_thread_group)
|
32
|
+
add_table_name(table_name)
|
33
|
+
add_primary_key(table_name, primary_key)
|
34
|
+
|
35
|
+
@thread_groups[current_thread_group.object_id][table_name][primary_key] = deep_dup(data)
|
36
|
+
end
|
37
|
+
|
38
|
+
def drop_table_cache(table_name)
|
39
|
+
add_thread_group_cache(current_thread_group)
|
40
|
+
@thread_groups[current_thread_group.object_id].delete(table_name)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def current_thread_group
|
46
|
+
Thread.current.group
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_table_name(thread_group = Thread.current.group, table_name)
|
50
|
+
@thread_groups[thread_group.object_id][table_name] ||= {}
|
51
|
+
end
|
52
|
+
|
53
|
+
def add_primary_key(thread_group = Thread.current.group, table_name, primary_key)
|
54
|
+
@thread_groups[thread_group.object_id][table_name][primary_key] ||= {}
|
55
|
+
end
|
56
|
+
end
|
@@ -19,24 +19,25 @@ module ReeDao
|
|
19
19
|
end
|
20
20
|
|
21
21
|
module InstanceMethods
|
22
|
-
PERSISTENCE_STATE_VARIABLE = :@persistence_state
|
23
22
|
IMPORT_BATCH_SIZE = 1000
|
24
23
|
|
24
|
+
package_require("ree_dao/functions/extract_changes")
|
25
|
+
|
25
26
|
# override methods
|
26
|
-
def find(id,
|
27
|
-
where(primary_key => id).first(
|
27
|
+
def find(id, mapper: nil)
|
28
|
+
where(primary_key => id).first(mapper: mapper)
|
28
29
|
end
|
29
30
|
|
30
|
-
def first(
|
31
|
-
with_mapper(
|
31
|
+
def first(mapper: nil)
|
32
|
+
with_mapper(mapper).__original_first
|
32
33
|
end
|
33
34
|
|
34
|
-
def last(
|
35
|
-
with_mapper(
|
35
|
+
def last(mapper: nil)
|
36
|
+
with_mapper(mapper).__original_last
|
36
37
|
end
|
37
38
|
|
38
|
-
def all(
|
39
|
-
with_mapper(
|
39
|
+
def all(mapper: nil)
|
40
|
+
with_mapper(mapper).__original_all
|
40
41
|
end
|
41
42
|
|
42
43
|
def delete_all
|
@@ -49,7 +50,7 @@ module ReeDao
|
|
49
50
|
key = insert(raw)
|
50
51
|
|
51
52
|
set_entity_primary_key(entity, raw, key)
|
52
|
-
|
53
|
+
set_entity_cache(entity, raw)
|
53
54
|
|
54
55
|
entity
|
55
56
|
end
|
@@ -73,7 +74,7 @@ module ReeDao
|
|
73
74
|
key = insert_conflict(conflict_opts).insert(raw)
|
74
75
|
|
75
76
|
set_entity_primary_key(entity, raw, key)
|
76
|
-
|
77
|
+
set_entity_cache(entity, raw)
|
77
78
|
|
78
79
|
where(primary_key => key).first
|
79
80
|
end
|
@@ -104,7 +105,7 @@ module ReeDao
|
|
104
105
|
raw_data = raw[entity]
|
105
106
|
|
106
107
|
set_entity_primary_key(entity, raw_data, id)
|
107
|
-
|
108
|
+
set_entity_cache(entity, raw_data)
|
108
109
|
end
|
109
110
|
|
110
111
|
nil
|
@@ -115,10 +116,10 @@ module ReeDao
|
|
115
116
|
return __original_update(hash_or_entity) if hash_or_entity.is_a?(Hash)
|
116
117
|
|
117
118
|
raw = opts[:schema_mapper].db_dump(hash_or_entity)
|
118
|
-
raw =
|
119
|
+
raw = ReeDao::ExtractChanges.new.call(table_name, extract_primary_key(hash_or_entity), raw)
|
119
120
|
|
120
121
|
unless raw.empty?
|
121
|
-
|
122
|
+
update_entity_cache(hash_or_entity, raw)
|
122
123
|
key_condition = prepare_key_condition_from_entity(hash_or_entity)
|
123
124
|
where(key_condition).__original_update(raw)
|
124
125
|
end
|
@@ -148,10 +149,18 @@ module ReeDao
|
|
148
149
|
|
149
150
|
private
|
150
151
|
|
152
|
+
def __ree_dao_cache
|
153
|
+
ReeDao::DaoCache.new
|
154
|
+
end
|
155
|
+
|
151
156
|
def primary_key
|
152
157
|
opts[:primary_key] || :id
|
153
158
|
end
|
154
159
|
|
160
|
+
def table_name
|
161
|
+
first_source_table
|
162
|
+
end
|
163
|
+
|
155
164
|
def remove_null_primary_key(raw)
|
156
165
|
return if primary_key.is_a?(Array)
|
157
166
|
|
@@ -166,9 +175,9 @@ module ReeDao
|
|
166
175
|
end
|
167
176
|
end
|
168
177
|
|
169
|
-
def with_mapper(
|
178
|
+
def with_mapper(mapper)
|
170
179
|
clone(
|
171
|
-
|
180
|
+
schema_mapper: mapper || opts[:schema_mapper],
|
172
181
|
).with_row_proc(
|
173
182
|
Proc.new { |hash|
|
174
183
|
m = mapper || opts[:schema_mapper]
|
@@ -176,9 +185,7 @@ module ReeDao
|
|
176
185
|
if m
|
177
186
|
entity = m.db_load(hash)
|
178
187
|
|
179
|
-
|
180
|
-
self.set_persistence_state(entity, hash)
|
181
|
-
end
|
188
|
+
self.set_entity_cache(entity, hash)
|
182
189
|
|
183
190
|
entity
|
184
191
|
else
|
@@ -188,34 +195,27 @@ module ReeDao
|
|
188
195
|
)
|
189
196
|
end
|
190
197
|
|
191
|
-
def
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
previous_column_value = persistence_state[column]
|
199
|
-
|
200
|
-
if persistence_state.has_key?(column) && previous_column_value != value
|
201
|
-
changes[column] = value
|
202
|
-
end
|
198
|
+
def extract_primary_key(entity)
|
199
|
+
if primary_key.is_a?(Array)
|
200
|
+
primary_key.map do |key|
|
201
|
+
entity.send(key)
|
202
|
+
end.join("_")
|
203
|
+
else
|
204
|
+
entity.send(primary_key)
|
203
205
|
end
|
204
|
-
|
205
|
-
changes
|
206
206
|
end
|
207
207
|
|
208
|
-
def
|
208
|
+
def set_entity_cache(entity, raw)
|
209
209
|
if !entity.is_a?(Integer) && !entity.is_a?(Symbol)
|
210
|
-
|
210
|
+
__ree_dao_cache.set(table_name, extract_primary_key(entity), raw)
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
214
|
-
def
|
215
|
-
|
214
|
+
def update_entity_cache(entity, raw)
|
215
|
+
cache = __ree_dao_cache.get(table_name, extract_primary_key(entity))
|
216
216
|
|
217
|
-
if
|
218
|
-
|
217
|
+
if cache
|
218
|
+
__ree_dao_cache.set(table_name, extract_primary_key(entity), cache.merge(raw))
|
219
219
|
end
|
220
220
|
end
|
221
221
|
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ReeDao::ExtractChanges
|
4
|
+
include Ree::FnDSL
|
5
|
+
|
6
|
+
fn :extract_changes do
|
7
|
+
link :dao_cache, as: :__ree_dao_cache
|
8
|
+
end
|
9
|
+
|
10
|
+
contract(Symbol, Any, Hash => Hash)
|
11
|
+
def call(table_name, primary_key, hash)
|
12
|
+
cached = __ree_dao_cache.get(table_name, primary_key)
|
13
|
+
return hash unless cached
|
14
|
+
changes = {}
|
15
|
+
|
16
|
+
hash.each do |column, value|
|
17
|
+
previous_column_value = cached[column]
|
18
|
+
|
19
|
+
if cached.has_key?(column) && previous_column_value != value
|
20
|
+
changes[column] = value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
changes
|
25
|
+
end
|
26
|
+
end
|
@@ -11,7 +11,16 @@ module ReeDao
|
|
11
11
|
depends_on :ree_enum
|
12
12
|
depends_on :ree_mapper
|
13
13
|
depends_on :ree_string
|
14
|
+
depends_on :ree_object
|
14
15
|
end
|
15
16
|
|
16
17
|
require_relative "./ree_dao/dsl"
|
18
|
+
|
19
|
+
def self.init_cache(thread)
|
20
|
+
ReeDao::Cache.init_cache(thread)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.drop_cache(thread)
|
24
|
+
ReeDao::Cache.delete_cache(thread)
|
25
|
+
end
|
17
26
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"schema_type": "object",
|
3
|
+
"schema_version": "1.1",
|
4
|
+
"name": "dao_cache",
|
5
|
+
"path": "packages/ree_dao/package/ree_dao/beans/dao_cache.rb",
|
6
|
+
"mount_as": "object",
|
7
|
+
"class": "ReeDao::DaoCache",
|
8
|
+
"factory": null,
|
9
|
+
"methods": [
|
10
|
+
|
11
|
+
],
|
12
|
+
"links": [
|
13
|
+
{
|
14
|
+
"target": "deep_dup",
|
15
|
+
"package_name": "ree_object",
|
16
|
+
"as": "deep_dup",
|
17
|
+
"imports": [
|
18
|
+
|
19
|
+
]
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}
|
@@ -17,7 +17,7 @@
|
|
17
17
|
{
|
18
18
|
"arg": "conn_opts",
|
19
19
|
"arg_type": "req",
|
20
|
-
"type": "{:conn_str? => String, :adapter => String, :database? => String, :encoding? => String, :user? => String, :password? => String, :host? => String, :port? => String, :convert_infinite_timestamps? => Or[string, nil, float], :connect_timeout? => Integer, :driver_options? => Hash, :notice_receiver? => Proc, :sslmode? => Or[disable, allow, prefer, require, verify-ca, verify-full...], :sslrootcert? => String, :search_path? => String, :use_iso_date_format? => Bool, :max_connections? => Integer}"
|
20
|
+
"type": "{:conn_str? => String, :adapter => String, :database? => String, :encoding? => String, :user? => String, :password? => String, :host? => String, :port? => Or[String, Integer], :convert_infinite_timestamps? => Or[string, nil, float], :connect_timeout? => Integer, :driver_options? => Hash, :notice_receiver? => Proc, :sslmode? => Or[disable, allow, prefer, require, verify-ca, verify-full...], :sslrootcert? => String, :search_path? => String, :use_iso_date_format? => Bool, :max_connections? => Integer}"
|
21
21
|
},
|
22
22
|
{
|
23
23
|
"arg": "opts",
|
@@ -0,0 +1,31 @@
|
|
1
|
+
{
|
2
|
+
"schema_type": "object",
|
3
|
+
"schema_version": "1.1",
|
4
|
+
"name": "drop_cache",
|
5
|
+
"path": "packages/ree_dao/package/ree_dao/functions/drop_cache.rb",
|
6
|
+
"mount_as": "fn",
|
7
|
+
"class": "ReeDao::DropCache",
|
8
|
+
"factory": null,
|
9
|
+
"methods": [
|
10
|
+
{
|
11
|
+
"doc": "",
|
12
|
+
"throws": [
|
13
|
+
|
14
|
+
],
|
15
|
+
"return": "Any",
|
16
|
+
"args": [
|
17
|
+
|
18
|
+
]
|
19
|
+
}
|
20
|
+
],
|
21
|
+
"links": [
|
22
|
+
{
|
23
|
+
"target": "dao_cache",
|
24
|
+
"package_name": "ree_dao",
|
25
|
+
"as": "dao_cache",
|
26
|
+
"imports": [
|
27
|
+
|
28
|
+
]
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
{
|
2
|
+
"schema_type": "object",
|
3
|
+
"schema_version": "1.1",
|
4
|
+
"name": "extract_changes",
|
5
|
+
"path": "packages/ree_dao/package/ree_dao/functions/extract_changes.rb",
|
6
|
+
"mount_as": "fn",
|
7
|
+
"class": "ReeDao::ExtractChanges",
|
8
|
+
"factory": null,
|
9
|
+
"methods": [
|
10
|
+
{
|
11
|
+
"doc": "",
|
12
|
+
"throws": [
|
13
|
+
|
14
|
+
],
|
15
|
+
"return": "Hash",
|
16
|
+
"args": [
|
17
|
+
{
|
18
|
+
"arg": "table_name",
|
19
|
+
"arg_type": "req",
|
20
|
+
"type": "Symbol"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"arg": "primary_key",
|
24
|
+
"arg_type": "req",
|
25
|
+
"type": "Any"
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"arg": "hash",
|
29
|
+
"arg_type": "req",
|
30
|
+
"type": "Hash"
|
31
|
+
}
|
32
|
+
]
|
33
|
+
}
|
34
|
+
],
|
35
|
+
"links": [
|
36
|
+
{
|
37
|
+
"target": "dao_cache",
|
38
|
+
"package_name": "ree_dao",
|
39
|
+
"as": "__ree_dao_cache",
|
40
|
+
"imports": [
|
41
|
+
|
42
|
+
]
|
43
|
+
}
|
44
|
+
]
|
45
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
{
|
2
|
+
"schema_type": "object",
|
3
|
+
"schema_version": "1.1",
|
4
|
+
"name": "init_cache",
|
5
|
+
"path": "packages/ree_dao/package/ree_dao/functions/init_cache.rb",
|
6
|
+
"mount_as": "fn",
|
7
|
+
"class": "ReeDao::InitCache",
|
8
|
+
"factory": null,
|
9
|
+
"methods": [
|
10
|
+
{
|
11
|
+
"doc": "",
|
12
|
+
"throws": [
|
13
|
+
|
14
|
+
],
|
15
|
+
"return": "Any",
|
16
|
+
"args": [
|
17
|
+
|
18
|
+
]
|
19
|
+
}
|
20
|
+
],
|
21
|
+
"links": [
|
22
|
+
{
|
23
|
+
"target": "dao_cache",
|
24
|
+
"package_name": "ree_dao",
|
25
|
+
"as": "dao_cache",
|
26
|
+
"imports": [
|
27
|
+
|
28
|
+
]
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|
@@ -0,0 +1,150 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
package_require("ree_dao/wrappers/pg_jsonb")
|
4
|
+
package_require("ree_dao/wrappers/pg_array")
|
5
|
+
|
6
|
+
RSpec.describe :build_pg_connection do
|
7
|
+
link :build_pg_connection, from: :ree_dao
|
8
|
+
|
9
|
+
DB_CONFIG = {
|
10
|
+
host: "localhost",
|
11
|
+
user: "postgres",
|
12
|
+
database: "postgres",
|
13
|
+
password: "password",
|
14
|
+
adapter: "postgres"
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
after do
|
18
|
+
Ree.disable_irb_mode
|
19
|
+
end
|
20
|
+
|
21
|
+
before :all do
|
22
|
+
connection = build_pg_connection(
|
23
|
+
DB_CONFIG,
|
24
|
+
**{extensions: [:pg_array, :pg_json]}
|
25
|
+
)
|
26
|
+
|
27
|
+
if connection.table_exists?(:products)
|
28
|
+
connection.drop_table(:products)
|
29
|
+
end
|
30
|
+
|
31
|
+
connection.create_table :products do
|
32
|
+
primary_key :id
|
33
|
+
|
34
|
+
column :title, 'varchar(256)'
|
35
|
+
column :info, :jsonb
|
36
|
+
column :labels, :"varchar(30)[]"
|
37
|
+
end
|
38
|
+
|
39
|
+
connection.disconnect
|
40
|
+
end
|
41
|
+
|
42
|
+
Ree.enable_irb_mode
|
43
|
+
|
44
|
+
module ReeDaoTestPg
|
45
|
+
include Ree::PackageDSL
|
46
|
+
|
47
|
+
package do
|
48
|
+
depends_on :ree_dao
|
49
|
+
depends_on :ree_mapper
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class ReeDaoTestPg::MapperFactory
|
54
|
+
include Ree::BeanDSL
|
55
|
+
|
56
|
+
bean :mapper_factory do
|
57
|
+
factory :build
|
58
|
+
singleton
|
59
|
+
|
60
|
+
link :build_mapper_factory, from: :ree_mapper
|
61
|
+
link :build_mapper_strategy, from: :ree_mapper
|
62
|
+
end
|
63
|
+
|
64
|
+
def build
|
65
|
+
factory = build_mapper_factory(strategies: [
|
66
|
+
build_mapper_strategy(method: :cast, dto: Hash),
|
67
|
+
build_mapper_strategy(method: :serialize, dto: Hash),
|
68
|
+
build_mapper_strategy(method: :db_dump, dto: Hash),
|
69
|
+
build_mapper_strategy(method: :db_load, dto: Object, always_optional: true)
|
70
|
+
])
|
71
|
+
|
72
|
+
factory
|
73
|
+
.register_wrapper(:pg_jsonb, ReeDao::PgJsonb)
|
74
|
+
.register_wrapper(:pg_array, ReeDao::PgArray)
|
75
|
+
|
76
|
+
factory
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
require "sequel/extensions/pg_json_ops"
|
81
|
+
require "sequel/extensions/pg_array_ops"
|
82
|
+
|
83
|
+
class ReeDaoTestPg::Db
|
84
|
+
include Ree::BeanDSL
|
85
|
+
|
86
|
+
bean :db do
|
87
|
+
singleton
|
88
|
+
factory :build
|
89
|
+
|
90
|
+
link :build_pg_connection, from: :ree_dao
|
91
|
+
end
|
92
|
+
|
93
|
+
def build
|
94
|
+
Sequel.extension :pg_json_ops
|
95
|
+
Sequel.extension :pg_array_ops
|
96
|
+
|
97
|
+
build_pg_connection(
|
98
|
+
DB_CONFIG,
|
99
|
+
**{extensions: [:pg_array, :pg_json]}
|
100
|
+
)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
class ReeDaoTestPg::Product
|
105
|
+
include ReeDto::EntityDSL
|
106
|
+
|
107
|
+
properties(
|
108
|
+
id: Nilor[Integer],
|
109
|
+
title: String,
|
110
|
+
info: Hash,
|
111
|
+
labels: ArrayOf[String]
|
112
|
+
)
|
113
|
+
|
114
|
+
attr_accessor :title, :info
|
115
|
+
end
|
116
|
+
|
117
|
+
class ReeDaoTestPg::ProductsDao
|
118
|
+
include ReeDao::DSL
|
119
|
+
|
120
|
+
dao :products_dao do
|
121
|
+
link :db
|
122
|
+
end
|
123
|
+
|
124
|
+
schema ReeDaoTestPg::Product do
|
125
|
+
integer :id, null: true
|
126
|
+
string :title
|
127
|
+
pg_jsonb :info, any
|
128
|
+
pg_array :labels, string
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
let(:products_dao) { ReeDaoTestPg::ProductsDao.new }
|
133
|
+
|
134
|
+
it {
|
135
|
+
products_dao.delete_all
|
136
|
+
|
137
|
+
product = ReeDaoTestPg::Product.new(title: "Product", info: { price: 1337, count: 200 }, labels: ["Sale"])
|
138
|
+
products_dao.put(product)
|
139
|
+
|
140
|
+
product.info[:price] = 1440
|
141
|
+
product.labels << "New"
|
142
|
+
|
143
|
+
products_dao.update(product)
|
144
|
+
|
145
|
+
product = products_dao.find(product.id)
|
146
|
+
expect(product.title).to eq("Product")
|
147
|
+
expect(product.info[:price]).to eq(1440)
|
148
|
+
expect(product.labels).to eq(["Sale", "New"])
|
149
|
+
}
|
150
|
+
end
|
@@ -5,6 +5,7 @@ package_require('ree_dto/entity_dsl')
|
|
5
5
|
|
6
6
|
RSpec.describe :build_sqlite_connection do
|
7
7
|
link :build_sqlite_connection, from: :ree_dao
|
8
|
+
link :dao_cache, from: :ree_dao
|
8
9
|
|
9
10
|
after do
|
10
11
|
Ree.disable_irb_mode
|
@@ -140,7 +141,7 @@ RSpec.describe :build_sqlite_connection do
|
|
140
141
|
|
141
142
|
expect(u).to be_a(ReeDaoTest::User)
|
142
143
|
|
143
|
-
state = u.
|
144
|
+
state = dao_cache.get(:users, u.id)
|
144
145
|
|
145
146
|
expect(state).to be_a(Hash)
|
146
147
|
expect(state[:id]).to eq(user.id)
|
@@ -154,16 +155,16 @@ RSpec.describe :build_sqlite_connection do
|
|
154
155
|
user = ReeDaoTest::User.new(name: 'John', age: 30)
|
155
156
|
dao.put(user)
|
156
157
|
|
157
|
-
u = dao.find(user.id
|
158
|
+
u = dao.find(user.id)
|
158
159
|
expect(u).to be_a(ReeDaoTest::User)
|
159
|
-
expect(u.
|
160
|
+
expect(dao_cache.get(:users, u.id)).to_not eq(nil)
|
160
161
|
|
161
162
|
all = dao.all
|
162
163
|
expect(all.size).to eq(1)
|
163
164
|
u = all.first
|
164
165
|
|
165
166
|
expect(u).to be_a(ReeDaoTest::User)
|
166
|
-
expect(u.
|
167
|
+
expect(dao_cache.get(:users, u.id)).to be_a(Hash)
|
167
168
|
}
|
168
169
|
|
169
170
|
it {
|
@@ -246,7 +247,7 @@ RSpec.describe :build_sqlite_connection do
|
|
246
247
|
}
|
247
248
|
end
|
248
249
|
|
249
|
-
context "
|
250
|
+
context "update by entity" do
|
250
251
|
it {
|
251
252
|
dao.delete_all
|
252
253
|
|
@@ -82,6 +82,10 @@ module ReeMapper
|
|
82
82
|
pckg_name = ReeString::Underscore.new.call(mod.name)
|
83
83
|
factory_path = "#{pckg_name}/mapper_factory"
|
84
84
|
|
85
|
+
if Ree.irb_mode? && Object.const_defined?("#{mod.name}::MapperFactory") && mod != self
|
86
|
+
return Object.const_get("#{mod.name}::MapperFactory").new
|
87
|
+
end
|
88
|
+
|
85
89
|
mapper_factory_klass = if package_file_exists?(factory_path) && mod != self
|
86
90
|
package_require(factory_path)
|
87
91
|
Object.const_get("#{mod.name}::MapperFactory")
|
@@ -125,8 +125,8 @@ class Roda
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def build_traverse_tree_proc(tree, context)
|
128
|
-
has_arbitrary_param = tree.
|
129
|
-
|
128
|
+
has_arbitrary_param = tree.values[0].start_with?(":")
|
129
|
+
route_parts = has_arbitrary_param ? tree.values.map { _1.gsub(":", "") } : tree.values
|
130
130
|
procs = []
|
131
131
|
|
132
132
|
child_procs = tree.children.map do |child|
|
@@ -141,7 +141,9 @@ class Roda
|
|
141
141
|
if has_arbitrary_param
|
142
142
|
Proc.new do |r|
|
143
143
|
r.on String do |param_val|
|
144
|
-
|
144
|
+
route_parts.each do |route_part|
|
145
|
+
r.params[route_part] = param_val
|
146
|
+
end
|
145
147
|
|
146
148
|
child_procs.each do |child_proc|
|
147
149
|
r.instance_exec(r, &child_proc)
|
@@ -156,7 +158,7 @@ class Roda
|
|
156
158
|
end
|
157
159
|
else
|
158
160
|
Proc.new do |r|
|
159
|
-
r.on
|
161
|
+
r.on route_parts[0] do
|
160
162
|
child_procs.each do |child_proc|
|
161
163
|
r.instance_exec(r, &child_proc)
|
162
164
|
end
|
@@ -173,7 +175,9 @@ class Roda
|
|
173
175
|
Proc.new do |r|
|
174
176
|
if has_arbitrary_param
|
175
177
|
r.is String do |param_val|
|
176
|
-
|
178
|
+
route_parts.each do |route_part|
|
179
|
+
r.params[route_part] = param_val
|
180
|
+
end
|
177
181
|
|
178
182
|
route_procs.each do |route_proc|
|
179
183
|
r.instance_exec(r, &route_proc)
|
@@ -182,7 +186,7 @@ class Roda
|
|
182
186
|
nil
|
183
187
|
end
|
184
188
|
else
|
185
|
-
r.is
|
189
|
+
r.is route_parts[0] do
|
186
190
|
route_procs.each do |route_proc|
|
187
191
|
r.instance_exec(r, &route_proc)
|
188
192
|
end
|
@@ -1,54 +1,66 @@
|
|
1
1
|
class ReeRoda::BuildRoutingTree
|
2
2
|
include Ree::FnDSL
|
3
3
|
|
4
|
-
fn :build_routing_tree
|
4
|
+
fn :build_routing_tree do
|
5
|
+
link "ree_routes/route", -> { Route }
|
6
|
+
end
|
5
7
|
|
6
8
|
class RoutingTree
|
7
|
-
attr_accessor :children, :
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
attr_accessor :children, :values, :depth, :routes, :type, :parent
|
10
|
+
|
11
|
+
contract ArrayOf[String], Integer, Or[:param, :string], Nilor[self], ArrayOf[Route] => Any
|
12
|
+
def initialize(values, depth, type, parent = nil, routes = [])
|
13
|
+
@values = values
|
11
14
|
@depth = depth
|
12
15
|
@parent = parent
|
13
16
|
@type = type
|
14
17
|
@routes = []
|
15
18
|
@children = []
|
16
19
|
end
|
17
|
-
|
18
|
-
|
20
|
+
|
21
|
+
contract(Kwargs[
|
19
22
|
tree: self,
|
20
|
-
value:
|
21
|
-
type: :param,
|
22
|
-
depth:
|
23
|
+
value: Nilor[String],
|
24
|
+
type: Or[:param, :string],
|
25
|
+
depth: Integer] => Or[self, nil, ArrayOf[self]]
|
23
26
|
)
|
24
|
-
|
27
|
+
def find_by_value(tree: self, value: nil, type: :param, depth: 0)
|
28
|
+
return tree if tree.depth == depth && tree.values.include?(value)
|
29
|
+
|
25
30
|
if tree.depth < depth
|
26
|
-
res = tree
|
27
|
-
|
28
|
-
|
31
|
+
res = tree
|
32
|
+
.children
|
33
|
+
.map { find_by_value(tree: _1, value: value, type: type, depth: depth) }
|
34
|
+
.flatten
|
35
|
+
.compact
|
29
36
|
|
30
|
-
|
37
|
+
res.size > 1 ? res : res.first
|
31
38
|
end
|
32
39
|
end
|
33
40
|
|
34
|
-
|
35
|
-
|
41
|
+
contract String => Bool
|
42
|
+
def any_child_has_value?(value)
|
43
|
+
!!self.children.find { |c| c.values.include?(value) }
|
36
44
|
end
|
37
45
|
|
46
|
+
contract String, Integer, Or[:param, :string] => self
|
38
47
|
def add_child(value, depth, type)
|
39
|
-
new_child = self.class.new(value, depth, type, self
|
48
|
+
new_child = self.class.new([value], depth, type, self)
|
49
|
+
|
40
50
|
self.children << new_child
|
41
|
-
self.children = self.children.sort { _1.
|
51
|
+
self.children = self.children.sort { _1.values[0].match?(/\:/) ? 1 : 0 }
|
42
52
|
|
43
53
|
return new_child
|
44
54
|
end
|
45
55
|
|
56
|
+
contract Route => nil
|
46
57
|
def add_route(route)
|
47
|
-
self.routes << route
|
58
|
+
self.routes << route; nil
|
48
59
|
end
|
49
60
|
|
50
61
|
def print_tree(tree = self)
|
51
|
-
puts "#{get_offset(tree.depth)}#{tree.
|
62
|
+
puts "#{get_offset(tree.depth)}#{tree.values.inspect} - #{tree.depth}"
|
63
|
+
|
52
64
|
if tree.children.length > 0
|
53
65
|
tree.children.each do |child|
|
54
66
|
print_tree(child)
|
@@ -59,13 +71,16 @@ class ReeRoda::BuildRoutingTree
|
|
59
71
|
end
|
60
72
|
|
61
73
|
def print_proc_tree(tree = self)
|
62
|
-
param_value = tree.
|
74
|
+
param_value = tree.values[0].start_with?(":") ? String : "\"#{tree.values[0]}\""
|
75
|
+
|
63
76
|
if tree.routes.length == 0
|
64
77
|
if tree.children.length > 0
|
65
78
|
puts "#{get_offset(tree.depth)}r.on #{param_value} do"
|
79
|
+
|
66
80
|
tree.children.each do |child|
|
67
81
|
print_proc_tree(child)
|
68
82
|
end
|
83
|
+
|
69
84
|
puts "#{get_offset(tree.depth)}end"
|
70
85
|
end
|
71
86
|
|
@@ -73,20 +88,25 @@ class ReeRoda::BuildRoutingTree
|
|
73
88
|
else
|
74
89
|
if tree.children.length > 0
|
75
90
|
puts "#{get_offset(tree.depth)}r.on #{param_value} do"
|
91
|
+
|
76
92
|
tree.children.each do |child|
|
77
93
|
print_proc_tree(child)
|
78
94
|
end
|
95
|
+
|
79
96
|
tree.routes.each do |route|
|
80
97
|
puts "#{get_offset(tree.depth + 1)}r.#{route.request_method} do"
|
81
98
|
puts "#{get_offset(tree.depth + 1)}end"
|
82
99
|
end
|
100
|
+
|
83
101
|
puts "#{get_offset(tree.depth)}end"
|
84
102
|
else
|
85
103
|
puts "#{get_offset(tree.depth)}r.is #{param_value} do"
|
104
|
+
|
86
105
|
tree.routes.each do |route|
|
87
106
|
puts "#{get_offset(tree.depth + 1)}r.#{route.request_method} do"
|
88
107
|
puts "#{get_offset(tree.depth + 1)}end"
|
89
108
|
end
|
109
|
+
|
90
110
|
puts "#{get_offset(tree.depth)}end"
|
91
111
|
end
|
92
112
|
end
|
@@ -104,26 +124,28 @@ class ReeRoda::BuildRoutingTree
|
|
104
124
|
contract(ArrayOf[ReeRoutes::Route] => Nilor[RoutingTree])
|
105
125
|
def call(routes)
|
106
126
|
tree = nil
|
127
|
+
|
107
128
|
routes.each do |route|
|
108
129
|
splitted = route.path.split("/")
|
109
|
-
|
110
130
|
parent_tree = tree
|
131
|
+
|
111
132
|
splitted.each_with_index do |v, j|
|
112
133
|
if tree.nil?
|
113
|
-
tree = RoutingTree.new(v, j, :string)
|
134
|
+
tree = RoutingTree.new([v], j, :string)
|
114
135
|
parent_tree = tree
|
115
136
|
next
|
116
137
|
end
|
117
138
|
|
118
139
|
current = parent_tree.find_by_value(value: v, depth: j)
|
140
|
+
|
119
141
|
if current
|
120
142
|
parent_tree = current
|
121
|
-
|
122
143
|
current.add_route(route) if j == (splitted.length - 1)
|
123
144
|
else
|
124
|
-
if !parent_tree.
|
145
|
+
if !parent_tree.any_child_has_value?(v)
|
125
146
|
if parent_tree.children.any? { |c| c.type == :param } && v.start_with?(":")
|
126
147
|
param_child = parent_tree.children.find { |c| c.type == :param }
|
148
|
+
param_child.values << v if !param_child.values.include?(v)
|
127
149
|
param_child.add_route(route) if j == (splitted.length - 1)
|
128
150
|
parent_tree = param_child
|
129
151
|
|
@@ -138,7 +160,7 @@ class ReeRoda::BuildRoutingTree
|
|
138
160
|
end
|
139
161
|
end
|
140
162
|
end
|
141
|
-
|
163
|
+
|
142
164
|
tree
|
143
165
|
end
|
144
166
|
end
|
@@ -16,7 +16,10 @@ RSpec.describe ReeRoda::App do
|
|
16
16
|
module ReeRodaTest
|
17
17
|
include Ree::PackageDSL
|
18
18
|
|
19
|
-
package
|
19
|
+
package do
|
20
|
+
depends_on :ree_actions
|
21
|
+
depends_on :ree_dao
|
22
|
+
end
|
20
23
|
end
|
21
24
|
|
22
25
|
class ReeRodaTest::Cmd
|
@@ -62,6 +65,20 @@ RSpec.describe ReeRoda::App do
|
|
62
65
|
end
|
63
66
|
end
|
64
67
|
|
68
|
+
class ReeRodaTest::ActionCmd
|
69
|
+
include ReeActions::DSL
|
70
|
+
|
71
|
+
action :action_cmd
|
72
|
+
|
73
|
+
ActionCaster = build_mapper.use(:cast) do
|
74
|
+
integer :action_id
|
75
|
+
end
|
76
|
+
|
77
|
+
def call(access, attrs)
|
78
|
+
{result: "action_cmd"}
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
65
82
|
class ReeRodaTest::Serializer
|
66
83
|
include ReeMapper::DSL
|
67
84
|
|
@@ -91,6 +108,14 @@ RSpec.describe ReeRoda::App do
|
|
91
108
|
serializer :serializer, **opts
|
92
109
|
end
|
93
110
|
|
111
|
+
get "api/action/:action_id/test" do
|
112
|
+
summary "Subaction"
|
113
|
+
warden_scope :visitor
|
114
|
+
sections "some_action"
|
115
|
+
action :action_cmd, **opts
|
116
|
+
serializer :serializer, **opts
|
117
|
+
end
|
118
|
+
|
94
119
|
get "api/action/:id/subaction" do
|
95
120
|
summary "Subaction"
|
96
121
|
warden_scope :visitor
|
@@ -202,6 +227,10 @@ RSpec.describe ReeRoda::App do
|
|
202
227
|
get "api/action/1/subaction"
|
203
228
|
expect(last_response.status).to eq(200)
|
204
229
|
expect(last_response.body).to eq("{\"result\":\"result\"}")
|
230
|
+
|
231
|
+
get "api/action/1/test"
|
232
|
+
expect(last_response.status).to eq(200)
|
233
|
+
expect(last_response.body).to eq("{\"result\":\"action_cmd\"}")
|
205
234
|
}
|
206
235
|
|
207
236
|
it {
|
@@ -2,10 +2,8 @@
|
|
2
2
|
|
3
3
|
RSpec.describe :build_routing_tree do
|
4
4
|
link :build_routing_tree, from: :ree_roda
|
5
|
-
link :except, from: :ree_hash
|
6
5
|
link :is_blank, from: :ree_object
|
7
6
|
link :not_blank, from: :ree_object
|
8
|
-
link :to_hash, from: :ree_object
|
9
7
|
|
10
8
|
before :all do
|
11
9
|
Ree.enable_irb_mode
|
@@ -13,7 +11,10 @@ RSpec.describe :build_routing_tree do
|
|
13
11
|
module ReeRodaTestTree
|
14
12
|
include Ree::PackageDSL
|
15
13
|
|
16
|
-
package
|
14
|
+
package do
|
15
|
+
depends_on :ree_actions
|
16
|
+
depends_on :ree_dao
|
17
|
+
end
|
17
18
|
end
|
18
19
|
|
19
20
|
class ReeRodaTestTree::Cmd
|
@@ -255,7 +256,7 @@ RSpec.describe :build_routing_tree do
|
|
255
256
|
expect(id_nodes.all? { not_blank(_1.routes) }).to eq(true)
|
256
257
|
expect(count_tree_routes(tree)).to eq(13)
|
257
258
|
|
258
|
-
hsh = to_hash(tree)
|
259
|
-
expect(except(hsh, global_except: [:routes])).to eq(hsh_tree)
|
259
|
+
# hsh = to_hash(tree)
|
260
|
+
# expect(except(hsh, global_except: [:routes])).to eq(hsh_tree)
|
260
261
|
}
|
261
262
|
end
|
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.43
|
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-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ree
|
@@ -293,26 +293,35 @@ files:
|
|
293
293
|
- lib/ree_lib/packages/ree_dao/bin/console
|
294
294
|
- lib/ree_lib/packages/ree_dao/package/ree_dao.rb
|
295
295
|
- lib/ree_lib/packages/ree_dao/package/ree_dao/beans/connections.rb
|
296
|
+
- lib/ree_lib/packages/ree_dao/package/ree_dao/beans/dao_cache.rb
|
296
297
|
- lib/ree_lib/packages/ree_dao/package/ree_dao/dataset_extensions.rb
|
297
298
|
- lib/ree_lib/packages/ree_dao/package/ree_dao/dsl.rb
|
298
299
|
- lib/ree_lib/packages/ree_dao/package/ree_dao/functions/build_connection.rb
|
299
300
|
- lib/ree_lib/packages/ree_dao/package/ree_dao/functions/build_dao.rb
|
300
301
|
- lib/ree_lib/packages/ree_dao/package/ree_dao/functions/build_pg_connection.rb
|
301
302
|
- lib/ree_lib/packages/ree_dao/package/ree_dao/functions/build_sqlite_connection.rb
|
303
|
+
- lib/ree_lib/packages/ree_dao/package/ree_dao/functions/drop_cache.rb
|
304
|
+
- lib/ree_lib/packages/ree_dao/package/ree_dao/functions/extract_changes.rb
|
305
|
+
- lib/ree_lib/packages/ree_dao/package/ree_dao/functions/init_cache.rb
|
302
306
|
- lib/ree_lib/packages/ree_dao/package/ree_dao/functions/one_to_many.rb
|
303
307
|
- lib/ree_lib/packages/ree_dao/package/ree_dao/functions/one_to_one.rb
|
304
308
|
- lib/ree_lib/packages/ree_dao/package/ree_dao/functions/persist_assoc.rb
|
305
309
|
- lib/ree_lib/packages/ree_dao/package/ree_dao/wrappers/pg_array.rb
|
306
310
|
- lib/ree_lib/packages/ree_dao/package/ree_dao/wrappers/pg_jsonb.rb
|
307
311
|
- lib/ree_lib/packages/ree_dao/schemas/ree_dao/beans/connections.schema.json
|
312
|
+
- lib/ree_lib/packages/ree_dao/schemas/ree_dao/beans/dao_cache.schema.json
|
308
313
|
- lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/build_connection.schema.json
|
309
314
|
- lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/build_dao.schema.json
|
310
315
|
- lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/build_pg_connection.schema.json
|
311
316
|
- lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/build_sqlite_connection.schema.json
|
317
|
+
- lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/drop_cache.schema.json
|
318
|
+
- lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/extract_changes.schema.json
|
319
|
+
- lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/init_cache.schema.json
|
312
320
|
- lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/one_to_many.schema.json
|
313
321
|
- lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/one_to_one.schema.json
|
314
322
|
- lib/ree_lib/packages/ree_dao/schemas/ree_dao/functions/persist_assoc.schema.json
|
315
323
|
- lib/ree_lib/packages/ree_dao/spec/package_schema_spec.rb
|
324
|
+
- lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/build_pg_connection_spec.rb
|
316
325
|
- lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/build_sqlite_connection/max_connections_spec.rb
|
317
326
|
- lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/build_sqlite_connection_spec.rb
|
318
327
|
- lib/ree_lib/packages/ree_dao/spec/ree_dao/functions/one_to_many_spec.rb
|