umbrellio-sequel-plugins 0.4.0.121 → 0.5.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 +65 -0
- data/.travis.yml +1 -4
- data/Gemfile.lock +74 -75
- data/README.md +49 -15
- data/Rakefile +3 -1
- data/lib/sequel/plugins/attr_encrypted.rb +98 -0
- data/lib/sequel/plugins/attr_encrypted/simple_crypt.rb +46 -0
- data/lib/sequel/timestamp_migrator_undo_extension.rb +7 -3
- data/lib/umbrellio-sequel-plugins.rb +1 -1
- data/umbrellio-sequel-plugins.gemspec +6 -6
- data/utils/database.rb +1 -0
- metadata +22 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a56d6ec4ec8867a8f8f2d6721f240519d298e0fbcf0574b6f99eebc73bf5edad
|
4
|
+
data.tar.gz: d47dd520afe94e7cf2fcb7314305d48399499054d6bc7da4cd1ddb7ed525f1c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b5ee860f246e355526d33a852b11273e23caae0e03a02ae298ab4af33e21a3cfb72a231ae93b5a80e76232222041ed9e7e256a17401294887613ca7e3377f1b
|
7
|
+
data.tar.gz: 4ae1b3566ab9471fa4b1962fece7fd9bf3c8f6b34a7af3946dbbe9d2060f6da8c8b2d04f838e126fbbe353c0ad33b86b0d357b08b4e2cdc04322b4b232af84f3
|
@@ -0,0 +1,65 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
|
9
|
+
# We want to run on external PRs, but not on our own internal PRs as they'll be run on push event
|
10
|
+
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != 'umbrellio/umbrellio-sequel-plugins'
|
11
|
+
|
12
|
+
services:
|
13
|
+
postgres:
|
14
|
+
image: postgres:12
|
15
|
+
env:
|
16
|
+
POSTGRES_USER: root
|
17
|
+
POSTGRES_HOST_AUTH_METHOD: trust
|
18
|
+
options: >-
|
19
|
+
--health-cmd pg_isready
|
20
|
+
--health-interval 10s
|
21
|
+
--health-timeout 5s
|
22
|
+
--health-retries 5
|
23
|
+
ports:
|
24
|
+
- 5432:5432
|
25
|
+
|
26
|
+
env:
|
27
|
+
PGHOST: localhost
|
28
|
+
PGUSER: root
|
29
|
+
|
30
|
+
strategy:
|
31
|
+
fail-fast: false
|
32
|
+
matrix:
|
33
|
+
ruby: ["2.5", "2.6", "2.7", "3.0"]
|
34
|
+
|
35
|
+
name: ${{ matrix.ruby }}
|
36
|
+
|
37
|
+
steps:
|
38
|
+
- uses: actions/checkout@v2
|
39
|
+
|
40
|
+
- uses: ruby/setup-ruby@v1
|
41
|
+
with:
|
42
|
+
ruby-version: ${{ matrix.ruby }}
|
43
|
+
bundler-cache: true
|
44
|
+
|
45
|
+
- run: psql -c 'CREATE DATABASE sequel_plugins'
|
46
|
+
- run: bundle exec rake
|
47
|
+
|
48
|
+
- uses: coverallsapp/github-action@v1.1.2
|
49
|
+
with:
|
50
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
51
|
+
|
52
|
+
deploy:
|
53
|
+
runs-on: ubuntu-latest
|
54
|
+
|
55
|
+
environment: Deploy
|
56
|
+
|
57
|
+
# Run on push to master branch
|
58
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
59
|
+
|
60
|
+
steps:
|
61
|
+
- uses: actions/checkout@v1
|
62
|
+
|
63
|
+
- uses: umbrellio/publish-ruby-gem-action@v1
|
64
|
+
with:
|
65
|
+
api-key: ${{secrets.RUBYGEMS_API_KEY}}
|
data/.travis.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
3
|
os: linux
|
4
|
+
|
4
5
|
dist: xenial
|
5
6
|
|
6
7
|
jobs:
|
@@ -43,10 +44,6 @@ install: bundle install --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
|
|
43
44
|
before_script:
|
44
45
|
- psql -c 'create database sequel_plugins;' -U postgres
|
45
46
|
|
46
|
-
script:
|
47
|
-
- bundle exec rspec
|
48
|
-
- bundle exec rubocop
|
49
|
-
|
50
47
|
deploy:
|
51
48
|
provider: rubygems
|
52
49
|
api_key:
|
data/Gemfile.lock
CHANGED
@@ -1,109 +1,107 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
umbrellio-sequel-plugins (0.
|
4
|
+
umbrellio-sequel-plugins (0.5.0)
|
5
5
|
sequel
|
6
|
-
symbiont-ruby
|
6
|
+
symbiont-ruby
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (6.
|
11
|
+
activesupport (6.1.3)
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
-
i18n (>=
|
14
|
-
minitest (
|
15
|
-
tzinfo (~>
|
16
|
-
zeitwerk (~> 2.
|
17
|
-
ast (2.4.
|
18
|
-
coderay (1.1.
|
19
|
-
concurrent-ruby (1.1.
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
term-ansicolor (~> 1.3)
|
24
|
-
thor (>= 0.19.4, < 2.0)
|
25
|
-
tins (~> 1.6)
|
26
|
-
diff-lcs (1.3)
|
27
|
-
docile (1.3.2)
|
28
|
-
i18n (1.8.2)
|
13
|
+
i18n (>= 1.6, < 2)
|
14
|
+
minitest (>= 5.1)
|
15
|
+
tzinfo (~> 2.0)
|
16
|
+
zeitwerk (~> 2.3)
|
17
|
+
ast (2.4.2)
|
18
|
+
coderay (1.1.3)
|
19
|
+
concurrent-ruby (1.1.8)
|
20
|
+
diff-lcs (1.4.4)
|
21
|
+
docile (1.3.5)
|
22
|
+
i18n (1.8.9)
|
29
23
|
concurrent-ruby (~> 1.0)
|
30
|
-
jaro_winkler (1.5.4)
|
31
|
-
json (2.3.0)
|
32
24
|
method_source (1.0.0)
|
33
|
-
minitest (5.14.
|
34
|
-
money (6.
|
25
|
+
minitest (5.14.4)
|
26
|
+
money (6.14.1)
|
35
27
|
i18n (>= 0.6.4, <= 2)
|
36
|
-
parallel (1.
|
37
|
-
parser (
|
38
|
-
ast (~> 2.4.
|
28
|
+
parallel (1.20.1)
|
29
|
+
parser (3.0.0.0)
|
30
|
+
ast (~> 2.4.1)
|
39
31
|
pg (1.2.3)
|
40
|
-
pry (0.
|
32
|
+
pry (0.14.0)
|
41
33
|
coderay (~> 1.1)
|
42
34
|
method_source (~> 1.0)
|
43
|
-
rack (2.2.
|
35
|
+
rack (2.2.3)
|
44
36
|
rainbow (3.0.0)
|
45
|
-
rake (13.0.
|
37
|
+
rake (13.0.3)
|
38
|
+
regexp_parser (2.1.1)
|
46
39
|
rexml (3.2.4)
|
47
|
-
rspec (3.
|
48
|
-
rspec-core (~> 3.
|
49
|
-
rspec-expectations (~> 3.
|
50
|
-
rspec-mocks (~> 3.
|
51
|
-
rspec-core (3.
|
52
|
-
rspec-support (~> 3.
|
53
|
-
rspec-expectations (3.
|
40
|
+
rspec (3.10.0)
|
41
|
+
rspec-core (~> 3.10.0)
|
42
|
+
rspec-expectations (~> 3.10.0)
|
43
|
+
rspec-mocks (~> 3.10.0)
|
44
|
+
rspec-core (3.10.1)
|
45
|
+
rspec-support (~> 3.10.0)
|
46
|
+
rspec-expectations (3.10.1)
|
54
47
|
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
-
rspec-support (~> 3.
|
56
|
-
rspec-mocks (3.
|
48
|
+
rspec-support (~> 3.10.0)
|
49
|
+
rspec-mocks (3.10.2)
|
57
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
58
|
-
rspec-support (~> 3.
|
59
|
-
rspec-support (3.
|
60
|
-
rubocop (
|
61
|
-
jaro_winkler (~> 1.5.1)
|
51
|
+
rspec-support (~> 3.10.0)
|
52
|
+
rspec-support (3.10.2)
|
53
|
+
rubocop (1.11.0)
|
62
54
|
parallel (~> 1.10)
|
63
|
-
parser (>=
|
55
|
+
parser (>= 3.0.0.0)
|
64
56
|
rainbow (>= 2.2.2, < 4.0)
|
57
|
+
regexp_parser (>= 1.8, < 3.0)
|
65
58
|
rexml
|
59
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
66
60
|
ruby-progressbar (~> 1.7)
|
67
|
-
unicode-display_width (>= 1.4.0, <
|
68
|
-
rubocop-
|
69
|
-
|
70
|
-
|
71
|
-
rubocop
|
72
|
-
rubocop-
|
73
|
-
|
74
|
-
rubocop (
|
75
|
-
|
76
|
-
|
61
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
62
|
+
rubocop-ast (1.4.1)
|
63
|
+
parser (>= 2.7.1.5)
|
64
|
+
rubocop-config-umbrellio (1.11.0.40)
|
65
|
+
rubocop (= 1.11.0)
|
66
|
+
rubocop-performance (= 1.10.0)
|
67
|
+
rubocop-rails (= 2.9.1)
|
68
|
+
rubocop-rake (= 0.5.1)
|
69
|
+
rubocop-rspec (= 2.2.0)
|
70
|
+
rubocop-sequel (= 0.2.0)
|
71
|
+
rubocop-performance (1.10.0)
|
72
|
+
rubocop (>= 0.90.0, < 2.0)
|
73
|
+
rubocop-ast (>= 0.4.0)
|
74
|
+
rubocop-rails (2.9.1)
|
75
|
+
activesupport (>= 4.2.0)
|
77
76
|
rack (>= 1.1)
|
78
|
-
rubocop (>= 0.
|
79
|
-
rubocop-
|
80
|
-
rubocop
|
81
|
-
|
82
|
-
|
83
|
-
|
77
|
+
rubocop (>= 0.90.0, < 2.0)
|
78
|
+
rubocop-rake (0.5.1)
|
79
|
+
rubocop
|
80
|
+
rubocop-rspec (2.2.0)
|
81
|
+
rubocop (~> 1.0)
|
82
|
+
rubocop-ast (>= 1.1.0)
|
83
|
+
rubocop-sequel (0.2.0)
|
84
|
+
rubocop (~> 1.0)
|
85
|
+
ruby-progressbar (1.11.0)
|
86
|
+
sequel (5.42.0)
|
87
|
+
simplecov (0.21.2)
|
84
88
|
docile (~> 1.1)
|
85
|
-
|
86
|
-
|
87
|
-
simplecov-html (0.
|
89
|
+
simplecov-html (~> 0.11)
|
90
|
+
simplecov_json_formatter (~> 0.1)
|
91
|
+
simplecov-html (0.12.3)
|
92
|
+
simplecov-lcov (0.8.0)
|
93
|
+
simplecov_json_formatter (0.1.2)
|
88
94
|
symbiont-ruby (0.6.0)
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
thread_safe (0.3.6)
|
94
|
-
tins (1.24.1)
|
95
|
-
sync
|
96
|
-
tzinfo (1.2.7)
|
97
|
-
thread_safe (~> 0.1)
|
98
|
-
unicode-display_width (1.7.0)
|
99
|
-
zeitwerk (2.3.0)
|
95
|
+
tzinfo (2.0.4)
|
96
|
+
concurrent-ruby (~> 1.0)
|
97
|
+
unicode-display_width (2.0.0)
|
98
|
+
zeitwerk (2.4.2)
|
100
99
|
|
101
100
|
PLATFORMS
|
102
101
|
ruby
|
103
102
|
|
104
103
|
DEPENDENCIES
|
105
104
|
bundler
|
106
|
-
coveralls (>= 0.8)
|
107
105
|
money
|
108
106
|
pg
|
109
107
|
pry
|
@@ -111,7 +109,8 @@ DEPENDENCIES
|
|
111
109
|
rspec
|
112
110
|
rubocop-config-umbrellio
|
113
111
|
simplecov
|
112
|
+
simplecov-lcov
|
114
113
|
umbrellio-sequel-plugins!
|
115
114
|
|
116
115
|
BUNDLED WITH
|
117
|
-
2.
|
116
|
+
2.2.11
|
data/README.md
CHANGED
@@ -13,29 +13,30 @@ gem 'umbrellio-sequel-plugins'
|
|
13
13
|
|
14
14
|
And then execute:
|
15
15
|
|
16
|
-
|
16
|
+
$ bundle
|
17
17
|
|
18
18
|
# Extensions
|
19
19
|
|
20
|
-
- `CurrencyRates`
|
21
|
-
- `PGTools`
|
22
|
-
- `Slave`
|
23
|
-
- `Synchronize`
|
24
|
-
- `
|
25
|
-
- `
|
20
|
+
- [`CurrencyRates`](#CurrencyRates)
|
21
|
+
- [`PGTools`](#PGTools)
|
22
|
+
- [`Slave`](#Slave)
|
23
|
+
- [`Synchronize`](#Synchronize)
|
24
|
+
- [`Methods in Migrations`](#Methods-in-Migrations)
|
25
|
+
- [`Deferrable Foreign Keys`](#Deferrable-Foreign-Keys)
|
26
26
|
|
27
27
|
# Plugins
|
28
28
|
|
29
|
-
- `
|
30
|
-
- `
|
31
|
-
- `
|
32
|
-
- `
|
33
|
-
- `
|
34
|
-
- `
|
35
|
-
- `
|
29
|
+
- [`AttrEncrypted`](#AttrEncrypted)
|
30
|
+
- [`Duplicate`](#Duplicate)
|
31
|
+
- [`GetColumnValue`](#GetColumnValue)
|
32
|
+
- [`MoneyAccessors`](#MoneyAccessors)
|
33
|
+
- [`StoreAccessors`](#StoreAccessors)
|
34
|
+
- [`Synchronize`](#Synchronize)
|
35
|
+
- [`Upsert`](#Upsert)
|
36
|
+
- [`WithLock`](#WithLock)
|
36
37
|
|
37
38
|
# Tools
|
38
|
-
- `TimestampMigratorUndoExtension`
|
39
|
+
- [`TimestampMigratorUndoExtension`](#TimestampMigratorUndoExtension)
|
39
40
|
|
40
41
|
## CurrencyRates
|
41
42
|
|
@@ -203,6 +204,39 @@ end
|
|
203
204
|
# => <Husband @attributes={id:1, wife_id: 1}>
|
204
205
|
```
|
205
206
|
|
207
|
+
## AttrEncrypted
|
208
|
+
|
209
|
+
Enable: `Sequel::Model.plugin :attr_encrypted`
|
210
|
+
|
211
|
+
Plugin for storing encrypted model attributes.
|
212
|
+
|
213
|
+
Example:
|
214
|
+
|
215
|
+
```ruby
|
216
|
+
Sequel.migration do
|
217
|
+
change do
|
218
|
+
alter_table :orders do
|
219
|
+
add_column :encrypted_first_name, :text
|
220
|
+
add_column :encrypted_last_name, :text
|
221
|
+
add_column :encrypted_secret_data, :text
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
class Order < Sequel::Model
|
227
|
+
attr_encrypted :first_name, :last_name, key: Settings.private_key
|
228
|
+
attr_encrypted :secret_data, key: Settings.another_private_key
|
229
|
+
end
|
230
|
+
|
231
|
+
Order.create(first_name: "Ivan")
|
232
|
+
# => INSERT INTO "orders" ("encrypted_first_name") VALUES ('/sTi9Q==$OTpuMRq5k8R3JayQ$WjSManQGP9UaZ3C40yDjKg==')
|
233
|
+
|
234
|
+
order = Order.create(first_name: "Ivan", last_name: "Smith",
|
235
|
+
secret_data: { "some_key" => "Some Value" })
|
236
|
+
order.first_name # => "Ivan"
|
237
|
+
order.secret_data # => { "some_key" => "Some Value" }
|
238
|
+
```
|
239
|
+
|
206
240
|
## Duplicate
|
207
241
|
|
208
242
|
Enable: `Sequel::Model.plugin :duplicate`
|
data/Rakefile
CHANGED
@@ -0,0 +1,98 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Creates encrypted attribute storing
|
4
|
+
module Sequel::Plugins::AttrEncrypted
|
5
|
+
SEPARATOR = "$"
|
6
|
+
require "sequel/plugins/attr_encrypted/simple_crypt"
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
# Setup attr encrypted
|
10
|
+
#
|
11
|
+
# @param attrs [Array<Symbol>] column names
|
12
|
+
# @param key [String] 32 bytes key
|
13
|
+
# @example
|
14
|
+
# Sequel.migration do
|
15
|
+
# change do
|
16
|
+
# alter_table :orders do
|
17
|
+
# add_column :encrypted_first_name, :text
|
18
|
+
# add_column :encrypted_last_name, :text
|
19
|
+
# add_column :encrypted_secret_data, :text
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# class Order < Sequel::Model
|
25
|
+
# attr_encrypted :first_name, :last_name, key: Settings.private_key
|
26
|
+
# attr_encrypted :secret_data, key: Settings.another_private_key
|
27
|
+
# end
|
28
|
+
|
29
|
+
# Order.create(first_name: "Ivan")
|
30
|
+
# # => INSERT INTO "orders" ("encrypted_first_name")
|
31
|
+
# VALUES ('/sTi9Q==$OTpuMRq5k8R3JayQ$WjSManQGP9UaZ3C40yDjKg==')
|
32
|
+
#
|
33
|
+
# order = Order.create(first_name: "Ivan", last_name: "Smith",
|
34
|
+
# secret_data: { "some_key" => "Some Value" })
|
35
|
+
# order.first_name # => "Ivan"
|
36
|
+
# order.last_name # => "Smith"
|
37
|
+
# order.secret_data # => { "some_key" => "Some Value" }
|
38
|
+
def attr_encrypted(*attrs, key:)
|
39
|
+
include_encrypted_module!
|
40
|
+
attrs.each do |attr|
|
41
|
+
define_encrypted_setter(attr, key)
|
42
|
+
define_encrypted_getter(attr, key)
|
43
|
+
@_encrypted_attributes << attr
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def define_encrypted_setter(attr, key)
|
50
|
+
@_attr_encrypted_module.module_eval do
|
51
|
+
define_method("#{attr}=") do |value|
|
52
|
+
instance_variable_set("@#{attr}", value)
|
53
|
+
|
54
|
+
send("encrypted_#{attr}=", SimpleCrypt.encrypt(value.to_json, key))
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def define_encrypted_getter(attr, key)
|
60
|
+
@_attr_encrypted_module.module_eval do
|
61
|
+
define_method(attr.to_s) do
|
62
|
+
instance_variable_get("@#{attr}") || begin
|
63
|
+
decrypted = SimpleCrypt.decrypt(send("encrypted_#{attr}"), key)
|
64
|
+
|
65
|
+
result = decrypted.nil? ? decrypted : JSON.parse(decrypted)
|
66
|
+
instance_variable_set("@#{attr}", result)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def include_encrypted_module!
|
73
|
+
return if defined?(@_attr_encrypted_module)
|
74
|
+
|
75
|
+
@_encrypted_attributes ||= []
|
76
|
+
@_attr_encrypted_module = Module.new
|
77
|
+
prepend @_attr_encrypted_module
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
module InstanceMethods
|
82
|
+
def save(*)
|
83
|
+
super.tap { _reset_encrypted_attrs_ivars }
|
84
|
+
end
|
85
|
+
|
86
|
+
def refresh(*)
|
87
|
+
super.tap { _reset_encrypted_attrs_ivars }
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def _reset_encrypted_attrs_ivars
|
93
|
+
self.class.instance_variable_get(:@_encrypted_attributes)&.each do |attr|
|
94
|
+
instance_variable_set("@#{attr}", nil)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sequel::Plugins::AttrEncrypted::SimpleCrypt
|
4
|
+
extend self
|
5
|
+
require "base64"
|
6
|
+
|
7
|
+
SEPARATOR = "$"
|
8
|
+
|
9
|
+
def encrypt(string, key)
|
10
|
+
return unless string.is_a?(String) && !string.empty?
|
11
|
+
|
12
|
+
encryptor = new_cipher(key, &:encrypt)
|
13
|
+
iv = encryptor.random_iv
|
14
|
+
|
15
|
+
encrypted = encryptor.update(string) + encryptor.final
|
16
|
+
dump(encrypted, iv, encryptor.auth_tag)
|
17
|
+
end
|
18
|
+
|
19
|
+
def decrypt(string, key)
|
20
|
+
encrypted, iv, auth_tag = parse(string) if string.is_a?(String)
|
21
|
+
return if [encrypted, iv, auth_tag].any?(&:nil?)
|
22
|
+
|
23
|
+
decryptor = new_cipher(key, &:decrypt)
|
24
|
+
decryptor.iv = iv
|
25
|
+
decryptor.auth_tag = auth_tag
|
26
|
+
|
27
|
+
decryptor.update(encrypted) + decryptor.final
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def new_cipher(key)
|
33
|
+
result = OpenSSL::Cipher.new("aes-256-gcm")
|
34
|
+
yield(result)
|
35
|
+
result.key = key
|
36
|
+
result
|
37
|
+
end
|
38
|
+
|
39
|
+
def parse(string)
|
40
|
+
string.split(SEPARATOR).map { |x| Base64.strict_decode64(x) }
|
41
|
+
end
|
42
|
+
|
43
|
+
def dump(*values)
|
44
|
+
Array(values).map { |x| Base64.strict_encode64(x) }.join(SEPARATOR)
|
45
|
+
end
|
46
|
+
end
|
@@ -8,10 +8,10 @@ module Sequel
|
|
8
8
|
# Rollback a migration
|
9
9
|
def undo(version)
|
10
10
|
path = files.find { |file| migration_version_from_file(get_filename(file)) == version }
|
11
|
-
|
11
|
+
error!("Migration #{version} does not exist in the filesystem") unless path
|
12
12
|
|
13
13
|
filename = get_filename(path)
|
14
|
-
|
14
|
+
error!("Migration #{version} is not applied") unless applied_migrations.include?(filename)
|
15
15
|
|
16
16
|
migration = get_migration(path)
|
17
17
|
|
@@ -41,7 +41,7 @@ module Sequel
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
Sequel::TimestampMigrator.prepend
|
44
|
+
Sequel::TimestampMigrator.prepend(TimestampMigratorLogger)
|
45
45
|
|
46
46
|
private
|
47
47
|
|
@@ -57,6 +57,10 @@ module Sequel
|
|
57
57
|
def get_filename(path)
|
58
58
|
File.basename(path).downcase
|
59
59
|
end
|
60
|
+
|
61
|
+
def error!(message)
|
62
|
+
raise Sequel::Migrator::Error, message
|
63
|
+
end
|
60
64
|
end
|
61
65
|
end
|
62
66
|
# rubocop:enable Layout/ClassStructure
|
@@ -4,11 +4,11 @@ lib = File.expand_path("lib", __dir__)
|
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
gem_version = "0.
|
8
|
-
release_version =
|
7
|
+
gem_version = "0.5.0"
|
8
|
+
release_version = "#{gem_version}.#{ENV["GITHUB_RUN_NUMBER"]}" if ENV["GITHUB_ACTIONS"]
|
9
9
|
|
10
10
|
spec.name = "umbrellio-sequel-plugins"
|
11
|
-
spec.version = release_version
|
11
|
+
spec.version = gem_version || release_version
|
12
12
|
spec.required_ruby_version = ">= 2.4"
|
13
13
|
|
14
14
|
spec.authors = ["nulldef"]
|
@@ -16,16 +16,15 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.homepage = "https://github.com/umbrellio/umbrellio-sequel-plugins"
|
17
17
|
spec.licenses = ["MIT"]
|
18
18
|
spec.summary = "Sequel plugins"
|
19
|
-
spec.description = "
|
19
|
+
spec.description = "A colletion of sequel plugins by Umbrellio"
|
20
20
|
|
21
21
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
24
|
spec.add_runtime_dependency "sequel"
|
25
|
-
spec.add_runtime_dependency "symbiont-ruby"
|
25
|
+
spec.add_runtime_dependency "symbiont-ruby"
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler"
|
28
|
-
spec.add_development_dependency "coveralls", ">= 0.8"
|
29
28
|
spec.add_development_dependency "money"
|
30
29
|
spec.add_development_dependency "pg"
|
31
30
|
spec.add_development_dependency "pry"
|
@@ -33,4 +32,5 @@ Gem::Specification.new do |spec|
|
|
33
32
|
spec.add_development_dependency "rspec"
|
34
33
|
spec.add_development_dependency "rubocop-config-umbrellio"
|
35
34
|
spec.add_development_dependency "simplecov"
|
35
|
+
spec.add_development_dependency "simplecov-lcov"
|
36
36
|
end
|
data/utils/database.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: umbrellio-sequel-plugins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nulldef
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,21 +53,21 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: money
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: pg
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: pry
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: rubocop-config-umbrellio
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
@@ -137,7 +137,7 @@ dependencies:
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
140
|
+
name: simplecov
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - ">="
|
@@ -151,7 +151,7 @@ dependencies:
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
|
-
name: simplecov
|
154
|
+
name: simplecov-lcov
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - ">="
|
@@ -164,7 +164,7 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
-
description:
|
167
|
+
description: A colletion of sequel plugins by Umbrellio
|
168
168
|
email:
|
169
169
|
- nulldefiner@gmail.com
|
170
170
|
- oss@umbrellio.biz
|
@@ -172,6 +172,7 @@ executables: []
|
|
172
172
|
extensions: []
|
173
173
|
extra_rdoc_files: []
|
174
174
|
files:
|
175
|
+
- ".github/workflows/ci.yml"
|
175
176
|
- ".gitignore"
|
176
177
|
- ".rspec"
|
177
178
|
- ".rubocop.yml"
|
@@ -190,6 +191,8 @@ files:
|
|
190
191
|
- lib/sequel/extensions/pg_tools.rb
|
191
192
|
- lib/sequel/extensions/slave.rb
|
192
193
|
- lib/sequel/extensions/synchronize.rb
|
194
|
+
- lib/sequel/plugins/attr_encrypted.rb
|
195
|
+
- lib/sequel/plugins/attr_encrypted/simple_crypt.rb
|
193
196
|
- lib/sequel/plugins/duplicate.rb
|
194
197
|
- lib/sequel/plugins/get_column_value.rb
|
195
198
|
- lib/sequel/plugins/money_accessors.rb
|
@@ -209,7 +212,7 @@ homepage: https://github.com/umbrellio/umbrellio-sequel-plugins
|
|
209
212
|
licenses:
|
210
213
|
- MIT
|
211
214
|
metadata: {}
|
212
|
-
post_install_message:
|
215
|
+
post_install_message:
|
213
216
|
rdoc_options: []
|
214
217
|
require_paths:
|
215
218
|
- lib
|
@@ -224,9 +227,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
227
|
- !ruby/object:Gem::Version
|
225
228
|
version: '0'
|
226
229
|
requirements: []
|
227
|
-
|
228
|
-
|
229
|
-
signing_key:
|
230
|
+
rubygems_version: 3.1.2
|
231
|
+
signing_key:
|
230
232
|
specification_version: 4
|
231
233
|
summary: Sequel plugins
|
232
234
|
test_files: []
|