lb-persistence 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +27 -0
- data/Guardfile +1 -2
- data/README.md +2 -2
- data/Rakefile +0 -1
- data/config/flay.yml +1 -1
- data/lb-persistence.gemspec +8 -9
- data/lib/lb/persistence.rb +0 -1
- data/lib/lb/persistence/functions.rb +5 -5
- data/lib/lb/persistence/types.rb +1 -1
- data/lib/lb/persistence/version.rb +1 -1
- data/spec/spec_helper.rb +2 -3
- data/spec/unit/lb/persistence/functions/class_methods/group_prefix_spec.rb +2 -2
- data/spec/unit/lb/persistence/functions/class_methods/wrap_prefix_spec.rb +2 -2
- metadata +18 -27
- data/circle.yml +0 -23
- data/lib/lb/persistence/model/attributes.rb +0 -25
- data/spec/unit/lb/persistence/model/redefine_attribute_spec.rb +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10650bcb263b3de597e131ce4845195860359394fe2cf06736a31d82e488377b
|
4
|
+
data.tar.gz: 5e0bb4741af426964b54db10bc2852aea3d7d56c53efe0d5cdf540bbaf4c6bac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc3cbbffd86a14edb1880e61cd55a3e6c48ee4827206b269c18978ac5b062093a4b63f427215e8093c0918632d736ceb49108b975363da7a6ad5eb12622563e7
|
7
|
+
data.tar.gz: 7b4ed1360817c34611391c6f47963ea9b061128fee48b4a0e07b82cf65c5ff305396c9f01730652bfd104c3b860cdd2334a60da39e7283d7b974bd2b1917a079
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: CI
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches: [ master ]
|
5
|
+
pull_request:
|
6
|
+
branches: [ master ]
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
ruby_version: ['2.5.x', '2.6.x', '2.7.x']
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- name: Set up Ruby
|
16
|
+
uses: actions/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: ${{ matrix.ruby_version }}
|
19
|
+
- name: Install dependencies
|
20
|
+
run: |
|
21
|
+
sudo apt-get update
|
22
|
+
sudo apt-get install -y libsqlite3-dev
|
23
|
+
- name: Build and test with Rake
|
24
|
+
run: |
|
25
|
+
gem install bundler
|
26
|
+
bundle install --jobs 4 --retry 3
|
27
|
+
bundle exec rake ci
|
data/Guardfile
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# encoding: utf-8
|
3
2
|
|
4
3
|
guard :bundler do
|
5
4
|
watch('Gemfile')
|
@@ -28,7 +27,7 @@ guard :rspec, cmd: 'bundle exec rspec ' +
|
|
28
27
|
Dir["spec/unit/#{m[1]}/#{m[2]}*"]
|
29
28
|
end
|
30
29
|
|
31
|
-
watch("lib/#{File.basename(File.expand_path(
|
30
|
+
watch("lib/#{File.basename(File.expand_path(__dir__))}.rb") do
|
32
31
|
'spec'
|
33
32
|
end
|
34
33
|
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
[gem]: https://rubygems.org/gems/lb-persistence
|
2
|
-
[ci]: https://
|
2
|
+
[ci]: https://github.com/lb-rb/lb-persistence/actions
|
3
3
|
|
4
4
|
# lb-persistence
|
5
5
|
|
6
6
|
[![Gem Version](https://badge.fury.io/rb/lb-persistence.svg)][gem]
|
7
|
-
[![Build Status](https://
|
7
|
+
[![Build Status](https://github.com/lb-rb/lb-persistence/workflows/CI/badge.svg)][ci]
|
8
8
|
|
9
9
|
## Credits
|
10
10
|
|
data/Rakefile
CHANGED
data/config/flay.yml
CHANGED
data/lb-persistence.gemspec
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# encoding: utf-8
|
3
2
|
|
4
|
-
require File.expand_path('
|
3
|
+
require File.expand_path('lib/lb/persistence/version', __dir__)
|
5
4
|
|
6
5
|
Gem::Specification.new do |gem|
|
7
6
|
gem.name = 'lb-persistence'
|
@@ -24,15 +23,15 @@ Gem::Specification.new do |gem|
|
|
24
23
|
gem.extra_rdoc_files = %w[README.md]
|
25
24
|
gem.required_ruby_version = '>= 2.4'
|
26
25
|
|
27
|
-
gem.add_dependency 'dry-struct', '~>
|
28
|
-
gem.add_dependency 'rom', '~>
|
29
|
-
gem.add_dependency 'rom-sql', '~> 2
|
26
|
+
gem.add_dependency 'dry-struct', '~> 1.3'
|
27
|
+
gem.add_dependency 'rom', '~> 5.2'
|
28
|
+
gem.add_dependency 'rom-sql', '~> 3.2'
|
30
29
|
|
31
|
-
gem.add_development_dependency 'devtools', '~> 0.1.
|
32
|
-
gem.add_development_dependency 'guard', '~> 2.
|
33
|
-
gem.add_development_dependency 'guard-bundler', '~>
|
30
|
+
gem.add_development_dependency 'devtools', '~> 0.1.25'
|
31
|
+
gem.add_development_dependency 'guard', '~> 2.16'
|
32
|
+
gem.add_development_dependency 'guard-bundler', '~> 3.0'
|
34
33
|
gem.add_development_dependency 'guard-rspec', '~> 4.7', '>= 4.7.3'
|
35
34
|
gem.add_development_dependency 'guard-rubocop', '~> 1.3'
|
36
|
-
gem.add_development_dependency 'rubocop', '~> 0.
|
35
|
+
gem.add_development_dependency 'rubocop', '~> 0.79'
|
37
36
|
gem.add_development_dependency 'sqlite3', '~> 1.3'
|
38
37
|
end
|
data/lib/lb/persistence.rb
CHANGED
@@ -37,11 +37,11 @@ module LB
|
|
37
37
|
|
38
38
|
{
|
39
39
|
group: :remove_key_prefix_inject_for,
|
40
|
-
wrap:
|
40
|
+
wrap: :remove_key_prefix_inject_hash_for
|
41
41
|
}.each do |operation, inject|
|
42
|
-
# rubocop:disable
|
42
|
+
# rubocop:disable Layout/LineLength
|
43
43
|
define_method :"#{operation}_prefix" do |array, key, keys, prefix, model = nil|
|
44
|
-
# rubocop:enable
|
44
|
+
# rubocop:enable Layout/LineLength
|
45
45
|
compose do |ops|
|
46
46
|
ops << t(operation, key, keys)
|
47
47
|
ops << t(:map_array,
|
@@ -88,8 +88,8 @@ module LB
|
|
88
88
|
t(:remove_key_prefix_inject, prefix, model)).call(hash)
|
89
89
|
end
|
90
90
|
|
91
|
-
def reject_array(array,
|
92
|
-
Array(array).reject { |value|
|
91
|
+
def reject_array(array, function)
|
92
|
+
Array(array).reject { |value| function[value] }
|
93
93
|
end
|
94
94
|
|
95
95
|
def empty_hash?(hash)
|
data/lib/lb/persistence/types.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# encoding: utf-8
|
3
2
|
|
4
3
|
if ENV['COVERAGE'] == 'true'
|
5
4
|
require 'simplecov'
|
@@ -10,7 +9,7 @@ if ENV['COVERAGE'] == 'true'
|
|
10
9
|
add_filter 'config'
|
11
10
|
add_filter 'spec'
|
12
11
|
|
13
|
-
minimum_coverage
|
12
|
+
minimum_coverage 88
|
14
13
|
end
|
15
14
|
end
|
16
15
|
|
@@ -21,7 +20,7 @@ require 'lb-persistence'
|
|
21
20
|
require 'devtools/spec_helper'
|
22
21
|
|
23
22
|
# require spec support files and shared behavior
|
24
|
-
Dir[File.expand_path('
|
23
|
+
Dir[File.expand_path('{support,shared}/**/*.rb', __dir__)].sort.each do |file|
|
25
24
|
require file
|
26
25
|
end
|
27
26
|
|
@@ -18,7 +18,7 @@ describe LB::Persistence::Functions, '.group_prefix' do
|
|
18
18
|
nested = nested_class
|
19
19
|
Class.new(Dry::Struct) do
|
20
20
|
module Types
|
21
|
-
include Dry
|
21
|
+
include Dry.Types(default: :nominal)
|
22
22
|
end
|
23
23
|
|
24
24
|
attribute :a, Types::Strict::String
|
@@ -29,7 +29,7 @@ describe LB::Persistence::Functions, '.group_prefix' do
|
|
29
29
|
let(:nested_class) do
|
30
30
|
Class.new(Dry::Struct) do
|
31
31
|
module Types
|
32
|
-
include Dry
|
32
|
+
include Dry.Types(default: :nominal)
|
33
33
|
end
|
34
34
|
|
35
35
|
attribute :a, Types::Strict::String
|
@@ -18,7 +18,7 @@ describe LB::Persistence::Functions, '.wrap_prefix' do
|
|
18
18
|
nested = nested_class
|
19
19
|
Class.new(Dry::Struct) do
|
20
20
|
module Types
|
21
|
-
include Dry
|
21
|
+
include Dry.Types(default: :nominal)
|
22
22
|
end
|
23
23
|
|
24
24
|
attribute :a, Types::Strict::String
|
@@ -29,7 +29,7 @@ describe LB::Persistence::Functions, '.wrap_prefix' do
|
|
29
29
|
let(:nested_class) do
|
30
30
|
Class.new(Dry::Struct) do
|
31
31
|
module Types
|
32
|
-
include Dry
|
32
|
+
include Dry.Types(default: :nominal)
|
33
33
|
end
|
34
34
|
|
35
35
|
attribute :a, Types::Strict::String
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lb-persistence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Firas Zaidan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-struct
|
@@ -16,90 +16,84 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '0.5'
|
19
|
+
version: '1.3'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '0.5'
|
26
|
+
version: '1.3'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: rom
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
31
|
- - "~>"
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
33
|
+
version: '5.2'
|
40
34
|
type: :runtime
|
41
35
|
prerelease: false
|
42
36
|
version_requirements: !ruby/object:Gem::Requirement
|
43
37
|
requirements:
|
44
38
|
- - "~>"
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
40
|
+
version: '5.2'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: rom-sql
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
45
|
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '2
|
47
|
+
version: '3.2'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
52
|
- - "~>"
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version: '2
|
54
|
+
version: '3.2'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: devtools
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
59
|
- - "~>"
|
66
60
|
- !ruby/object:Gem::Version
|
67
|
-
version: 0.1.
|
61
|
+
version: 0.1.25
|
68
62
|
type: :development
|
69
63
|
prerelease: false
|
70
64
|
version_requirements: !ruby/object:Gem::Requirement
|
71
65
|
requirements:
|
72
66
|
- - "~>"
|
73
67
|
- !ruby/object:Gem::Version
|
74
|
-
version: 0.1.
|
68
|
+
version: 0.1.25
|
75
69
|
- !ruby/object:Gem::Dependency
|
76
70
|
name: guard
|
77
71
|
requirement: !ruby/object:Gem::Requirement
|
78
72
|
requirements:
|
79
73
|
- - "~>"
|
80
74
|
- !ruby/object:Gem::Version
|
81
|
-
version: '2.
|
75
|
+
version: '2.16'
|
82
76
|
type: :development
|
83
77
|
prerelease: false
|
84
78
|
version_requirements: !ruby/object:Gem::Requirement
|
85
79
|
requirements:
|
86
80
|
- - "~>"
|
87
81
|
- !ruby/object:Gem::Version
|
88
|
-
version: '2.
|
82
|
+
version: '2.16'
|
89
83
|
- !ruby/object:Gem::Dependency
|
90
84
|
name: guard-bundler
|
91
85
|
requirement: !ruby/object:Gem::Requirement
|
92
86
|
requirements:
|
93
87
|
- - "~>"
|
94
88
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
89
|
+
version: '3.0'
|
96
90
|
type: :development
|
97
91
|
prerelease: false
|
98
92
|
version_requirements: !ruby/object:Gem::Requirement
|
99
93
|
requirements:
|
100
94
|
- - "~>"
|
101
95
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
96
|
+
version: '3.0'
|
103
97
|
- !ruby/object:Gem::Dependency
|
104
98
|
name: guard-rspec
|
105
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,14 +134,14 @@ dependencies:
|
|
140
134
|
requirements:
|
141
135
|
- - "~>"
|
142
136
|
- !ruby/object:Gem::Version
|
143
|
-
version: 0.
|
137
|
+
version: '0.79'
|
144
138
|
type: :development
|
145
139
|
prerelease: false
|
146
140
|
version_requirements: !ruby/object:Gem::Requirement
|
147
141
|
requirements:
|
148
142
|
- - "~>"
|
149
143
|
- !ruby/object:Gem::Version
|
150
|
-
version: 0.
|
144
|
+
version: '0.79'
|
151
145
|
- !ruby/object:Gem::Dependency
|
152
146
|
name: sqlite3
|
153
147
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,6 +164,7 @@ extensions: []
|
|
170
164
|
extra_rdoc_files:
|
171
165
|
- README.md
|
172
166
|
files:
|
167
|
+
- ".github/workflows/ci.yml"
|
173
168
|
- ".gitignore"
|
174
169
|
- ".rspec"
|
175
170
|
- ".rubocop.yml"
|
@@ -178,7 +173,6 @@ files:
|
|
178
173
|
- LICENSE
|
179
174
|
- README.md
|
180
175
|
- Rakefile
|
181
|
-
- circle.yml
|
182
176
|
- config/devtools.yml
|
183
177
|
- config/flay.yml
|
184
178
|
- config/flog.yml
|
@@ -190,7 +184,6 @@ files:
|
|
190
184
|
- lib/lb-persistence.rb
|
191
185
|
- lib/lb/persistence.rb
|
192
186
|
- lib/lb/persistence/functions.rb
|
193
|
-
- lib/lb/persistence/model/attributes.rb
|
194
187
|
- lib/lb/persistence/relation/joins.rb
|
195
188
|
- lib/lb/persistence/settings.rb
|
196
189
|
- lib/lb/persistence/types.rb
|
@@ -204,7 +197,6 @@ files:
|
|
204
197
|
- spec/unit/lb/persistence/container_spec.rb
|
205
198
|
- spec/unit/lb/persistence/functions/class_methods/group_prefix_spec.rb
|
206
199
|
- spec/unit/lb/persistence/functions/class_methods/wrap_prefix_spec.rb
|
207
|
-
- spec/unit/lb/persistence/model/redefine_attribute_spec.rb
|
208
200
|
- spec/unit/lb/persistence/repository_spec.rb
|
209
201
|
- spec/unit/lb/persistence/uri_spec.rb
|
210
202
|
homepage: https://github.com/lb-rb/lb-persistence
|
@@ -228,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
220
|
version: '0'
|
229
221
|
requirements: []
|
230
222
|
rubyforge_project:
|
231
|
-
rubygems_version: 2.7.
|
223
|
+
rubygems_version: 2.7.8
|
232
224
|
signing_key:
|
233
225
|
specification_version: 4
|
234
226
|
summary: LB Persistence API
|
@@ -241,6 +233,5 @@ test_files:
|
|
241
233
|
- spec/unit/lb/persistence/container_spec.rb
|
242
234
|
- spec/unit/lb/persistence/functions/class_methods/group_prefix_spec.rb
|
243
235
|
- spec/unit/lb/persistence/functions/class_methods/wrap_prefix_spec.rb
|
244
|
-
- spec/unit/lb/persistence/model/redefine_attribute_spec.rb
|
245
236
|
- spec/unit/lb/persistence/repository_spec.rb
|
246
237
|
- spec/unit/lb/persistence/uri_spec.rb
|
data/circle.yml
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
defaults: &defaults
|
2
|
-
working_directory: ~/lb-project
|
3
|
-
steps:
|
4
|
-
- checkout
|
5
|
-
- run: bundle install
|
6
|
-
- run: bundle exec rake ci
|
7
|
-
|
8
|
-
version: 2
|
9
|
-
jobs:
|
10
|
-
ruby_2_4:
|
11
|
-
<<: *defaults
|
12
|
-
docker:
|
13
|
-
- image: circleci/ruby:2.4.4
|
14
|
-
ruby_2_5:
|
15
|
-
<<: *defaults
|
16
|
-
docker:
|
17
|
-
- image: circleci/ruby:2.5.1
|
18
|
-
workflows:
|
19
|
-
version: 2
|
20
|
-
test:
|
21
|
-
jobs:
|
22
|
-
- ruby_2_4
|
23
|
-
- ruby_2_5
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module LB
|
4
|
-
class Persistence
|
5
|
-
module Model
|
6
|
-
# Helper for dry-struct attributes
|
7
|
-
module Attributes
|
8
|
-
def delete_attribute(name)
|
9
|
-
@schema.delete(name)
|
10
|
-
equalizer.instance_variable_get('@keys').delete(name)
|
11
|
-
superclass.instance_variable_get('@schema').delete(name)
|
12
|
-
@constructor = Dry::Types['coercible.hash']
|
13
|
-
.public_send(constructor_type, @schema)
|
14
|
-
|
15
|
-
self
|
16
|
-
end
|
17
|
-
|
18
|
-
def redefine_attribute(name, type)
|
19
|
-
delete_attribute(name)
|
20
|
-
attribute(name, type)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe LB::Persistence::Model::Attributes, '#redefine_attribute' do
|
6
|
-
include_context 'settings'
|
7
|
-
|
8
|
-
subject { object }
|
9
|
-
|
10
|
-
let(:model_base_class) do
|
11
|
-
Class.new(Dry::Struct) do
|
12
|
-
module Types
|
13
|
-
include Dry::Types.module
|
14
|
-
end
|
15
|
-
|
16
|
-
attribute :a, Types::Strict::Symbol
|
17
|
-
attribute :b, Types::Strict::String
|
18
|
-
attribute :c, Types::Strict::Hash
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
let(:model_child_class) do
|
23
|
-
Class.new(model_base_class) do
|
24
|
-
extend LB::Persistence::Model::Attributes
|
25
|
-
|
26
|
-
redefine_attribute :b, Types::Strict::Bool
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
let(:object) { model_child_class.new(values) }
|
31
|
-
|
32
|
-
let(:base_values) do
|
33
|
-
{
|
34
|
-
a: :symbol,
|
35
|
-
c: { key: 'value' }
|
36
|
-
}
|
37
|
-
end
|
38
|
-
|
39
|
-
let(:values) { base_values.merge(b: true) }
|
40
|
-
|
41
|
-
it 'should create model with redefined attribute' do
|
42
|
-
expect(subject.b).to be(true)
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'with invalid value' do
|
46
|
-
let(:values) { base_values.merge(b: 'true') }
|
47
|
-
let(:expected_msg) { /has invalid type for #{Regexp.escape(':b')}/ }
|
48
|
-
|
49
|
-
it 'should not create model with old attribute' do
|
50
|
-
expect { subject }.to raise_error(Dry::Struct::Error, expected_msg)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|