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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34f142eee2a8be5aae73687655f819eb5b54f77fc286bd7bf03fd60ccd598c0a
4
- data.tar.gz: 9d145a34e867be9d70d64668eba6ee3823b6b9319e86ba1985cd829f5d007b8e
3
+ metadata.gz: 10650bcb263b3de597e131ce4845195860359394fe2cf06736a31d82e488377b
4
+ data.tar.gz: 5e0bb4741af426964b54db10bc2852aea3d7d56c53efe0d5cdf540bbaf4c6bac
5
5
  SHA512:
6
- metadata.gz: 4409e4fbe16f39c07460807d7e36e6eb6f76e813a7f61703612bd9906902708464e78680e99984f8cdb0d88d932aa88316a5792c63d904cacf3c9862efadbda7
7
- data.tar.gz: 43fea15f325e80d76ca632531fca42d0eb51ee37bf951f8394fb55100ace30347ed69b85cdcbdb7821860ac2ab4f2d69e19bb10925521d2c4758fe77a5d06814
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('../', __FILE__))}.rb") do
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://circleci.com/gh/lb-rb/lb-persistence/tree/master
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://img.shields.io/circleci/project/lb-rb/lb-persistence.svg)][ci]
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
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- # encoding: utf-8
3
2
 
4
3
  require 'devtools'
5
4
 
@@ -1,3 +1,3 @@
1
1
  ---
2
2
  threshold: 13
3
- total_score: 77
3
+ total_score: 72
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
- # encoding: utf-8
3
2
 
4
- require File.expand_path('../lib/lb/persistence/version', __FILE__)
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', '~> 0.4', '< 0.5'
28
- gem.add_dependency 'rom', '~> 4.2'
29
- gem.add_dependency 'rom-sql', '~> 2.4'
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.20'
32
- gem.add_development_dependency 'guard', '~> 2.14'
33
- gem.add_development_dependency 'guard-bundler', '~> 2.1'
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.52.1'
35
+ gem.add_development_dependency 'rubocop', '~> 0.79'
37
36
  gem.add_development_dependency 'sqlite3', '~> 1.3'
38
37
  end
@@ -9,7 +9,6 @@ require 'lb/persistence/settings'
9
9
 
10
10
  # Helpers
11
11
  require 'lb/persistence/relation/joins'
12
- require 'lb/persistence/model/attributes'
13
12
  require 'lb/persistence/functions'
14
13
 
15
14
  # LB namespace
@@ -37,11 +37,11 @@ module LB
37
37
 
38
38
  {
39
39
  group: :remove_key_prefix_inject_for,
40
- wrap: :remove_key_prefix_inject_hash_for
40
+ wrap: :remove_key_prefix_inject_hash_for
41
41
  }.each do |operation, inject|
42
- # rubocop:disable Metrics/LineLength
42
+ # rubocop:disable Layout/LineLength
43
43
  define_method :"#{operation}_prefix" do |array, key, keys, prefix, model = nil|
44
- # rubocop:enable Metrics/LineLength
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, fn)
92
- Array(array).reject { |value| fn[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)
@@ -4,7 +4,7 @@ module LB
4
4
  class Persistence
5
5
  # Custom Types
6
6
  module Types
7
- include Dry::Types.module
7
+ include Dry.Types(default: :nominal)
8
8
  end
9
9
  end
10
10
  end
@@ -3,6 +3,6 @@
3
3
  module LB
4
4
  class Persistence
5
5
  # Version
6
- VERSION = '0.1.0'
6
+ VERSION = '0.2.0'
7
7
  end
8
8
  end
@@ -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 89
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('../{support,shared}/**/*.rb', __FILE__)].each do |file|
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::Types.module
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::Types.module
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::Types.module
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::Types.module
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.1.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: 2018-12-17 00:00:00.000000000 Z
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: '0.4'
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: '0.4'
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: '4.2'
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: '4.2'
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.4'
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.4'
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.20
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.20
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.14'
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.14'
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: '2.1'
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: '2.1'
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.52.1
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.52.1
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.6
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