db 0.5.0 → 0.8.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/db/adapters.rb +31 -0
- data/lib/db/client.rb +24 -25
- data/lib/db/context/{query.rb → session.rb} +32 -3
- data/lib/db/context/transaction.rb +7 -4
- data/lib/db/query.rb +135 -0
- data/lib/db/version.rb +1 -1
- metadata +9 -42
- data/.github/workflows/development.yml +0 -65
- data/.gitignore +0 -12
- data/.rspec +0 -3
- data/README.md +0 -35
- data/db.gemspec +0 -29
- data/gems.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cde27a0a6510347217c2823470f138bd5d35bac35292f0ff7a085ec5c37c26c
|
4
|
+
data.tar.gz: 4e597ecdbfb05092a2a5c7f3f57ea2816ac16e7cfd05f5b1ca92ffeabe298fc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 829dd25eeaf87078bfaee1f719040abae45fcd531cd00e68dc57e6abc6cad637fbd95e60bcd0305945f580eba893ea52c5a9f341dcca9e01b5f963b64256209c
|
7
|
+
data.tar.gz: 2a6726e95b389ad06810f0c14cd4abdb90997aa3bfe419aff8a284feff613c879b36d170f7392078e078719e831070419535258fd65a1b4e42c593a0015435a1
|
data/lib/db/adapters.rb
CHANGED
@@ -1,12 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
1
22
|
|
2
23
|
module DB
|
24
|
+
# A global map of registered adapters.
|
25
|
+
# e.g. `DB::Adapters.register(:mariadb, DB::MariaDB::Adapter)`
|
3
26
|
module Adapters
|
4
27
|
@adapters = {}
|
5
28
|
|
29
|
+
# Register the adapter class to the specified name.
|
30
|
+
# @parameter name [Symbol] The adapter name.
|
31
|
+
# @parameter adapter [Class] The adapter class.
|
6
32
|
def self.register(name, adapter)
|
7
33
|
@adapters[name] = adapter
|
8
34
|
end
|
9
35
|
|
36
|
+
# Enumerate all registered adapters.
|
37
|
+
# @yields {|name, adapter| ...} The adapters if a block is given.
|
38
|
+
# @parameter name [Symbol] The adapter name.
|
39
|
+
# @parameter adapter [Class] The adapter class
|
40
|
+
# @returns [Enumerator(Symbol, Class)] If no block is given.
|
10
41
|
def self.each(&block)
|
11
42
|
@adapters.each(&block)
|
12
43
|
end
|
data/lib/db/client.rb
CHANGED
@@ -24,56 +24,55 @@ require 'async/io'
|
|
24
24
|
require 'async/io/stream'
|
25
25
|
require 'async/pool/controller'
|
26
26
|
|
27
|
-
require_relative 'context/
|
27
|
+
require_relative 'context/session'
|
28
28
|
require_relative 'context/transaction'
|
29
29
|
|
30
30
|
module DB
|
31
|
+
# Binds a connection pool to the specified adapter.
|
31
32
|
class Client
|
33
|
+
# Initialize the client and internal connection pool using the specified adapter.
|
34
|
+
# @parameter adapter [Object] The adapter instance.
|
32
35
|
def initialize(adapter, **options)
|
33
36
|
@adapter = adapter
|
34
37
|
|
35
38
|
@pool = connect(**options)
|
36
39
|
end
|
37
40
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
# @return [client] if no block provided.
|
42
|
-
# @yield [client, task] yield the client in an async task.
|
43
|
-
def self.open(*arguments, &block)
|
44
|
-
client = self.new(*arguments)
|
45
|
-
|
46
|
-
return client unless block_given?
|
47
|
-
|
48
|
-
Async do |task|
|
49
|
-
begin
|
50
|
-
yield client, task
|
51
|
-
ensure
|
52
|
-
client.close
|
53
|
-
end
|
54
|
-
end.wait
|
55
|
-
end
|
41
|
+
# The adapter used for making connections.
|
42
|
+
# @attribute [Object]
|
43
|
+
attr :adapter
|
56
44
|
|
45
|
+
# Close all open connections in the connection pool.
|
57
46
|
def close
|
58
47
|
@pool.close
|
59
48
|
end
|
60
49
|
|
61
|
-
|
62
|
-
|
50
|
+
# Acquires a connection and sends the specified statement if given.
|
51
|
+
# @parameters statement [String | Nil] An optional statement to send.
|
52
|
+
# @yields {|session| ...} A connected session if a block is given. Implicitly closed.
|
53
|
+
# @parameter session [Context::Session]
|
54
|
+
# @returns [Context::Session] A connected session if no block is given.
|
55
|
+
def session(statement = nil, **options)
|
56
|
+
session = Context::Session.new(@pool, **options)
|
63
57
|
|
64
58
|
if statement
|
65
|
-
|
59
|
+
session.send_query(statement)
|
66
60
|
end
|
67
61
|
|
68
|
-
return
|
62
|
+
return session unless block_given?
|
69
63
|
|
70
64
|
begin
|
71
|
-
yield
|
65
|
+
yield session
|
72
66
|
ensure
|
73
|
-
|
67
|
+
session.close
|
74
68
|
end
|
75
69
|
end
|
76
70
|
|
71
|
+
# Acquires a connection and starts a transaction.
|
72
|
+
# @parameters statement [String | Nil] An optional statement to send. Defaults to `"BEGIN"`.
|
73
|
+
# @yields {|session| ...} A connected session if a block is given. Implicitly commits, or aborts the connnection if an exception is raised.
|
74
|
+
# @parameter session [Context::Transaction]
|
75
|
+
# @returns [Context::Transaction] A connected and started transaction if no block is given.
|
77
76
|
def transaction(statement = "BEGIN", **options)
|
78
77
|
transaction = Context::Transaction.new(@pool, **options)
|
79
78
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright,
|
4
|
-
# Copyright, 2018, by Huba Nagy.
|
3
|
+
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
5
4
|
#
|
6
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -21,16 +20,22 @@
|
|
21
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
21
|
# THE SOFTWARE.
|
23
22
|
|
23
|
+
require_relative '../query'
|
24
|
+
|
24
25
|
module DB
|
25
26
|
module Context
|
26
|
-
|
27
|
+
# A connected context for sending queries and reading results.
|
28
|
+
class Session
|
29
|
+
# Iniitalize the query context attached to the given connection pool.
|
27
30
|
def initialize(pool, **options)
|
28
31
|
@pool = pool
|
29
32
|
@connection = pool.acquire
|
30
33
|
end
|
31
34
|
|
35
|
+
# The underlying connection.
|
32
36
|
attr :connection
|
33
37
|
|
38
|
+
# Flush the connection and then return it to the connection pool.
|
34
39
|
def close
|
35
40
|
if @connection
|
36
41
|
self.flush
|
@@ -41,20 +46,43 @@ module DB
|
|
41
46
|
end
|
42
47
|
end
|
43
48
|
|
49
|
+
def clause(fragment = String.new)
|
50
|
+
Query.new(self, fragment)
|
51
|
+
end
|
52
|
+
|
53
|
+
def query(fragment = String.new, **parameters)
|
54
|
+
if parameters.empty?
|
55
|
+
Query.new(self, fragment)
|
56
|
+
else
|
57
|
+
Query.new(self).interpolate(fragment, **parameters)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Send a query to the server.
|
62
|
+
# @parameter statement [String] The SQL query to send.
|
44
63
|
def send_query(statement, **options)
|
64
|
+
# Console.logger.info(self, statement)
|
45
65
|
@connection.send_query(statement, **options)
|
46
66
|
end
|
47
67
|
|
68
|
+
# Read the next result. Sending a query usually generates 1 or more results.
|
69
|
+
# @returns [Enumerable] The resulting records.
|
48
70
|
def next_result
|
49
71
|
@connection.next_result
|
50
72
|
end
|
51
73
|
|
74
|
+
# Send a query to the server and read the next result.
|
75
|
+
# @returns [Enumerable] The resulting records.
|
52
76
|
def call(statement, **options)
|
77
|
+
# Console.logger.info(self, statement)
|
53
78
|
@connection.send_query(statement, **options)
|
54
79
|
|
55
80
|
return @connection.next_result
|
56
81
|
end
|
57
82
|
|
83
|
+
# Enumerate all results.
|
84
|
+
# @yields {|result ...} The results if a block is given.
|
85
|
+
# @parameter result [Enumerable]
|
58
86
|
def results
|
59
87
|
while result = self.next_result
|
60
88
|
yield result
|
@@ -63,6 +91,7 @@ module DB
|
|
63
91
|
return nil
|
64
92
|
end
|
65
93
|
|
94
|
+
# Flush all outstanding results.
|
66
95
|
def flush
|
67
96
|
until @connection.next_result.nil?
|
68
97
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright,
|
4
|
-
# Copyright, 2018, by Huba Nagy.
|
3
|
+
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
5
4
|
#
|
6
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -21,25 +20,29 @@
|
|
21
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
21
|
# THE SOFTWARE.
|
23
22
|
|
24
|
-
require_relative '
|
23
|
+
require_relative 'session'
|
25
24
|
|
26
25
|
module DB
|
27
26
|
module Context
|
28
|
-
class Transaction <
|
27
|
+
class Transaction < Session
|
28
|
+
# Commit the transaction and return the connection to the connection pool.
|
29
29
|
def commit
|
30
30
|
self.call("COMMIT")
|
31
31
|
self.close
|
32
32
|
end
|
33
33
|
|
34
|
+
# Abort the transaction and return the connection to the connection pool.
|
34
35
|
def abort
|
35
36
|
self.call("ROLLBACK")
|
36
37
|
self.close
|
37
38
|
end
|
38
39
|
|
40
|
+
# Mark a savepoint in the transaction.
|
39
41
|
def savepoint(name)
|
40
42
|
self.call("SAVEPOINT #{name}")
|
41
43
|
end
|
42
44
|
|
45
|
+
# Return back to a previously registered savepoint.
|
43
46
|
def rollback(name)
|
44
47
|
self.call("ROLLBACK #{name}")
|
45
48
|
end
|
data/lib/db/query.rb
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
module DB
|
24
|
+
# Represents one or more identifiers for databases, tables or columns.
|
25
|
+
class Identifier < Array
|
26
|
+
def self.coerce(name_or_identifier)
|
27
|
+
case name_or_identifier
|
28
|
+
when Identifier
|
29
|
+
name_or_identifier
|
30
|
+
when Array
|
31
|
+
self.new(name_or_identifier)
|
32
|
+
when Symbol
|
33
|
+
self[name_or_identifier]
|
34
|
+
else
|
35
|
+
self[name_or_identifier.to_sym]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def append_to(query)
|
40
|
+
query.identifier(self)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# A mutable query builder.
|
45
|
+
class Query
|
46
|
+
# Create a new query builder attached to the specified session.
|
47
|
+
# @parameter session [Context::Session] the connected session which is used for escaping arguments.
|
48
|
+
def initialize(session, buffer = String.new)
|
49
|
+
@session = session
|
50
|
+
@connection = session.connection
|
51
|
+
@buffer = +buffer
|
52
|
+
end
|
53
|
+
|
54
|
+
# Append a raw textual clause to the query buffer.
|
55
|
+
# @parameter value [String] A raw SQL string, e.g. `WHERE x > 10`.
|
56
|
+
# @returns [Query] The mutable query itself.
|
57
|
+
def clause(value)
|
58
|
+
@buffer << ' ' unless @buffer.end_with?(' ') || @buffer.empty?
|
59
|
+
|
60
|
+
@buffer << value
|
61
|
+
|
62
|
+
return self
|
63
|
+
end
|
64
|
+
|
65
|
+
# Append a literal value to the query buffer.
|
66
|
+
# Escapes the field according to the requirements of the underlying connection.
|
67
|
+
# @parameter value [Object] Any kind of object, passed to the underlying database connection for conversion to a string representation.
|
68
|
+
# @returns [Query] The mutable query itself.
|
69
|
+
def literal(value)
|
70
|
+
@buffer << ' ' unless @buffer.end_with?(' ')
|
71
|
+
|
72
|
+
@connection.append_literal(value, @buffer)
|
73
|
+
|
74
|
+
return self
|
75
|
+
end
|
76
|
+
|
77
|
+
# Append an identifier value to the query buffer.
|
78
|
+
# Escapes the field according to the requirements of the underlying connection.
|
79
|
+
# @parameter value [String | Symbol | DB::Identifier] Passed to the underlying database connection for conversion to a string representation.
|
80
|
+
# @returns [Query] The mutable query itself.
|
81
|
+
def identifier(value)
|
82
|
+
@buffer << ' ' unless @buffer.end_with?(' ')
|
83
|
+
|
84
|
+
@connection.append_identifier(value, @buffer)
|
85
|
+
|
86
|
+
return self
|
87
|
+
end
|
88
|
+
|
89
|
+
# Interpolate a query fragment with the specified parameters.
|
90
|
+
# The parameters are escaped before being appended.
|
91
|
+
#
|
92
|
+
# @parameter fragment [String] A fragment of SQL including placeholders, e.g. `WHERE x > %{column}`.
|
93
|
+
# @parameter parameters [Hash] The substitution parameters.
|
94
|
+
# @returns [Query] The mutable query itself.
|
95
|
+
def interpolate(fragment, **parameters)
|
96
|
+
parameters.transform_values! do |value|
|
97
|
+
case value
|
98
|
+
when Symbol, Identifier
|
99
|
+
@connection.append_identifier(value)
|
100
|
+
else
|
101
|
+
@connection.append_literal(value)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
@buffer << sprintf(fragment, parameters)
|
106
|
+
|
107
|
+
return self
|
108
|
+
end
|
109
|
+
|
110
|
+
def key_column(*arguments, **options)
|
111
|
+
@buffer << @connection.key_column(*arguments, **options)
|
112
|
+
|
113
|
+
return self
|
114
|
+
end
|
115
|
+
|
116
|
+
# Send the query to the remote server to be executed. See {Context::Session#send_query} for more details.
|
117
|
+
def send
|
118
|
+
@session.send_query(@buffer)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Send the query to the remote server to be executed. See {Context::Session#call} for more details.
|
122
|
+
# @returns [Enumerable] The resulting records.
|
123
|
+
def call
|
124
|
+
@session.call(@buffer)
|
125
|
+
end
|
126
|
+
|
127
|
+
def to_s
|
128
|
+
@buffer
|
129
|
+
end
|
130
|
+
|
131
|
+
def inspect
|
132
|
+
"\#<#{self.class} #{@buffer.inspect}>"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
data/lib/db/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async-io
|
@@ -39,21 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: bake-bundler
|
42
|
+
name: bundler
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - ">="
|
@@ -80,20 +66,6 @@ dependencies:
|
|
80
66
|
- - ">="
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: bundler
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '2.0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '2.0'
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
70
|
name: rspec
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,25 +82,20 @@ dependencies:
|
|
110
82
|
version: '3.0'
|
111
83
|
description:
|
112
84
|
email:
|
113
|
-
- samuel.williams@oriontransfer.co.nz
|
114
85
|
executables: []
|
115
86
|
extensions: []
|
116
87
|
extra_rdoc_files: []
|
117
88
|
files:
|
118
|
-
- ".github/workflows/development.yml"
|
119
|
-
- ".gitignore"
|
120
|
-
- ".rspec"
|
121
|
-
- README.md
|
122
|
-
- db.gemspec
|
123
|
-
- gems.rb
|
124
89
|
- lib/db.rb
|
125
90
|
- lib/db/adapters.rb
|
126
91
|
- lib/db/client.rb
|
127
|
-
- lib/db/context/
|
92
|
+
- lib/db/context/session.rb
|
128
93
|
- lib/db/context/transaction.rb
|
94
|
+
- lib/db/query.rb
|
129
95
|
- lib/db/version.rb
|
130
96
|
homepage: https://github.com/socketry/db
|
131
|
-
licenses:
|
97
|
+
licenses:
|
98
|
+
- MIT
|
132
99
|
metadata: {}
|
133
100
|
post_install_message:
|
134
101
|
rdoc_options: []
|
@@ -138,14 +105,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
138
105
|
requirements:
|
139
106
|
- - ">="
|
140
107
|
- !ruby/object:Gem::Version
|
141
|
-
version: '
|
108
|
+
version: '2.5'
|
142
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
110
|
requirements:
|
144
111
|
- - ">="
|
145
112
|
- !ruby/object:Gem::Version
|
146
113
|
version: '0'
|
147
114
|
requirements: []
|
148
|
-
rubygems_version: 3.
|
115
|
+
rubygems_version: 3.2.3
|
149
116
|
signing_key:
|
150
117
|
specification_version: 4
|
151
118
|
summary: A low level database access gem.
|
@@ -1,65 +0,0 @@
|
|
1
|
-
name: Development
|
2
|
-
|
3
|
-
on: [push, pull_request]
|
4
|
-
|
5
|
-
jobs:
|
6
|
-
test:
|
7
|
-
runs-on: ${{matrix.os}}-latest
|
8
|
-
continue-on-error: ${{matrix.experimental}}
|
9
|
-
|
10
|
-
strategy:
|
11
|
-
matrix:
|
12
|
-
os:
|
13
|
-
- ubuntu
|
14
|
-
|
15
|
-
ruby:
|
16
|
-
- 2.5
|
17
|
-
- 2.6
|
18
|
-
- 2.7
|
19
|
-
|
20
|
-
experimental: [false]
|
21
|
-
env: [""]
|
22
|
-
|
23
|
-
include:
|
24
|
-
- os: ubuntu
|
25
|
-
ruby: truffleruby
|
26
|
-
experimental: true
|
27
|
-
- os: ubuntu
|
28
|
-
ruby: jruby
|
29
|
-
experimental: true
|
30
|
-
env: JRUBY_OPTS="--debug -X+O"
|
31
|
-
- os: ubuntu
|
32
|
-
ruby: head
|
33
|
-
experimental: true
|
34
|
-
|
35
|
-
steps:
|
36
|
-
- uses: actions/checkout@v2
|
37
|
-
- uses: ruby/setup-ruby@v1
|
38
|
-
with:
|
39
|
-
ruby-version: ${{matrix.ruby}}
|
40
|
-
|
41
|
-
- name: Install dependencies
|
42
|
-
run: ${{matrix.env}} bundle install
|
43
|
-
|
44
|
-
- name: Preparing Postgres (ubuntu)
|
45
|
-
if: matrix.os == 'ubuntu'
|
46
|
-
run: |
|
47
|
-
sudo apt-get install postgresql postgresql-contrib
|
48
|
-
echo "local all all trust" | sudo tee -a /var/lib/postgresql/12/main/pg_hba.conf
|
49
|
-
sudo systemctl restart postgresql
|
50
|
-
sudo -u postgres createuser -s -d $(id -un)
|
51
|
-
sudo -u postgres createdb test
|
52
|
-
|
53
|
-
- name: Preparing MariaDB (ubuntu)
|
54
|
-
if: matrix.os == 'ubuntu'
|
55
|
-
run: |
|
56
|
-
sudo apt-get install libmariadb-dev
|
57
|
-
sudo systemctl start mysql
|
58
|
-
mysql -uroot -proot -e "STATUS"
|
59
|
-
mysql -uroot -proot -e "CREATE USER '$(id -un)'@'localhost'; GRANT ALL ON *.* TO '$(id -un)'@'localhost'; FLUSH PRIVILEGES; CREATE DATABASE test;"
|
60
|
-
|
61
|
-
- name: Run tests
|
62
|
-
timeout-minutes: 5
|
63
|
-
run: |
|
64
|
-
export MYSQL_UNIX_PORT=/var/run/mysqld/mysqld.sock
|
65
|
-
${{matrix.env}} bundle exec rspec
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/README.md
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# Db
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/db`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'db'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install db
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/db.
|
data/db.gemspec
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative "lib/db/version"
|
3
|
-
|
4
|
-
Gem::Specification.new do |spec|
|
5
|
-
spec.name = "db"
|
6
|
-
spec.version = DB::VERSION
|
7
|
-
spec.authors = ["Samuel Williams"]
|
8
|
-
spec.email = ["samuel.williams@oriontransfer.co.nz"]
|
9
|
-
|
10
|
-
spec.summary = "A low level database access gem."
|
11
|
-
spec.homepage = "https://github.com/socketry/db"
|
12
|
-
|
13
|
-
spec.files = Dir.chdir(__dir__) do
|
14
|
-
`git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/})}
|
15
|
-
end
|
16
|
-
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.require_paths = ["lib"]
|
19
|
-
|
20
|
-
spec.add_dependency "async-io"
|
21
|
-
spec.add_dependency "async-pool"
|
22
|
-
|
23
|
-
spec.add_development_dependency "bake"
|
24
|
-
spec.add_development_dependency "bake-bundler"
|
25
|
-
|
26
|
-
spec.add_development_dependency "covered"
|
27
|
-
spec.add_development_dependency "bundler", "~> 2.0"
|
28
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
-
end
|
data/gems.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in db.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
group :adapters do
|
7
|
-
gem "db-postgres"#, path: "../db-postgres"
|
8
|
-
gem "db-mariadb"#, path: "../db-mariadb"
|
9
|
-
end
|
10
|
-
|
11
|
-
group :benchmark do
|
12
|
-
gem "benchmark-ips"
|
13
|
-
gem "mysql2"
|
14
|
-
gem "pg"
|
15
|
-
end
|