postspec 0.2.5 → 0.3.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 +4 -4
- data/lib/postspec/config.rb +6 -3
- data/lib/postspec/render.rb +2 -2
- data/lib/postspec/version.rb +1 -1
- data/lib/postspec.rb +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba916d9dadf392677f5d57fa0ddbdfab2458a122c4c6c286a1be996602db70c8
|
4
|
+
data.tar.gz: cff38fe2468820458869459422acd2a40f066c5e2f7a070c0c9b481e13c9612d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02a5ccb6c9451c24d1ad2f4b7c8cc5a1fd46b9aecbe1acfbf3ccd3eb47cd59b0be707fa522cbe88d86299e1312c6a7a3f03aaaa7f69506aed8aef82f5be0eb37
|
7
|
+
data.tar.gz: 5a0c49a71f4a9b007de038e49f490639cfc16b3a120596185059b0e4ad823cb744054848130f99ddfe5946ed58d4352454503f992d1b900a0066c3f86d02169a
|
data/lib/postspec/config.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Used to initialize postspec from spec/spec_helper.rb or spec/postspec_helper.rb
|
2
2
|
#
|
3
3
|
module Postspec
|
4
|
-
Config = Struct.new(:database, :mode, :reflections, :anchors, :fail_fast, :ignore)
|
4
|
+
Config = Struct.new(:database, :mode, :reflections, :anchors, :fail_fast, :ignore, :cache)
|
5
5
|
|
6
6
|
@database = nil
|
7
7
|
@mode = nil
|
@@ -9,6 +9,7 @@ module Postspec
|
|
9
9
|
@anchors = nil
|
10
10
|
@fail_fast = nil
|
11
11
|
@ignore = nil
|
12
|
+
@cache = nil
|
12
13
|
|
13
14
|
DEFAULT_MODE = :empty
|
14
15
|
DEFAULT_FAIL_FAST = true
|
@@ -20,9 +21,10 @@ module Postspec
|
|
20
21
|
def self.anchors() @anchors end
|
21
22
|
def self.fail_fast() @fail_fast end
|
22
23
|
def self.ignore() @ignore end
|
24
|
+
def self.cache() @cache end
|
23
25
|
|
24
26
|
def self.configure(&block)
|
25
|
-
config = Config.new(@database, DEFAULT_MODE, nil, nil, DEFAULT_FAIL_FAST, DEFAULT_IGNORE)
|
27
|
+
config = Config.new(@database, DEFAULT_MODE, nil, nil, DEFAULT_FAIL_FAST, DEFAULT_IGNORE, nil)
|
26
28
|
yield(config)
|
27
29
|
@database = config.database
|
28
30
|
@mode = config.mode || DEFAULT_MODE
|
@@ -30,6 +32,7 @@ module Postspec
|
|
30
32
|
@anchors = config.anchors
|
31
33
|
@fail_fast = config.fail_fast || DEFAULT_FAIL_FAST
|
32
34
|
@ignore = config.ignore || DEFAULT_IGNORE # FIXME: Why not rely on Config defaults?
|
35
|
+
@cache = config.cache
|
33
36
|
self
|
34
37
|
end
|
35
38
|
|
@@ -37,7 +40,7 @@ module Postspec
|
|
37
40
|
!@database.nil? or raise Error, "Database unspecified"
|
38
41
|
@postspec ||= Postspec.new(
|
39
42
|
PgConn.new(@database),
|
40
|
-
mode: mode, reflector: @reflections, anchors: @anchors, fail: @fail_fast, ignore: @ignore)
|
43
|
+
mode: mode, reflector: @reflections, anchors: @anchors, fail: @fail_fast, ignore: @ignore, cache: cache)
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
data/lib/postspec/render.rb
CHANGED
@@ -77,12 +77,12 @@ module Postspec
|
|
77
77
|
before update or delete on #{uid}
|
78
78
|
for each row
|
79
79
|
when (old.id <= #{id})
|
80
|
-
execute function
|
80
|
+
execute function postspec.readonly_failure('#{uid}')
|
81
81
|
EOS1
|
82
82
|
bt_sql = <<~EOS2
|
83
83
|
create trigger postspec_readonly_bt_trg
|
84
84
|
before truncate on #{uid}
|
85
|
-
execute function
|
85
|
+
execute function postspec.readonly_failure('#{uid}')
|
86
86
|
EOS2
|
87
87
|
[
|
88
88
|
bud_sql.chomp,
|
data/lib/postspec/version.rb
CHANGED
data/lib/postspec.rb
CHANGED
@@ -68,16 +68,17 @@ module Postspec
|
|
68
68
|
# TODO: PgMeta object
|
69
69
|
#
|
70
70
|
# +mode+ can be one of :seed, :empty (TODO :reseed, :keep)
|
71
|
-
def initialize(conn, reflector: nil, mode: :empty, anchors: [], fail: true, ignore: [])
|
71
|
+
def initialize(conn, reflector: nil, mode: :empty, anchors: [], fail: true, ignore: [], cache: nil)
|
72
72
|
constrain conn, PgConn
|
73
73
|
constrain reflector, NilClass, String, PgGraph::Reflector
|
74
74
|
constrain mode, lambda { |m| [:empty, :seed].include?(m) }
|
75
75
|
constrain anchors, [Hash], NilClass
|
76
76
|
constrain fail, TrueClass, FalseClass
|
77
77
|
constrain ignore, [String]
|
78
|
+
constrain cache, String, nil
|
78
79
|
|
79
80
|
@conn = conn
|
80
|
-
@meta = PgMeta.new(@conn)
|
81
|
+
@meta = cache ? PgMeta.cache(@conn, yaml: cache) : PgMeta.new(@conn)
|
81
82
|
|
82
83
|
# Make sure the postspec schema is not included in the type model. TODO:
|
83
84
|
# Consolidate this into the :ignore option of PgGraph::Type.new as is
|
@@ -85,7 +86,8 @@ module Postspec
|
|
85
86
|
has_postspec = @meta.schemas.key?("postspec")
|
86
87
|
!has_postspec or (@meta.schemas["postspec"].hidden = true)
|
87
88
|
|
88
|
-
@type = PgGraph::Type.new(@meta, reflector, ignore: ["prick"] + ignore)
|
89
|
+
@type = PgGraph::Type.new(@meta, reflector, ignore: ["prick"] + ignore)
|
90
|
+
|
89
91
|
@render = Render.new(self)
|
90
92
|
@tables = type.schemas.map(&:tables).flatten
|
91
93
|
@ignore = ignore
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-inflector
|