lb-persistence 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +41 -0
- data/.rspec +6 -0
- data/.rubocop.yml +1 -0
- data/Gemfile +5 -0
- data/Guardfile +43 -0
- data/LICENSE +20 -0
- data/README.md +15 -0
- data/Rakefile +6 -0
- data/circle.yml +23 -0
- data/config/devtools.yml +2 -0
- data/config/flay.yml +3 -0
- data/config/flog.yml +2 -0
- data/config/mutant.yml +3 -0
- data/config/reek.yml +103 -0
- data/config/rubocop.yml +11 -0
- data/config/yardstick.yml +2 -0
- data/lb-persistence.gemspec +38 -0
- data/lib/lb-persistence.rb +5 -0
- data/lib/lb/persistence.rb +148 -0
- data/lib/lb/persistence/settings.rb +12 -0
- data/lib/lb/persistence/types.rb +10 -0
- data/lib/lb/persistence/version.rb +8 -0
- data/rakelib/ci.rake +24 -0
- data/spec/shared/settings.rb +24 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/support/helper.rb +5 -0
- data/spec/unit/lb/persistence/class_methods/new_spec.rb +15 -0
- data/spec/unit/lb/persistence/connect_spec.rb +15 -0
- data/spec/unit/lb/persistence/container_spec.rb +15 -0
- data/spec/unit/lb/persistence/repository_spec.rb +19 -0
- data/spec/unit/lb/persistence/uri_spec.rb +15 -0
- metadata +231 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 408b687b7a418e50c17884ddc2400d13016c76d2929acbab93ebe6f67a348202
|
|
4
|
+
data.tar.gz: e9a5178a5215b608d717e67589aa5427ea85f165f2b198d63e9a17cffb669692
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: f570f6059cf492528abaf58841466086e24b0ffc0ac0c2d74e445dfd8256f9081fb3d8db76814bf0553cdf81620d3697aebb8914103b7328d8e25beeb396ac55
|
|
7
|
+
data.tar.gz: 67125037975478b7c97730717a58249fdb377f759b5c04afd70c028fbb8f893680d9849810e045f048e65a93e28f4535da754f2fdcd87501aa4adf1eb000bdf5
|
data/.gitignore
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
## MAC OS
|
|
2
|
+
.DS_Store
|
|
3
|
+
|
|
4
|
+
## TEXTMATE
|
|
5
|
+
*.tmproj
|
|
6
|
+
tmtags
|
|
7
|
+
|
|
8
|
+
## EMACS
|
|
9
|
+
*~
|
|
10
|
+
\#*
|
|
11
|
+
.\#*
|
|
12
|
+
|
|
13
|
+
## VIM
|
|
14
|
+
*.sw[op]
|
|
15
|
+
|
|
16
|
+
## Rubinius
|
|
17
|
+
*.rbc
|
|
18
|
+
.rbx
|
|
19
|
+
|
|
20
|
+
## PROJECT::GENERAL
|
|
21
|
+
*.gem
|
|
22
|
+
coverage
|
|
23
|
+
profiling
|
|
24
|
+
turbulence
|
|
25
|
+
rdoc
|
|
26
|
+
pkg
|
|
27
|
+
tmp
|
|
28
|
+
doc
|
|
29
|
+
log
|
|
30
|
+
.yardoc
|
|
31
|
+
measurements
|
|
32
|
+
|
|
33
|
+
## BUNDLER
|
|
34
|
+
.bundle
|
|
35
|
+
Gemfile.lock
|
|
36
|
+
|
|
37
|
+
## ctags
|
|
38
|
+
tags
|
|
39
|
+
gems.tags
|
|
40
|
+
|
|
41
|
+
## PROJECT::SPECIFIC
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
./config/rubocop.yml
|
data/Gemfile
ADDED
data/Guardfile
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
guard :bundler do
|
|
5
|
+
watch('Gemfile')
|
|
6
|
+
watch('Gemfile.lock')
|
|
7
|
+
watch(/\A(.+)\.gemspec\z/)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
guard :rspec, cmd: 'bundle exec rspec ' +
|
|
11
|
+
File.read('.rspec').split.join(' '),
|
|
12
|
+
failed_mode: :keep do
|
|
13
|
+
# Run all specs if configuration is modified
|
|
14
|
+
watch('.rspec') { 'spec' }
|
|
15
|
+
watch('Guardfile') { 'spec' }
|
|
16
|
+
watch('Gemfile.lock') { 'spec' }
|
|
17
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
|
18
|
+
|
|
19
|
+
# Run all specs if supporting files files are modified
|
|
20
|
+
watch(%r{\Aspec/(?:fixtures|lib|support|shared)/.+\.rb\z}) { 'spec' }
|
|
21
|
+
|
|
22
|
+
# Run unit specs if associated lib code is modified
|
|
23
|
+
watch(%r{\Alib/(.+)\.rb\z}) do |m|
|
|
24
|
+
Dir["spec/unit/#{m[1]}*"]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
watch(%r{\Alib/(.+)/support/(.+)\.rb\z}) do |m|
|
|
28
|
+
Dir["spec/unit/#{m[1]}/#{m[2]}*"]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
watch("lib/#{File.basename(File.expand_path('../', __FILE__))}.rb") do
|
|
32
|
+
'spec'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Run a spec if it is modified
|
|
36
|
+
watch(%r{\Aspec/(?:unit|integration|features)/.+_spec\.rb\z})
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
guard :rubocop, cli: %w[--config config/rubocop.yml] do
|
|
40
|
+
watch(/.+\.(?:rb|rake|gemspec)\z/)
|
|
41
|
+
watch(%r{\Aconfig/rubocop\.yml\z}) { |m| File.dirname(m[0]) }
|
|
42
|
+
watch(%r{(?:.+/)?\.rubocop\.yml\z}) { |m| File.dirname(m[0]) }
|
|
43
|
+
end
|
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2017-2018 Firas Zaidan
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[gem]: https://rubygems.org/gems/lb-persistence
|
|
2
|
+
[ci]: https://circleci.com/gh/lb-rb/lb-persistence/tree/master
|
|
3
|
+
|
|
4
|
+
# lb-persistence
|
|
5
|
+
|
|
6
|
+
[][gem]
|
|
7
|
+
[][ci]
|
|
8
|
+
|
|
9
|
+
## Credits
|
|
10
|
+
|
|
11
|
+
* [Firas Zaidan](https://github.com/zaidan)
|
|
12
|
+
|
|
13
|
+
## License
|
|
14
|
+
|
|
15
|
+
See `LICENSE` file.
|
data/Rakefile
ADDED
data/circle.yml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
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/devtools.yml
ADDED
data/config/flay.yml
ADDED
data/config/flog.yml
ADDED
data/config/mutant.yml
ADDED
data/config/reek.yml
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
Attribute:
|
|
3
|
+
enabled: false
|
|
4
|
+
exclude: []
|
|
5
|
+
BooleanParameter:
|
|
6
|
+
enabled: true
|
|
7
|
+
exclude: []
|
|
8
|
+
ClassVariable:
|
|
9
|
+
enabled: true
|
|
10
|
+
exclude: []
|
|
11
|
+
ControlParameter:
|
|
12
|
+
enabled: true
|
|
13
|
+
exclude: []
|
|
14
|
+
DataClump:
|
|
15
|
+
enabled: true
|
|
16
|
+
exclude: []
|
|
17
|
+
max_copies: 0
|
|
18
|
+
min_clump_size: 2
|
|
19
|
+
DuplicateMethodCall:
|
|
20
|
+
enabled: true
|
|
21
|
+
exclude: []
|
|
22
|
+
max_calls: 1
|
|
23
|
+
allow_calls: []
|
|
24
|
+
FeatureEnvy:
|
|
25
|
+
enabled: true
|
|
26
|
+
exclude: []
|
|
27
|
+
IrresponsibleModule:
|
|
28
|
+
enabled: true
|
|
29
|
+
exclude: []
|
|
30
|
+
LongParameterList:
|
|
31
|
+
enabled: true
|
|
32
|
+
exclude: []
|
|
33
|
+
max_params: 2
|
|
34
|
+
overrides: {}
|
|
35
|
+
LongYieldList:
|
|
36
|
+
enabled: true
|
|
37
|
+
exclude: []
|
|
38
|
+
max_params: 0
|
|
39
|
+
NestedIterators:
|
|
40
|
+
enabled: true
|
|
41
|
+
exclude: []
|
|
42
|
+
max_allowed_nesting: 1
|
|
43
|
+
ignore_iterators: []
|
|
44
|
+
NilCheck:
|
|
45
|
+
enabled: true
|
|
46
|
+
exclude: []
|
|
47
|
+
RepeatedConditional:
|
|
48
|
+
enabled: true
|
|
49
|
+
exclude: []
|
|
50
|
+
max_ifs: 1
|
|
51
|
+
TooManyConstants:
|
|
52
|
+
enabled: true
|
|
53
|
+
exclude: []
|
|
54
|
+
TooManyInstanceVariables:
|
|
55
|
+
enabled: true
|
|
56
|
+
exclude: []
|
|
57
|
+
max_instance_variables: 2
|
|
58
|
+
TooManyMethods:
|
|
59
|
+
enabled: true
|
|
60
|
+
exclude: []
|
|
61
|
+
max_methods: 15
|
|
62
|
+
TooManyStatements:
|
|
63
|
+
enabled: true
|
|
64
|
+
exclude: []
|
|
65
|
+
max_statements: 5
|
|
66
|
+
UncommunicativeMethodName:
|
|
67
|
+
enabled: true
|
|
68
|
+
exclude: []
|
|
69
|
+
reject:
|
|
70
|
+
- !ruby/regexp /^[a-z]$/
|
|
71
|
+
- !ruby/regexp /[0-9]$/
|
|
72
|
+
- !ruby/regexp /[A-Z]/
|
|
73
|
+
accept: []
|
|
74
|
+
UncommunicativeModuleName:
|
|
75
|
+
enabled: true
|
|
76
|
+
exclude: []
|
|
77
|
+
reject:
|
|
78
|
+
- !ruby/regexp /^.$/
|
|
79
|
+
- !ruby/regexp /[0-9]$/
|
|
80
|
+
accept: []
|
|
81
|
+
UncommunicativeParameterName:
|
|
82
|
+
enabled: true
|
|
83
|
+
exclude: []
|
|
84
|
+
reject:
|
|
85
|
+
- !ruby/regexp /^.$/
|
|
86
|
+
- !ruby/regexp /[0-9]$/
|
|
87
|
+
- !ruby/regexp /[A-Z]/
|
|
88
|
+
accept: []
|
|
89
|
+
UncommunicativeVariableName:
|
|
90
|
+
enabled: true
|
|
91
|
+
exclude: []
|
|
92
|
+
reject:
|
|
93
|
+
- !ruby/regexp /^.$/
|
|
94
|
+
- !ruby/regexp /[0-9]$/
|
|
95
|
+
- !ruby/regexp /[A-Z]/
|
|
96
|
+
accept: []
|
|
97
|
+
UnusedParameters:
|
|
98
|
+
enabled: true
|
|
99
|
+
exclude: []
|
|
100
|
+
UtilityFunction:
|
|
101
|
+
enabled: true
|
|
102
|
+
exclude: []
|
|
103
|
+
max_helper_calls: 0
|
data/config/rubocop.yml
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
require File.expand_path('../lib/lb/persistence/version', __FILE__)
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |gem|
|
|
7
|
+
gem.name = 'lb-persistence'
|
|
8
|
+
gem.version = LB::Persistence::VERSION.dup
|
|
9
|
+
gem.authors = ['Firas Zaidan']
|
|
10
|
+
gem.email = ['firas@zaidan.de']
|
|
11
|
+
gem.description = 'LB Persistence API'
|
|
12
|
+
gem.summary = gem.description
|
|
13
|
+
gem.homepage = 'https://github.com/lb-rb/lb-persistence'
|
|
14
|
+
gem.license = 'MIT'
|
|
15
|
+
|
|
16
|
+
gem.bindir = 'bin'
|
|
17
|
+
gem.require_paths = %w[lib bin]
|
|
18
|
+
gem.files = `git ls-files`
|
|
19
|
+
.split($INPUT_RECORD_SEPARATOR)
|
|
20
|
+
gem.executables = `git ls-files -- bin/*`
|
|
21
|
+
.split("\n").map { |f| File.basename(f) }
|
|
22
|
+
gem.test_files = `git ls-files -- spec`
|
|
23
|
+
.split($INPUT_RECORD_SEPARATOR)
|
|
24
|
+
gem.extra_rdoc_files = %w[README.md]
|
|
25
|
+
gem.required_ruby_version = '>= 2.4'
|
|
26
|
+
|
|
27
|
+
gem.add_dependency 'dry-struct', '~> 0.4'
|
|
28
|
+
gem.add_dependency 'rom', '~> 4.2'
|
|
29
|
+
gem.add_dependency 'rom-sql', '~> 2.4'
|
|
30
|
+
|
|
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'
|
|
34
|
+
gem.add_development_dependency 'guard-rspec', '~> 4.7', '>= 4.7.3'
|
|
35
|
+
gem.add_development_dependency 'guard-rubocop', '~> 1.3'
|
|
36
|
+
gem.add_development_dependency 'rubocop', '~> 0.52'
|
|
37
|
+
gem.add_development_dependency 'sqlite3', '~> 1.3'
|
|
38
|
+
end
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# ROM
|
|
4
|
+
require 'rom-sql'
|
|
5
|
+
require 'rom-repository'
|
|
6
|
+
require 'rom-mapper'
|
|
7
|
+
require 'rom-changeset'
|
|
8
|
+
|
|
9
|
+
require 'lb/persistence/types'
|
|
10
|
+
require 'lb/persistence/settings'
|
|
11
|
+
|
|
12
|
+
# LB namespace
|
|
13
|
+
module LB
|
|
14
|
+
# Persistence
|
|
15
|
+
class Persistence
|
|
16
|
+
attr_reader :settings
|
|
17
|
+
|
|
18
|
+
def initialize(settings)
|
|
19
|
+
@settings = settings
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Get ROM container
|
|
23
|
+
#
|
|
24
|
+
# @return [ROM::Conatainer]
|
|
25
|
+
#
|
|
26
|
+
# @api private
|
|
27
|
+
#
|
|
28
|
+
def container
|
|
29
|
+
@container ||= rom_setup(uri)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Get ROM Repository instance for Repository class
|
|
33
|
+
#
|
|
34
|
+
# @return [ROM::Repository]
|
|
35
|
+
#
|
|
36
|
+
# @api private
|
|
37
|
+
#
|
|
38
|
+
def repository(repository)
|
|
39
|
+
repository.new(container)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Connect to database definied by given URI
|
|
43
|
+
#
|
|
44
|
+
# @param [String]
|
|
45
|
+
#
|
|
46
|
+
# @return [Sequel::Database]
|
|
47
|
+
#
|
|
48
|
+
# @api private
|
|
49
|
+
#
|
|
50
|
+
def connect(uri)
|
|
51
|
+
Sequel.connect(uri)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Configure ROM for given connection or URI
|
|
55
|
+
#
|
|
56
|
+
# @param [Sequel::Database | String]
|
|
57
|
+
#
|
|
58
|
+
# @return [ROM::Configuration]
|
|
59
|
+
#
|
|
60
|
+
# @api private
|
|
61
|
+
#
|
|
62
|
+
def configure_for(connection)
|
|
63
|
+
configure(configuration_for(connection))
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Get URI
|
|
67
|
+
#
|
|
68
|
+
# @return [String]
|
|
69
|
+
#
|
|
70
|
+
# @api private
|
|
71
|
+
#
|
|
72
|
+
def uri
|
|
73
|
+
@uri ||= settings.database_uri
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
private
|
|
77
|
+
|
|
78
|
+
# Create ROM container for given config
|
|
79
|
+
#
|
|
80
|
+
# @param [ROM::Configuration] config
|
|
81
|
+
#
|
|
82
|
+
# @return [ROM::Container]
|
|
83
|
+
#
|
|
84
|
+
# @api private
|
|
85
|
+
#
|
|
86
|
+
def container_from(config)
|
|
87
|
+
ROM.container(config)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# Setup rom for given URI
|
|
91
|
+
#
|
|
92
|
+
# @param [String]
|
|
93
|
+
#
|
|
94
|
+
# @return [ROM::Conatainer]
|
|
95
|
+
#
|
|
96
|
+
# @api private
|
|
97
|
+
#
|
|
98
|
+
def rom_setup(uri)
|
|
99
|
+
container_from(configure_for(uri))
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Create ROM configuration for given connection or URI
|
|
103
|
+
#
|
|
104
|
+
# @param [Sequel::Database | String]
|
|
105
|
+
#
|
|
106
|
+
# @return [ROM::Configuration]
|
|
107
|
+
#
|
|
108
|
+
# @api private
|
|
109
|
+
#
|
|
110
|
+
def configuration_for(connection)
|
|
111
|
+
ROM::Configuration.new(:sql, connection)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Configure ROM
|
|
115
|
+
#
|
|
116
|
+
# @param [ROM::Configuration] config
|
|
117
|
+
#
|
|
118
|
+
# @return [ROM::Configuration]
|
|
119
|
+
#
|
|
120
|
+
# @api private
|
|
121
|
+
#
|
|
122
|
+
def configure(config)
|
|
123
|
+
config.auto_registration(settings.source_dir, options)
|
|
124
|
+
|
|
125
|
+
config
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Get ROM auto registration options
|
|
129
|
+
#
|
|
130
|
+
# @param [IO] source
|
|
131
|
+
# @param [IO] target
|
|
132
|
+
#
|
|
133
|
+
# @return [Hash]
|
|
134
|
+
#
|
|
135
|
+
# @api private
|
|
136
|
+
#
|
|
137
|
+
def options
|
|
138
|
+
{
|
|
139
|
+
component_dirs: {
|
|
140
|
+
relations: :relations,
|
|
141
|
+
commands: :commands,
|
|
142
|
+
mappers: :mappers
|
|
143
|
+
},
|
|
144
|
+
namespace: settings.namespace
|
|
145
|
+
}
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module LB
|
|
4
|
+
class Persistence
|
|
5
|
+
# Settings supplied to LB::Persistence
|
|
6
|
+
class Settings < Dry::Struct
|
|
7
|
+
attribute :source_dir, Types::Strict::String
|
|
8
|
+
attribute :namespace, Types::Strict::String
|
|
9
|
+
attribute :database_uri, Types::Strict::String
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
data/rakelib/ci.rake
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Remove existing same-named tasks
|
|
4
|
+
%w[ci ci:metrics].each do |task|
|
|
5
|
+
klass = Rake::Task
|
|
6
|
+
klass[task].clear if klass.task_defined?(task)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
desc 'Run all specs, metrics and mutant'
|
|
10
|
+
task ci: %w[ci:metrics]
|
|
11
|
+
|
|
12
|
+
namespace :ci do
|
|
13
|
+
tasks = %w[
|
|
14
|
+
metrics:coverage
|
|
15
|
+
metrics:yardstick:verify
|
|
16
|
+
metrics:rubocop
|
|
17
|
+
metrics:flog
|
|
18
|
+
metrics:flay
|
|
19
|
+
spec:integration
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
desc 'Run metrics (except mutant)'
|
|
23
|
+
task metrics: tasks
|
|
24
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
shared_context 'settings' do
|
|
4
|
+
def root_for(file, depth = 2)
|
|
5
|
+
path = File.expand_path(file)
|
|
6
|
+
depth.times { path = File.dirname(path) }
|
|
7
|
+
path
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
let(:root) { root_for(__FILE__, 3) }
|
|
11
|
+
|
|
12
|
+
let(:source_dir) { File.join(root, 'spec/fixtures/lib/example/persistence') }
|
|
13
|
+
|
|
14
|
+
let(:namespace) { 'Test::Persistence' }
|
|
15
|
+
|
|
16
|
+
let(:database_uri) { 'sqlite::memory' }
|
|
17
|
+
let(:settings) do
|
|
18
|
+
LB::Persistence::Settings.new(
|
|
19
|
+
source_dir: root,
|
|
20
|
+
namespace: namespace,
|
|
21
|
+
database_uri: database_uri
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
if ENV['COVERAGE'] == 'true'
|
|
5
|
+
require 'simplecov'
|
|
6
|
+
|
|
7
|
+
SimpleCov.start do
|
|
8
|
+
command_name 'spec:unit'
|
|
9
|
+
|
|
10
|
+
add_filter 'config'
|
|
11
|
+
add_filter 'spec'
|
|
12
|
+
|
|
13
|
+
minimum_coverage 100
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
$LOAD_PATH << 'lib'
|
|
18
|
+
|
|
19
|
+
require 'lb-persistence'
|
|
20
|
+
|
|
21
|
+
require 'devtools/spec_helper'
|
|
22
|
+
|
|
23
|
+
# require spec support files and shared behavior
|
|
24
|
+
Dir[File.expand_path('../{support,shared}/**/*.rb', __FILE__)].each do |file|
|
|
25
|
+
require file
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
RSpec.configure do |config|
|
|
29
|
+
config.include(SpecHelper)
|
|
30
|
+
config.mock_framework = :rspec
|
|
31
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe LB::Persistence, '.new' do
|
|
6
|
+
include_context 'settings'
|
|
7
|
+
|
|
8
|
+
subject { object.new(settings) }
|
|
9
|
+
|
|
10
|
+
let(:object) { described_class }
|
|
11
|
+
|
|
12
|
+
it 'should return config' do
|
|
13
|
+
expect(subject).to be_a(object)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe LB::Persistence, '#connect' do
|
|
6
|
+
include_context 'settings'
|
|
7
|
+
|
|
8
|
+
subject { object.connect(database_uri) }
|
|
9
|
+
|
|
10
|
+
let(:object) { described_class.new(settings) }
|
|
11
|
+
|
|
12
|
+
it 'should return container' do
|
|
13
|
+
expect(subject).to be_a(Sequel::SQLite::Database)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe LB::Persistence, '#container' do
|
|
6
|
+
include_context 'settings'
|
|
7
|
+
|
|
8
|
+
subject { object.container }
|
|
9
|
+
|
|
10
|
+
let(:object) { described_class.new(settings) }
|
|
11
|
+
|
|
12
|
+
it 'should return container' do
|
|
13
|
+
expect(subject).to be_a(ROM::Container)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe LB::Persistence, '#repository' do
|
|
6
|
+
include_context 'settings'
|
|
7
|
+
|
|
8
|
+
subject { object.repository(repository) }
|
|
9
|
+
|
|
10
|
+
let(:object) { described_class.new(settings) }
|
|
11
|
+
|
|
12
|
+
let(:repository) { class_double('repository', new: repository_instance) }
|
|
13
|
+
let(:repository_instance) { double('repository instance') }
|
|
14
|
+
|
|
15
|
+
it 'should return container' do
|
|
16
|
+
expect(repository).to receive(:new).with(object.container)
|
|
17
|
+
expect(subject).to be(repository_instance)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe LB::Persistence, '#uri' do
|
|
6
|
+
include_context 'settings'
|
|
7
|
+
|
|
8
|
+
subject { object.uri }
|
|
9
|
+
|
|
10
|
+
let(:object) { described_class.new(settings) }
|
|
11
|
+
|
|
12
|
+
it 'should return database uri' do
|
|
13
|
+
expect(subject).to be(database_uri)
|
|
14
|
+
end
|
|
15
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: lb-persistence
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Firas Zaidan
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-05-13 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: dry-struct
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0.4'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0.4'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rom
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '4.2'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '4.2'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rom-sql
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '2.4'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '2.4'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: devtools
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 0.1.20
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 0.1.20
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: guard
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '2.14'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '2.14'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: guard-bundler
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '2.1'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '2.1'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: guard-rspec
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '4.7'
|
|
104
|
+
- - ">="
|
|
105
|
+
- !ruby/object:Gem::Version
|
|
106
|
+
version: 4.7.3
|
|
107
|
+
type: :development
|
|
108
|
+
prerelease: false
|
|
109
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
110
|
+
requirements:
|
|
111
|
+
- - "~>"
|
|
112
|
+
- !ruby/object:Gem::Version
|
|
113
|
+
version: '4.7'
|
|
114
|
+
- - ">="
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: 4.7.3
|
|
117
|
+
- !ruby/object:Gem::Dependency
|
|
118
|
+
name: guard-rubocop
|
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - "~>"
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '1.3'
|
|
124
|
+
type: :development
|
|
125
|
+
prerelease: false
|
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
127
|
+
requirements:
|
|
128
|
+
- - "~>"
|
|
129
|
+
- !ruby/object:Gem::Version
|
|
130
|
+
version: '1.3'
|
|
131
|
+
- !ruby/object:Gem::Dependency
|
|
132
|
+
name: rubocop
|
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
|
134
|
+
requirements:
|
|
135
|
+
- - "~>"
|
|
136
|
+
- !ruby/object:Gem::Version
|
|
137
|
+
version: '0.52'
|
|
138
|
+
type: :development
|
|
139
|
+
prerelease: false
|
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
141
|
+
requirements:
|
|
142
|
+
- - "~>"
|
|
143
|
+
- !ruby/object:Gem::Version
|
|
144
|
+
version: '0.52'
|
|
145
|
+
- !ruby/object:Gem::Dependency
|
|
146
|
+
name: sqlite3
|
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
|
148
|
+
requirements:
|
|
149
|
+
- - "~>"
|
|
150
|
+
- !ruby/object:Gem::Version
|
|
151
|
+
version: '1.3'
|
|
152
|
+
type: :development
|
|
153
|
+
prerelease: false
|
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
155
|
+
requirements:
|
|
156
|
+
- - "~>"
|
|
157
|
+
- !ruby/object:Gem::Version
|
|
158
|
+
version: '1.3'
|
|
159
|
+
description: LB Persistence API
|
|
160
|
+
email:
|
|
161
|
+
- firas@zaidan.de
|
|
162
|
+
executables: []
|
|
163
|
+
extensions: []
|
|
164
|
+
extra_rdoc_files:
|
|
165
|
+
- README.md
|
|
166
|
+
files:
|
|
167
|
+
- ".gitignore"
|
|
168
|
+
- ".rspec"
|
|
169
|
+
- ".rubocop.yml"
|
|
170
|
+
- Gemfile
|
|
171
|
+
- Guardfile
|
|
172
|
+
- LICENSE
|
|
173
|
+
- README.md
|
|
174
|
+
- Rakefile
|
|
175
|
+
- circle.yml
|
|
176
|
+
- config/devtools.yml
|
|
177
|
+
- config/flay.yml
|
|
178
|
+
- config/flog.yml
|
|
179
|
+
- config/mutant.yml
|
|
180
|
+
- config/reek.yml
|
|
181
|
+
- config/rubocop.yml
|
|
182
|
+
- config/yardstick.yml
|
|
183
|
+
- lb-persistence.gemspec
|
|
184
|
+
- lib/lb-persistence.rb
|
|
185
|
+
- lib/lb/persistence.rb
|
|
186
|
+
- lib/lb/persistence/settings.rb
|
|
187
|
+
- lib/lb/persistence/types.rb
|
|
188
|
+
- lib/lb/persistence/version.rb
|
|
189
|
+
- rakelib/ci.rake
|
|
190
|
+
- spec/shared/settings.rb
|
|
191
|
+
- spec/spec_helper.rb
|
|
192
|
+
- spec/support/helper.rb
|
|
193
|
+
- spec/unit/lb/persistence/class_methods/new_spec.rb
|
|
194
|
+
- spec/unit/lb/persistence/connect_spec.rb
|
|
195
|
+
- spec/unit/lb/persistence/container_spec.rb
|
|
196
|
+
- spec/unit/lb/persistence/repository_spec.rb
|
|
197
|
+
- spec/unit/lb/persistence/uri_spec.rb
|
|
198
|
+
homepage: https://github.com/lb-rb/lb-persistence
|
|
199
|
+
licenses:
|
|
200
|
+
- MIT
|
|
201
|
+
metadata: {}
|
|
202
|
+
post_install_message:
|
|
203
|
+
rdoc_options: []
|
|
204
|
+
require_paths:
|
|
205
|
+
- lib
|
|
206
|
+
- bin
|
|
207
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
208
|
+
requirements:
|
|
209
|
+
- - ">="
|
|
210
|
+
- !ruby/object:Gem::Version
|
|
211
|
+
version: '2.4'
|
|
212
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
|
+
requirements:
|
|
214
|
+
- - ">="
|
|
215
|
+
- !ruby/object:Gem::Version
|
|
216
|
+
version: '0'
|
|
217
|
+
requirements: []
|
|
218
|
+
rubyforge_project:
|
|
219
|
+
rubygems_version: 2.7.6
|
|
220
|
+
signing_key:
|
|
221
|
+
specification_version: 4
|
|
222
|
+
summary: LB Persistence API
|
|
223
|
+
test_files:
|
|
224
|
+
- spec/shared/settings.rb
|
|
225
|
+
- spec/spec_helper.rb
|
|
226
|
+
- spec/support/helper.rb
|
|
227
|
+
- spec/unit/lb/persistence/class_methods/new_spec.rb
|
|
228
|
+
- spec/unit/lb/persistence/connect_spec.rb
|
|
229
|
+
- spec/unit/lb/persistence/container_spec.rb
|
|
230
|
+
- spec/unit/lb/persistence/repository_spec.rb
|
|
231
|
+
- spec/unit/lb/persistence/uri_spec.rb
|