sql_runner 0.4.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8ae856dccc72baadf453eab3f66fc6b375757e81d042e309de58b80a3794c22
4
- data.tar.gz: bc6cdefb9735e36c972e0ae23fc062e746c6ca44f981444fb604fd9e3db388d5
3
+ metadata.gz: 3224a627fbfdb75b22aff61e35fce3def752d203da72e6cfc89a80c539cfd413
4
+ data.tar.gz: 0b6102814d498c2fbf53b1b642f3d03b639af95514d5d1d9854d579deb79aee4
5
5
  SHA512:
6
- metadata.gz: 1651fa64b28884dc534d878114bfab992f7d592b30c4b86cb518c24bfb63685795b61bb792db072ce07f7ea9495310b73196d5763b4250f3ea6d2fe7346efb3f
7
- data.tar.gz: b660ace92f4e0446c8f583505a4d2da82f4854b53cdce460202d83086dd968e5a2a89af8953c484a12dfa023e12dfaa4ac68c38bb9ddb4e78f3144e27bf703bf
6
+ metadata.gz: 6a622ef1f472136f5298a3fa4c37ba3b46f3265e7538c126ad2718e950db0e24fcfd65b49dad8eee47cf7fa699ca0623cc970cebbaabc89f327092ef5998b910
7
+ data.tar.gz: 126036d892682c63236f01dec9152fdf8cbc66e58846e04ca2e4767a408409e1f154cf57104d8cc59b78f03310f359293856e987d1271ab4efdbd72867f97dc1
@@ -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.0", "3.1", "3.2"]
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
- TargetRubyVersion: 2.6
6
+ NewCops: enable
7
+ TargetRubyVersion: 3.0
7
8
 
8
9
  Metrics/MethodLength:
9
10
  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
- * 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
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
- * Other unethical or unprofessional conduct
21
+ - Other unethical or unprofessional conduct
22
22
 
23
- Project maintainers have the right and responsibility to remove, edit, or
24
- reject comments, commits, code, wiki edits, issues, and other contributions
25
- that are not aligned to this Code of Conduct, or to ban temporarily or
26
- permanently any contributor for other behaviors that they deem inappropriate,
27
- threatening, offensive, or harmful.
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,5 @@
1
1
  # SQLRunner
2
2
 
3
- [![Travis-CI](https://travis-ci.org/fnando/sql_runner.svg)](https://travis-ci.org/fnando/sql_runner)
4
- [![Code Climate](https://codeclimate.com/github/fnando/sql_runner/badges/gpa.svg)](https://codeclimate.com/github/fnando/sql_runner)
5
- [![Test Coverage](https://codeclimate.com/github/fnando/sql_runner/badges/coverage.svg)](https://codeclimate.com/github/fnando/sql_runner/coverage)
6
3
  [![Gem](https://img.shields.io/gem/v/sql_runner.svg)](https://rubygems.org/gems/sql_runner)
7
4
  [![Gem](https://img.shields.io/gem/dt/sql_runner.svg)](https://rubygems.org/gems/sql_runner)
8
5
 
@@ -48,7 +45,7 @@ Run SQL files:
48
45
  SQLRunner.root_dir = "#{__dir__}/sql"
49
46
 
50
47
  class GetMembers < SQLRunner::Query
51
- # by default will use root_dir/get_members.sql
48
+ # by default will use root_dir/get_members.{sql,psql}
52
49
  end
53
50
  ```
54
51
 
@@ -72,7 +69,7 @@ Specify other options:
72
69
 
73
70
  ```ruby
74
71
  class GetMembers < SQLRunner::Query
75
- query_name "users" #=> will load root_dir/users.sql
72
+ query_name "users" #=> will load root_dir/users.{psql,sql}
76
73
  root_dir "/some/path"
77
74
  end
78
75
  ```
@@ -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(File.join(root_dir, "#{query_name}.sql")))
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SQLRunner
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.1"
5
5
  end
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.6.0")
10
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
11
11
  spec.metadata = {"rubygems_mfa_required" => "true"}
12
12
 
13
13
  spec.summary = <<~TEXT.tr("\n", " ")
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.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-28 00:00:00.000000000 Z
11
+ date: 2023-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: connection_pool
@@ -201,9 +201,9 @@ extensions: []
201
201
  extra_rdoc_files: []
202
202
  files:
203
203
  - ".github/FUNDING.yml"
204
+ - ".github/workflows/test.yml"
204
205
  - ".gitignore"
205
206
  - ".rubocop.yml"
206
- - ".travis.yml"
207
207
  - CODE_OF_CONDUCT.md
208
208
  - Gemfile
209
209
  - LICENSE.txt
@@ -248,14 +248,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
248
248
  requirements:
249
249
  - - ">="
250
250
  - !ruby/object:Gem::Version
251
- version: 2.6.0
251
+ version: 3.0.0
252
252
  required_rubygems_version: !ruby/object:Gem::Requirement
253
253
  requirements:
254
254
  - - ">="
255
255
  - !ruby/object:Gem::Version
256
256
  version: '0'
257
257
  requirements: []
258
- rubygems_version: 3.3.7
258
+ rubygems_version: 3.4.1
259
259
  signing_key:
260
260
  specification_version: 4
261
261
  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=