sql_runner 0.4.0 → 1.0.0
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/.github/workflows/test.yml +81 -0
- data/.rubocop.yml +5 -1
- data/CODE_OF_CONDUCT.md +12 -12
- data/README.md +3 -5
- data/lib/sql_runner/adapters/active_record.rb +1 -1
- data/lib/sql_runner/adapters/mysql.rb +1 -1
- data/lib/sql_runner/adapters/postgresql.rb +1 -1
- data/lib/sql_runner/adapters/sqlite.rb +1 -1
- data/lib/sql_runner/connection.rb +3 -3
- data/lib/sql_runner/query.rb +8 -1
- data/lib/sql_runner/version.rb +1 -1
- data/sql_runner.gemspec +2 -3
- metadata +9 -23
- data/.travis.yml +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d872ea15c372e83cf53ea750d274c5bae439323ed8ae27ca8bc74e9bdeef55c
|
4
|
+
data.tar.gz: a2ebaf2d1deddc6c34df6cd0b9fe38e161c790df31fac212254f10907beeddfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8c737e3faca0c83d76d2bf89a58a6cc2d72c5054ddd9f8a3b576b27a8f1fafd0d574276b6bd13a1b37684e001d78d0036e3373ff1070a5ca0f45703edab3f2e
|
7
|
+
data.tar.gz: bed77acf3c52539623139da8af8dfc55ce2637b757f979ddf6bdeb6aa0a47f256cde28e782261bb0df5f4e83212b3433c47ca8bc8b9b6571e88210bbd2097d7e
|
@@ -0,0 +1,81 @@
|
|
1
|
+
---
|
2
|
+
name: ruby-tests
|
3
|
+
|
4
|
+
on:
|
5
|
+
pull_request_target:
|
6
|
+
push:
|
7
|
+
branches:
|
8
|
+
- main
|
9
|
+
workflow_dispatch:
|
10
|
+
inputs: {}
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
build:
|
14
|
+
name: Tests with Ruby ${{ matrix.ruby }} and ${{ matrix.gemfile }}
|
15
|
+
runs-on: "ubuntu-latest"
|
16
|
+
if: |
|
17
|
+
github.actor == 'dependabot[bot]' && github.event_name == 'pull_request_target' ||
|
18
|
+
github.actor != 'dependabot[bot]'
|
19
|
+
strategy:
|
20
|
+
fail-fast: false
|
21
|
+
matrix:
|
22
|
+
ruby: ["3.2", "3.3"]
|
23
|
+
gemfile:
|
24
|
+
- Gemfile
|
25
|
+
|
26
|
+
services:
|
27
|
+
postgres:
|
28
|
+
image: postgres
|
29
|
+
env:
|
30
|
+
POSTGRES_DB: test
|
31
|
+
POSTGRES_HOST_AUTH_METHOD: trust
|
32
|
+
options: >-
|
33
|
+
--health-cmd pg_isready --health-interval 10s --health-timeout 5s
|
34
|
+
--health-retries 5
|
35
|
+
ports:
|
36
|
+
- 5432:5432
|
37
|
+
mysql:
|
38
|
+
image: mysql:8.0
|
39
|
+
env:
|
40
|
+
MYSQL_ROOT_PASSWORD: test
|
41
|
+
MYSQL_PASSWORD: test
|
42
|
+
MYSQL_DATABASE: test
|
43
|
+
MYSQL_USER: test
|
44
|
+
ports:
|
45
|
+
- 3306:3306
|
46
|
+
options:
|
47
|
+
--health-cmd="mysqladmin ping" --health-interval=10s
|
48
|
+
--health-timeout=5s --health-retries=3
|
49
|
+
|
50
|
+
steps:
|
51
|
+
- uses: actions/checkout@v3
|
52
|
+
|
53
|
+
- uses: actions/cache@v3
|
54
|
+
with:
|
55
|
+
path: vendor/bundle
|
56
|
+
key: >
|
57
|
+
${{ runner.os }}-${{ matrix.ruby }}-gems-${{
|
58
|
+
hashFiles(matrix.gemfile) }}
|
59
|
+
|
60
|
+
- name: Set up Ruby
|
61
|
+
uses: ruby/setup-ruby@v1
|
62
|
+
with:
|
63
|
+
ruby-version: ${{ matrix.ruby }}
|
64
|
+
|
65
|
+
- name: Install gem dependencies
|
66
|
+
env:
|
67
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
68
|
+
run: |
|
69
|
+
gem install bundler
|
70
|
+
bundle config path vendor/bundle
|
71
|
+
bundle update --jobs 4 --retry 3
|
72
|
+
|
73
|
+
- name: Run Tests
|
74
|
+
env:
|
75
|
+
PGHOST: localhost
|
76
|
+
PGUSER: postgres
|
77
|
+
PG_DATABASE_URL: "postgres://127.0.0.1/test?application_name=sql_runner"
|
78
|
+
MYSQL_DATABASE_URL: "mysql2://test:test@127.0.0.1/test?application_name=sql_runner"
|
79
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
80
|
+
run: |
|
81
|
+
bundle exec rake
|
data/.rubocop.yml
CHANGED
@@ -3,7 +3,8 @@ inherit_gem:
|
|
3
3
|
rubocop-fnando: .rubocop.yml
|
4
4
|
|
5
5
|
AllCops:
|
6
|
-
|
6
|
+
NewCops: enable
|
7
|
+
TargetRubyVersion: 3.2
|
7
8
|
|
8
9
|
Metrics/MethodLength:
|
9
10
|
Enabled: false
|
@@ -14,3 +15,6 @@ Metrics/AbcSize:
|
|
14
15
|
Style/OpenStructUse:
|
15
16
|
Exclude:
|
16
17
|
- test/**/*.rb
|
18
|
+
|
19
|
+
Minitest/UnspecifiedException:
|
20
|
+
Enabled: false
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -12,19 +12,19 @@ body size, race, ethnicity, age, religion, or nationality.
|
|
12
12
|
|
13
13
|
Examples of unacceptable behavior by participants include:
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
- The use of sexualized language or imagery
|
16
|
+
- Personal attacks
|
17
|
+
- Trolling or insulting/derogatory comments
|
18
|
+
- Public or private harassment
|
19
|
+
- Publishing other's private information, such as physical or electronic
|
20
20
|
addresses, without explicit permission
|
21
|
-
|
21
|
+
- Other unethical or unprofessional conduct
|
22
22
|
|
23
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or reject
|
24
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
25
|
+
not aligned to this Code of Conduct, or to ban temporarily or permanently any
|
26
|
+
contributor for other behaviors that they deem inappropriate, threatening,
|
27
|
+
offensive, or harmful.
|
28
28
|
|
29
29
|
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
30
|
fairly and consistently applying these principles to every aspect of managing
|
@@ -46,4 +46,4 @@ version 1.3.0, available at
|
|
46
46
|
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
47
|
|
48
48
|
[homepage]: http://contributor-covenant.org
|
49
|
-
[version]: http://contributor-covenant.org/version/1/3/0/
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# SQLRunner
|
2
2
|
|
3
|
-
[](https://codeclimate.com/github/fnando/sql_runner)
|
5
|
-
[](https://codeclimate.com/github/fnando/sql_runner/coverage)
|
3
|
+
[](https://github.com/fnando/sql_runner/actions/workflows/test.yml)
|
6
4
|
[](https://rubygems.org/gems/sql_runner)
|
7
5
|
[](https://rubygems.org/gems/sql_runner)
|
8
6
|
|
@@ -48,7 +46,7 @@ Run SQL files:
|
|
48
46
|
SQLRunner.root_dir = "#{__dir__}/sql"
|
49
47
|
|
50
48
|
class GetMembers < SQLRunner::Query
|
51
|
-
# by default will use root_dir/get_members.sql
|
49
|
+
# by default will use root_dir/get_members.{sql,psql}
|
52
50
|
end
|
53
51
|
```
|
54
52
|
|
@@ -72,7 +70,7 @@ Specify other options:
|
|
72
70
|
|
73
71
|
```ruby
|
74
72
|
class GetMembers < SQLRunner::Query
|
75
|
-
query_name "users" #=> will load root_dir/users.sql
|
73
|
+
query_name "users" #=> will load root_dir/users.{psql,sql}
|
76
74
|
root_dir "/some/path"
|
77
75
|
end
|
78
76
|
```
|
@@ -42,7 +42,7 @@ module SQLRunner
|
|
42
42
|
class ConnectionPool
|
43
43
|
def with
|
44
44
|
::ActiveRecord::Base.connection_pool.with_connection do |connection|
|
45
|
-
connection = connection.
|
45
|
+
connection = connection.raw_connection
|
46
46
|
|
47
47
|
adapter = case connection.class.name
|
48
48
|
when "PG::Connection"
|
@@ -9,12 +9,12 @@ module SQLRunner
|
|
9
9
|
adapter.create_connection_pool(
|
10
10
|
timeout: SQLRunner.timeout,
|
11
11
|
size: SQLRunner.pool,
|
12
|
-
connection_string:
|
12
|
+
connection_string:
|
13
13
|
)
|
14
14
|
end
|
15
15
|
|
16
|
-
def with_connection(&
|
17
|
-
connection_pool.with(&
|
16
|
+
def with_connection(&)
|
17
|
+
connection_pool.with(&)
|
18
18
|
end
|
19
19
|
|
20
20
|
def connect(connection_string)
|
data/lib/sql_runner/query.rb
CHANGED
@@ -37,7 +37,14 @@ module SQLRunner
|
|
37
37
|
|
38
38
|
def self.query(*value)
|
39
39
|
@query = value.first if value.any?
|
40
|
-
@query || (@query = File.read(
|
40
|
+
@query || (@query = File.read(find_query_file))
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.find_query_file
|
44
|
+
[
|
45
|
+
File.join(root_dir, "#{query_name}.psql"),
|
46
|
+
File.join(root_dir, "#{query_name}.sql")
|
47
|
+
].find {|file| File.file?(file) }
|
41
48
|
end
|
42
49
|
|
43
50
|
def self.connection_pool
|
data/lib/sql_runner/version.rb
CHANGED
data/sql_runner.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.version = SQLRunner::VERSION
|
8
8
|
spec.authors = ["Nando Vieira"]
|
9
9
|
spec.email = ["me@fnando.com"]
|
10
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
10
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.2.0")
|
11
11
|
spec.metadata = {"rubygems_mfa_required" => "true"}
|
12
12
|
|
13
13
|
spec.summary = <<~TEXT.tr("\n", " ")
|
@@ -34,10 +34,9 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency "mocha"
|
35
35
|
spec.add_development_dependency "mysql2"
|
36
36
|
spec.add_development_dependency "pg"
|
37
|
-
spec.add_development_dependency "pry-meta"
|
38
37
|
spec.add_development_dependency "rake"
|
39
38
|
spec.add_development_dependency "rubocop"
|
40
39
|
spec.add_development_dependency "rubocop-fnando"
|
41
40
|
spec.add_development_dependency "simplecov"
|
42
|
-
spec.add_development_dependency "sqlite3"
|
41
|
+
spec.add_development_dependency "sqlite3", "~> 1.7"
|
43
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sql_runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: connection_pool
|
@@ -108,20 +108,6 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: pry-meta
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: rake
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,16 +168,16 @@ dependencies:
|
|
182
168
|
name: sqlite3
|
183
169
|
requirement: !ruby/object:Gem::Requirement
|
184
170
|
requirements:
|
185
|
-
- - "
|
171
|
+
- - "~>"
|
186
172
|
- !ruby/object:Gem::Version
|
187
|
-
version: '
|
173
|
+
version: '1.7'
|
188
174
|
type: :development
|
189
175
|
prerelease: false
|
190
176
|
version_requirements: !ruby/object:Gem::Requirement
|
191
177
|
requirements:
|
192
|
-
- - "
|
178
|
+
- - "~>"
|
193
179
|
- !ruby/object:Gem::Version
|
194
|
-
version: '
|
180
|
+
version: '1.7'
|
195
181
|
description: SQLRunner allows you to load your queries out of SQL files, without using
|
196
182
|
ORMs.
|
197
183
|
email:
|
@@ -201,9 +187,9 @@ extensions: []
|
|
201
187
|
extra_rdoc_files: []
|
202
188
|
files:
|
203
189
|
- ".github/FUNDING.yml"
|
190
|
+
- ".github/workflows/test.yml"
|
204
191
|
- ".gitignore"
|
205
192
|
- ".rubocop.yml"
|
206
|
-
- ".travis.yml"
|
207
193
|
- CODE_OF_CONDUCT.md
|
208
194
|
- Gemfile
|
209
195
|
- LICENSE.txt
|
@@ -248,14 +234,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
248
234
|
requirements:
|
249
235
|
- - ">="
|
250
236
|
- !ruby/object:Gem::Version
|
251
|
-
version: 2.
|
237
|
+
version: 3.2.0
|
252
238
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
253
239
|
requirements:
|
254
240
|
- - ">="
|
255
241
|
- !ruby/object:Gem::Version
|
256
242
|
version: '0'
|
257
243
|
requirements: []
|
258
|
-
rubygems_version: 3.
|
244
|
+
rubygems_version: 3.5.9
|
259
245
|
signing_key:
|
260
246
|
specification_version: 4
|
261
247
|
summary: SQLRunner allows you to load your queries out of SQL files, without using
|
data/.travis.yml
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
---
|
2
|
-
language: ruby
|
3
|
-
cache: bundler
|
4
|
-
sudo: false
|
5
|
-
rvm:
|
6
|
-
- 2.7.0
|
7
|
-
services:
|
8
|
-
- mysql
|
9
|
-
addons:
|
10
|
-
postgresql: "10"
|
11
|
-
apt:
|
12
|
-
packages:
|
13
|
-
- postgresql-10
|
14
|
-
- postgresql-client-10
|
15
|
-
before_script:
|
16
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
17
|
-
- chmod +x ./cc-test-reporter
|
18
|
-
- "./cc-test-reporter before-build"
|
19
|
-
after_script:
|
20
|
-
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
21
|
-
before_install:
|
22
|
-
- gem install bundler
|
23
|
-
- createdb test
|
24
|
-
- mysql -e 'CREATE DATABASE IF NOT EXISTS test;'
|
25
|
-
notifications:
|
26
|
-
email: false
|
27
|
-
env:
|
28
|
-
global:
|
29
|
-
secure: 4dDrl8nCItKPRKpoA2KJVWsDm3o7U0pIsdY8t19pJXbziteT3zw5pEmFh+/qWGB1VszzFFZzXcZCIoKv3NX/x24g+LU+qvL7vLYLyhUR8ZjR4rGzGkwBCgEYBWgVtqg9ncYTbYsdbAqryt6f+HvpFj8EFvGSjIWVqJyh59qHdwAVT+BUKjllEH+t5Dbjd2knIQw83af+0A5ljP2uMziNcuHD7MUBIKY1DfFnBYQ5YA50o/mZe8sG5h6bZU/sf0pdoa+z2xDIJOPO7qaCwANACetDtsfs1DN39DsubvlFLg0s2z0XCuYyWSsJQ4zhRipHgnqYn+Rmpql17t0WmhVPA1xvLyk0/4X8rjRcYyYHMM3ryga5bnrpvSiPsqG+JFNhDczpN394KGa7o+/jCuNA0MVFcCzsvW2AMkYpUbPtADY7/Tl4iUJWmFbl0nO1n1wh5dDJ7Wo7mdkPAmdV7hNmMUmHbPeh8mSjMnuS2gcMc11wDgmR56TEMu/B7LUM31og7L+JouEJAOWtzThtpdYLpqDQ3Xe1G5uMl1oZ0lNOqag5Bg+AQCAIGr1N4G2m8fI74M9lUQUfhu87L+zycYMHInOH+Czc+RamlkH3vLl9Fu6aOKoXA0+zh85sVDj3Er+X2NEHaoRe4PSkOHOBNYSkAUd36TYMt8J5MgAD0w7HqmY=
|