Sha256: 4d181db3e9f99cf8c4b47c45cf556be53f9e5081eb4aa32cf1fbec7920091a9c
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
require "pg" require "pg_conn" require_relative "pg_meta/ext/hash.rb" require_relative "pg_meta/version.rb" require_relative "pg_meta/meta.rb" require_relative "pg_meta/load_conn.rb" require_relative "pg_meta/load_yaml.rb" require_relative "pg_meta/dump.rb" module PgMeta class Error < StandardError; end # :call-seq: # initialize(pg_conn_connection) # initialize(*pg_conn_initializers) # # Initialize a Database object # def self.new(*args, exclude_schemas: []) Database.load_conn(PgConn.ensure(*args), exclude_schemas: exclude_schemas) end def self.cache(*args, yaml: nil, marshal: nil, **opts) yaml.nil? != marshal.nil? or raise ArgumentError, "Require either of :yaml or :marshal" file = yaml || marshal kind = yaml ? :yaml : :marshal if File.exist?(file) if yaml load_file(file) else load_marshal(file) end else db = self.new(*args, **opts) IO.write(file, db.to_yaml) end end # Load data from a YAML object def self.load_yaml(yaml) Database.load_yaml(yaml) end # Load data from a YAML file def self.load_file(file) exit load_yaml(YAML.load(IO.read file)) end def self.load_marshal(file) Marshal.load(IO.read file) end # Make the PgMeta module pretend to have PgMeta::Database object instances def self.===(element) element.is_a?(PgMeta::Database) or super end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pg_meta-0.2.6 | lib/pg_meta.rb |
pg_meta-0.2.5 | lib/pg_meta.rb |