lb-persistence 0.1.0 → 0.3.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 +22 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +18 -0
- data/Guardfile +2 -4
- data/README.md +2 -2
- data/Rakefile +1 -4
- data/config/flay.yml +1 -1
- data/lb-persistence.gemspec +11 -15
- data/lib/lb/persistence/functions.rb +3 -5
- data/lib/lb/persistence/relation/joins.rb +2 -2
- data/lib/lb/persistence/types.rb +1 -1
- data/lib/lb/persistence/version.rb +1 -1
- data/lib/lb/persistence.rb +1 -2
- data/rakelib/ci.rake +14 -10
- data/rakelib/spec.rake +36 -0
- data/spec/spec_helper.rb +2 -5
- data/spec/unit/lb/persistence/functions/class_methods/group_prefix_spec.rb +3 -3
- data/spec/unit/lb/persistence/functions/class_methods/wrap_prefix_spec.rb +3 -3
- metadata +31 -84
- data/.rubocop.yml +0 -1
- data/circle.yml +0 -23
- data/config/rubocop.yml +0 -11
- 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: 0aaa4e82cdf55105539b2b0b922221f1c13edba4f415550f606c92f992154616
|
4
|
+
data.tar.gz: d67a1ad39dfc23b52720978f5283ae1cb4fe0d808ab14e8a709fcdb067320556
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01ca45c267be5d5a4d072d65a67d0fb26635f3c0c37587ccfb3d9951a8965ebb3851616ce660484c253715971c7b0da4554f2f3caf8bca51208067631b379496
|
7
|
+
data.tar.gz: 1b2f8d96eca4a1cf9340180dadb3935904f1eb900a8131cdeb700e15eb9bd8936a17f9a3a3a76b9c5d16e9dcf1c5386773d0060589305232caa347e2e5fd8aec
|
@@ -0,0 +1,22 @@
|
|
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.7', '3.0', '3.1', 'head']
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v3
|
15
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
16
|
+
uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
|
17
|
+
with:
|
18
|
+
ruby-version: ${{ matrix.ruby_version }}
|
19
|
+
- name: Install dependencies
|
20
|
+
run: bundle install
|
21
|
+
- name: Run tests
|
22
|
+
run: bundle exec rake ci
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.7
|
3
|
+
NewCops: enable
|
4
|
+
DisplayCopNames: true
|
5
|
+
Exclude:
|
6
|
+
- 'vendor/**/*'
|
7
|
+
Naming/FileName:
|
8
|
+
Exclude:
|
9
|
+
- Rakefile
|
10
|
+
Metrics/BlockLength:
|
11
|
+
Exclude:
|
12
|
+
- 'spec/**/*.rb'
|
13
|
+
- '*.gemspec'
|
14
|
+
Lint/ConstantDefinitionInBlock:
|
15
|
+
Exclude:
|
16
|
+
- 'spec/**/*.rb'
|
17
|
+
Style/OperatorMethodCall:
|
18
|
+
Enabled: false
|
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')
|
@@ -7,8 +6,7 @@ guard :bundler do
|
|
7
6
|
watch(/\A(.+)\.gemspec\z/)
|
8
7
|
end
|
9
8
|
|
10
|
-
guard :rspec, cmd:
|
11
|
-
File.read('.rspec').split.join(' '),
|
9
|
+
guard :rspec, cmd: "bundle exec rspec #{File.read('.rspec').split.join(' ')}",
|
12
10
|
failed_mode: :keep do
|
13
11
|
# Run all specs if configuration is modified
|
14
12
|
watch('.rspec') { 'spec' }
|
@@ -28,7 +26,7 @@ guard :rspec, cmd: 'bundle exec rspec ' +
|
|
28
26
|
Dir["spec/unit/#{m[1]}/#{m[2]}*"]
|
29
27
|
end
|
30
28
|
|
31
|
-
watch("lib/#{File.basename(File.expand_path(
|
29
|
+
watch("lib/#{File.basename(File.expand_path(__dir__))}.rb") do
|
32
30
|
'spec'
|
33
31
|
end
|
34
32
|
|
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'
|
@@ -19,20 +18,17 @@ Gem::Specification.new do |gem|
|
|
19
18
|
.split($INPUT_RECORD_SEPARATOR)
|
20
19
|
gem.executables = `git ls-files -- bin/*`
|
21
20
|
.split("\n").map { |f| File.basename(f) }
|
22
|
-
gem.test_files = `git ls-files -- spec`
|
23
|
-
.split($INPUT_RECORD_SEPARATOR)
|
24
21
|
gem.extra_rdoc_files = %w[README.md]
|
25
|
-
gem.required_ruby_version = '>= 2.
|
22
|
+
gem.required_ruby_version = '>= 2.7'
|
26
23
|
|
27
|
-
gem.add_dependency 'dry-struct', '~>
|
28
|
-
gem.add_dependency 'rom', '~>
|
29
|
-
gem.add_dependency 'rom-sql', '~>
|
24
|
+
gem.add_dependency 'dry-struct', '~> 1.6'
|
25
|
+
gem.add_dependency 'rom', '~> 5.3'
|
26
|
+
gem.add_dependency 'rom-sql', '~> 3.6'
|
30
27
|
|
31
|
-
gem.add_development_dependency '
|
32
|
-
gem.add_development_dependency '
|
33
|
-
gem.add_development_dependency '
|
34
|
-
gem.add_development_dependency '
|
35
|
-
gem.add_development_dependency '
|
36
|
-
gem.
|
37
|
-
gem.add_development_dependency 'sqlite3', '~> 1.3'
|
28
|
+
gem.add_development_dependency 'rake', '~> 13.0.6'
|
29
|
+
gem.add_development_dependency 'rspec', '~> 3.12.0'
|
30
|
+
gem.add_development_dependency 'rspec-core', '~> 3.12.1'
|
31
|
+
gem.add_development_dependency 'rubocop', '~> 1.5'
|
32
|
+
gem.add_development_dependency 'sqlite3', '~> 1.6'
|
33
|
+
gem.metadata['rubygems_mfa_required'] = 'true'
|
38
34
|
end
|
@@ -37,11 +37,9 @@ 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 Metrics/LineLength
|
43
42
|
define_method :"#{operation}_prefix" do |array, key, keys, prefix, model = nil|
|
44
|
-
# rubocop:enable Metrics/LineLength
|
45
43
|
compose do |ops|
|
46
44
|
ops << t(operation, key, keys)
|
47
45
|
ops << t(:map_array,
|
@@ -88,8 +86,8 @@ module LB
|
|
88
86
|
t(:remove_key_prefix_inject, prefix, model)).call(hash)
|
89
87
|
end
|
90
88
|
|
91
|
-
def reject_array(array,
|
92
|
-
Array(array).reject { |value|
|
89
|
+
def reject_array(array, function)
|
90
|
+
Array(array).reject { |value| function[value] }
|
93
91
|
end
|
94
92
|
|
95
93
|
def empty_hash?(hash)
|
@@ -21,11 +21,11 @@ module LB
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def qualify_on(on)
|
24
|
-
on.
|
24
|
+
on.to_h do |source, target|
|
25
25
|
source = source.qualified if source.respond_to?(:qualified)
|
26
26
|
target = target.qualified if target.respond_to?(:qualified)
|
27
27
|
[source, target]
|
28
|
-
end
|
28
|
+
end
|
29
29
|
end
|
30
30
|
|
31
31
|
def prefixed(relation,
|
data/lib/lb/persistence/types.rb
CHANGED
data/lib/lb/persistence.rb
CHANGED
@@ -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
|
@@ -124,7 +123,7 @@ module LB
|
|
124
123
|
# @api private
|
125
124
|
#
|
126
125
|
def configure(config)
|
127
|
-
config.auto_registration(settings.source_dir, options)
|
126
|
+
config.auto_registration(settings.source_dir, **options)
|
128
127
|
|
129
128
|
config
|
130
129
|
end
|
data/rakelib/ci.rake
CHANGED
@@ -1,24 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
namespace :metrics do
|
4
|
+
desc 'Check code style with RuboCop'
|
5
|
+
task :rubocop do
|
6
|
+
require 'rubocop'
|
7
|
+
begin
|
8
|
+
# args = %W[--config #{config.config_file}]
|
9
|
+
args = []
|
10
|
+
raise 'Rubocop failed' unless RuboCop::CLI.new.run(args).zero?
|
11
|
+
rescue Encoding::CompatibilityError => e
|
12
|
+
abort e.message
|
13
|
+
end
|
14
|
+
end
|
7
15
|
end
|
8
16
|
|
9
|
-
desc 'Run
|
17
|
+
desc 'Run CI tasks'
|
10
18
|
task ci: %w[ci:metrics]
|
11
19
|
|
12
20
|
namespace :ci do
|
13
21
|
tasks = %w[
|
14
|
-
metrics:coverage
|
15
|
-
metrics:yardstick:verify
|
16
22
|
metrics:rubocop
|
17
|
-
metrics:flog
|
18
|
-
metrics:flay
|
19
23
|
spec:integration
|
20
24
|
]
|
21
25
|
|
22
|
-
desc 'Run metrics
|
26
|
+
desc 'Run metrics'
|
23
27
|
task metrics: tasks
|
24
28
|
end
|
data/rakelib/spec.rake
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
# Remove existing same-named tasks
|
7
|
+
%w[spec spec:unit spec:integration].each do |task|
|
8
|
+
klass = Rake::Task
|
9
|
+
klass[task].clear if klass.task_defined?(task)
|
10
|
+
end
|
11
|
+
|
12
|
+
desc 'Run all specs'
|
13
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
14
|
+
task.pattern = 'spec/{unit,integration}/**/*_spec.rb'
|
15
|
+
end
|
16
|
+
|
17
|
+
namespace :spec do
|
18
|
+
desc 'Run unit specs'
|
19
|
+
RSpec::Core::RakeTask.new(:unit) do |task|
|
20
|
+
task.pattern = 'spec/unit/**/*_spec.rb'
|
21
|
+
end
|
22
|
+
|
23
|
+
desc 'Run integration specs'
|
24
|
+
RSpec::Core::RakeTask.new(:integration) do |task|
|
25
|
+
task.pattern = 'spec/integration/**/*_spec.rb'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
rescue LoadError
|
29
|
+
%w[spec spec:unit spec:integration].each do |name|
|
30
|
+
task name do
|
31
|
+
warn "In order to run #{name}, do: gem install rspec"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
task test: :spec
|
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
|
|
@@ -18,10 +17,8 @@ $LOAD_PATH << 'lib'
|
|
18
17
|
|
19
18
|
require 'lb-persistence'
|
20
19
|
|
21
|
-
require 'devtools/spec_helper'
|
22
|
-
|
23
20
|
# require spec support files and shared behavior
|
24
|
-
Dir[File.expand_path('
|
21
|
+
Dir[File.expand_path('{support,shared}/**/*.rb', __dir__)].sort.each do |file|
|
25
22
|
require file
|
26
23
|
end
|
27
24
|
|
@@ -7,7 +7,7 @@ describe LB::Persistence::Functions, '.group_prefix' do
|
|
7
7
|
|
8
8
|
let(:object) do
|
9
9
|
described_class.t(:group_prefix, key, keys, prefix, nested_class)
|
10
|
-
|
10
|
+
.>> described_class.t(:model, model_class)
|
11
11
|
end
|
12
12
|
|
13
13
|
let(:key) { :items }
|
@@ -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
|
@@ -7,7 +7,7 @@ describe LB::Persistence::Functions, '.wrap_prefix' do
|
|
7
7
|
|
8
8
|
let(:object) do
|
9
9
|
described_class.t(:wrap_prefix, key, keys, prefix, nested_class)
|
10
|
-
|
10
|
+
.>> described_class.t(:model, model_class)
|
11
11
|
end
|
12
12
|
|
13
13
|
let(:key) { :item }
|
@@ -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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Firas Zaidan
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-struct
|
@@ -16,152 +16,112 @@ 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.6'
|
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.6'
|
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.3'
|
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.3'
|
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: '
|
47
|
+
version: '3.6'
|
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: '
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: devtools
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: 0.1.20
|
68
|
-
type: :development
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - "~>"
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: 0.1.20
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: guard
|
77
|
-
requirement: !ruby/object:Gem::Requirement
|
78
|
-
requirements:
|
79
|
-
- - "~>"
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: '2.14'
|
82
|
-
type: :development
|
83
|
-
prerelease: false
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - "~>"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '2.14'
|
54
|
+
version: '3.6'
|
89
55
|
- !ruby/object:Gem::Dependency
|
90
|
-
name:
|
56
|
+
name: rake
|
91
57
|
requirement: !ruby/object:Gem::Requirement
|
92
58
|
requirements:
|
93
59
|
- - "~>"
|
94
60
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
61
|
+
version: 13.0.6
|
96
62
|
type: :development
|
97
63
|
prerelease: false
|
98
64
|
version_requirements: !ruby/object:Gem::Requirement
|
99
65
|
requirements:
|
100
66
|
- - "~>"
|
101
67
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
68
|
+
version: 13.0.6
|
103
69
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
70
|
+
name: rspec
|
105
71
|
requirement: !ruby/object:Gem::Requirement
|
106
72
|
requirements:
|
107
73
|
- - "~>"
|
108
74
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
110
|
-
- - ">="
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version: 4.7.3
|
75
|
+
version: 3.12.0
|
113
76
|
type: :development
|
114
77
|
prerelease: false
|
115
78
|
version_requirements: !ruby/object:Gem::Requirement
|
116
79
|
requirements:
|
117
80
|
- - "~>"
|
118
81
|
- !ruby/object:Gem::Version
|
119
|
-
version:
|
120
|
-
- - ">="
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
version: 4.7.3
|
82
|
+
version: 3.12.0
|
123
83
|
- !ruby/object:Gem::Dependency
|
124
|
-
name:
|
84
|
+
name: rspec-core
|
125
85
|
requirement: !ruby/object:Gem::Requirement
|
126
86
|
requirements:
|
127
87
|
- - "~>"
|
128
88
|
- !ruby/object:Gem::Version
|
129
|
-
version:
|
89
|
+
version: 3.12.1
|
130
90
|
type: :development
|
131
91
|
prerelease: false
|
132
92
|
version_requirements: !ruby/object:Gem::Requirement
|
133
93
|
requirements:
|
134
94
|
- - "~>"
|
135
95
|
- !ruby/object:Gem::Version
|
136
|
-
version:
|
96
|
+
version: 3.12.1
|
137
97
|
- !ruby/object:Gem::Dependency
|
138
98
|
name: rubocop
|
139
99
|
requirement: !ruby/object:Gem::Requirement
|
140
100
|
requirements:
|
141
101
|
- - "~>"
|
142
102
|
- !ruby/object:Gem::Version
|
143
|
-
version:
|
103
|
+
version: '1.5'
|
144
104
|
type: :development
|
145
105
|
prerelease: false
|
146
106
|
version_requirements: !ruby/object:Gem::Requirement
|
147
107
|
requirements:
|
148
108
|
- - "~>"
|
149
109
|
- !ruby/object:Gem::Version
|
150
|
-
version:
|
110
|
+
version: '1.5'
|
151
111
|
- !ruby/object:Gem::Dependency
|
152
112
|
name: sqlite3
|
153
113
|
requirement: !ruby/object:Gem::Requirement
|
154
114
|
requirements:
|
155
115
|
- - "~>"
|
156
116
|
- !ruby/object:Gem::Version
|
157
|
-
version: '1.
|
117
|
+
version: '1.6'
|
158
118
|
type: :development
|
159
119
|
prerelease: false
|
160
120
|
version_requirements: !ruby/object:Gem::Requirement
|
161
121
|
requirements:
|
162
122
|
- - "~>"
|
163
123
|
- !ruby/object:Gem::Version
|
164
|
-
version: '1.
|
124
|
+
version: '1.6'
|
165
125
|
description: LB Persistence API
|
166
126
|
email:
|
167
127
|
- firas@zaidan.de
|
@@ -170,6 +130,7 @@ extensions: []
|
|
170
130
|
extra_rdoc_files:
|
171
131
|
- README.md
|
172
132
|
files:
|
133
|
+
- ".github/workflows/ci.yml"
|
173
134
|
- ".gitignore"
|
174
135
|
- ".rspec"
|
175
136
|
- ".rubocop.yml"
|
@@ -178,24 +139,22 @@ files:
|
|
178
139
|
- LICENSE
|
179
140
|
- README.md
|
180
141
|
- Rakefile
|
181
|
-
- circle.yml
|
182
142
|
- config/devtools.yml
|
183
143
|
- config/flay.yml
|
184
144
|
- config/flog.yml
|
185
145
|
- config/mutant.yml
|
186
146
|
- config/reek.yml
|
187
|
-
- config/rubocop.yml
|
188
147
|
- config/yardstick.yml
|
189
148
|
- lb-persistence.gemspec
|
190
149
|
- lib/lb-persistence.rb
|
191
150
|
- lib/lb/persistence.rb
|
192
151
|
- lib/lb/persistence/functions.rb
|
193
|
-
- lib/lb/persistence/model/attributes.rb
|
194
152
|
- lib/lb/persistence/relation/joins.rb
|
195
153
|
- lib/lb/persistence/settings.rb
|
196
154
|
- lib/lb/persistence/types.rb
|
197
155
|
- lib/lb/persistence/version.rb
|
198
156
|
- rakelib/ci.rake
|
157
|
+
- rakelib/spec.rake
|
199
158
|
- spec/shared/settings.rb
|
200
159
|
- spec/spec_helper.rb
|
201
160
|
- spec/support/helper.rb
|
@@ -204,14 +163,14 @@ files:
|
|
204
163
|
- spec/unit/lb/persistence/container_spec.rb
|
205
164
|
- spec/unit/lb/persistence/functions/class_methods/group_prefix_spec.rb
|
206
165
|
- spec/unit/lb/persistence/functions/class_methods/wrap_prefix_spec.rb
|
207
|
-
- spec/unit/lb/persistence/model/redefine_attribute_spec.rb
|
208
166
|
- spec/unit/lb/persistence/repository_spec.rb
|
209
167
|
- spec/unit/lb/persistence/uri_spec.rb
|
210
168
|
homepage: https://github.com/lb-rb/lb-persistence
|
211
169
|
licenses:
|
212
170
|
- MIT
|
213
|
-
metadata:
|
214
|
-
|
171
|
+
metadata:
|
172
|
+
rubygems_mfa_required: 'true'
|
173
|
+
post_install_message:
|
215
174
|
rdoc_options: []
|
216
175
|
require_paths:
|
217
176
|
- lib
|
@@ -220,27 +179,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
220
179
|
requirements:
|
221
180
|
- - ">="
|
222
181
|
- !ruby/object:Gem::Version
|
223
|
-
version: '2.
|
182
|
+
version: '2.7'
|
224
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
184
|
requirements:
|
226
185
|
- - ">="
|
227
186
|
- !ruby/object:Gem::Version
|
228
187
|
version: '0'
|
229
188
|
requirements: []
|
230
|
-
|
231
|
-
|
232
|
-
signing_key:
|
189
|
+
rubygems_version: 3.4.10
|
190
|
+
signing_key:
|
233
191
|
specification_version: 4
|
234
192
|
summary: LB Persistence API
|
235
|
-
test_files:
|
236
|
-
- spec/shared/settings.rb
|
237
|
-
- spec/spec_helper.rb
|
238
|
-
- spec/support/helper.rb
|
239
|
-
- spec/unit/lb/persistence/class_methods/new_spec.rb
|
240
|
-
- spec/unit/lb/persistence/connect_spec.rb
|
241
|
-
- spec/unit/lb/persistence/container_spec.rb
|
242
|
-
- spec/unit/lb/persistence/functions/class_methods/group_prefix_spec.rb
|
243
|
-
- spec/unit/lb/persistence/functions/class_methods/wrap_prefix_spec.rb
|
244
|
-
- spec/unit/lb/persistence/model/redefine_attribute_spec.rb
|
245
|
-
- spec/unit/lb/persistence/repository_spec.rb
|
246
|
-
- spec/unit/lb/persistence/uri_spec.rb
|
193
|
+
test_files: []
|
data/.rubocop.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
./config/rubocop.yml
|
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
|
data/config/rubocop.yml
DELETED
@@ -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
|