pg_meta 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pg_meta/version.rb +1 -1
- data/lib/pg_meta.rb +19 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58339598c12ed8e286ecdd941ab1497947e5de3001c1dd1434888c05056551ba
|
4
|
+
data.tar.gz: e4b3bcf44fe2286760fd83841f8e42d5ca98a09cf08a8f3406f78a1d76c25671
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6918852294bd4207e93dc1730a64e6b4036db0807c2158de808da264de7200a34e08c8f40b7b59a07fbc454e098fdd9a9fbc436a2dd8bf5972e51a8aa7d8beb
|
7
|
+
data.tar.gz: 7c7c1166566190064ef0f45c24c2eee1b5a23fb89272963951203e915fd0a23cc8be5fc37c7499920684d754e0ee543e897bd20961667b31ab0536c9b651ce3a
|
data/lib/pg_meta/version.rb
CHANGED
data/lib/pg_meta.rb
CHANGED
@@ -23,6 +23,10 @@ module PgMeta
|
|
23
23
|
Database.load_conn(PgConn.ensure(*args), exclude_schemas: exclude_schemas)
|
24
24
|
end
|
25
25
|
|
26
|
+
# Read PgMeta object from cache file and return it. If the file is not
|
27
|
+
# present, a new PgMeta object is created and written to the file. The file
|
28
|
+
# can be either a yaml (:yaml option) or a Ruby marshal file (:marshall
|
29
|
+
# option)
|
26
30
|
def self.cache(*args, yaml: nil, marshal: nil, **opts)
|
27
31
|
yaml.nil? != marshal.nil? or raise ArgumentError, "Require either of :yaml or :marshal"
|
28
32
|
file = yaml || marshal
|
@@ -35,25 +39,36 @@ module PgMeta
|
|
35
39
|
end
|
36
40
|
else
|
37
41
|
db = self.new(*args, **opts)
|
38
|
-
|
42
|
+
case kind
|
43
|
+
when :yaml; save_file(db, file)
|
44
|
+
when :marshall; save_marshal(db, file)
|
45
|
+
end
|
46
|
+
db
|
39
47
|
end
|
40
48
|
end
|
41
49
|
|
42
|
-
# Load data from a YAML object
|
50
|
+
# Load data from a YAML hash object
|
43
51
|
def self.load_yaml(yaml)
|
44
52
|
Database.load_yaml(yaml)
|
45
53
|
end
|
46
54
|
|
47
55
|
# Load data from a YAML file
|
48
56
|
def self.load_file(file)
|
49
|
-
|
50
|
-
|
57
|
+
load_yaml(YAML.unsafe_load(IO.read file))
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.save_file(db, file)
|
61
|
+
IO.write(file, db.to_h.to_yaml)
|
51
62
|
end
|
52
63
|
|
53
64
|
def self.load_marshal(file)
|
54
65
|
Marshal.load(IO.read file)
|
55
66
|
end
|
56
67
|
|
68
|
+
def self.save_marshall(db, file)
|
69
|
+
IO.write(file, Marshal.dump(db))
|
70
|
+
end
|
71
|
+
|
57
72
|
# Make the PgMeta module pretend to have PgMeta::Database object instances
|
58
73
|
def self.===(element) element.is_a?(PgMeta::Database) or super end
|
59
74
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_meta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
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: indented_io
|
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
|
-
rubygems_version: 3.3.
|
170
|
+
rubygems_version: 3.3.7
|
171
171
|
signing_key:
|
172
172
|
specification_version: 4
|
173
173
|
summary: pg_meta gem
|