gizzard 0.8.0 → 0.9.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: c8bb051ec47485a5252ebd7aa6b6d0f00a5fce77ccc985f3dba400ce3b4564b6
4
- data.tar.gz: 319d1ac24f2da5174c7ed75a141d1f34909afac0b0ea5b8d0aafb233315c54a3
3
+ metadata.gz: cb2568fde715eb73945c6b19987ea08b3e2c72f34a6e4b5c5ab6dc8758d3f228
4
+ data.tar.gz: 3522cc6db511d5038947be77b59f6cb91c001df133690455424297ac68bd2b6c
5
5
  SHA512:
6
- metadata.gz: 6af2539ed91ffc9aa2528d6b1d301ad41972a7fb969d5074b0e7f3368fdd8cd2148b2b25b875768d108eac7151b82c03660eea961bfc8219017e3e690ee7a3d1
7
- data.tar.gz: 69d5665693686af4f7a765f1e90142e4ba49d8bd39391381bfeed8501fa8cf455d3a7e7cfb6378044e48244f0617c65e92674bb725f98400bc8ccbe958c10ee1
6
+ metadata.gz: d33ca160e6cf2499cab2eb47d122eb9200c1d255531b76ada7dfd91f79966f3cc0709fbd877bf69ad38c68435294d63d16012ecd341d6888f30b8226fa65cf28
7
+ data.tar.gz: 55c1901b302755e81bc945337b9dec1f3d1ef92d3faeecd6f967fc679c9dbf30718ca10bd3772782ca03326b42e9823e84ecc576f5cab6d285426c91b5d27f56
data/README.md CHANGED
@@ -35,11 +35,9 @@ end
35
35
 
36
36
  ## Run Test
37
37
 
38
- ```
39
- $ bundle install
40
- $ docker-compose up -d
41
- $ ./scripts/setup.sh
42
- $ bundle exec rspec
38
+ ```bash
39
+ $ make setup
40
+ $ make ruby/rspec
43
41
  ```
44
42
 
45
43
  ## Development
data/lib/gizzard/mysql.rb CHANGED
@@ -7,7 +7,7 @@ module Gizzard
7
7
 
8
8
  scope :filtered_by, -> (column, value) do
9
9
  v = value.respond_to?(:strip) ? value.strip : value
10
- v.present? ? where(column => value) : all
10
+ v.present? ? where(column => v) : all
11
11
  end
12
12
 
13
13
  scope :forward_matching_by, -> (column, value) { where("`#{table_name}`.`#{column}` LIKE ?", "#{sanitize_sql_like(value)}%") }
@@ -64,7 +64,7 @@ module Gizzard
64
64
  when :left_outer_join
65
65
  'LEFT OUTER JOIN'
66
66
  else
67
- raise
67
+ raise "Invalid join_type = #{join_type}"
68
68
  end
69
69
 
70
70
  index_hint = case hint
@@ -73,7 +73,7 @@ module Gizzard
73
73
  when :force
74
74
  'FORCE INDEX'
75
75
  else
76
- raise
76
+ raise "Invalid hint = #{hint}"
77
77
  end
78
78
 
79
79
  c = connection
@@ -1,3 +1,3 @@
1
1
  module Gizzard
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.1"
3
3
  end
data/sig/gizzard.rbs ADDED
@@ -0,0 +1,45 @@
1
+ # TypeProf 0.21.8
2
+
3
+ # Classes
4
+ module Gizzard
5
+ VERSION: String
6
+
7
+ class Error < StandardError
8
+ end
9
+
10
+ module Base
11
+ extend ActiveSupport::Concern
12
+ extend ActiveRecord::Core::ClassMethods
13
+
14
+ module ClassMethods
15
+ def preload_associations: (records: untyped, associations: untyped, ?scope: nil) -> nil
16
+ def delete_all_by_id: (?batch_size: Integer) -> untyped
17
+ def less_than_id: (Integer id) -> ActiveRecord::Relation
18
+ def greater_than_id: (Integer id) -> ActiveRecord::Relation
19
+ def less_than: (String | Symbol key, untyped value) -> ActiveRecord::Relation
20
+ def less_than_equal: (String | Symbol key, untyped value) -> ActiveRecord::Relation
21
+ def greater_than: (String | Symbol key, untyped value) -> ActiveRecord::Relation
22
+ def greater_than_equal: (String | Symbol key, untyped value) -> ActiveRecord::Relation
23
+ end
24
+ end
25
+
26
+ module Mysql
27
+ include Base
28
+ extend Base::ClassMethods
29
+
30
+ module ClassMethods
31
+ def lock_in_share: -> ActiveRecord::Relation
32
+ def order_by_field: (String | Symbol column, [untyped] values) -> ActiveRecord::Relation
33
+ def order_by_id_field: ([untyped] ids) -> ActiveRecord::Relation
34
+ def use_index: (String | [String] indexes) -> ActiveRecord::Relation
35
+ def force_index: (String | [String] indexes) -> ActiveRecord::Relation
36
+ def joins_with_use_index: (String | Symbol relation_name, String | [String] indexes) -> ActiveRecord::Relation
37
+ def joins_with_force_index: (String | Symbol relation_name, String | [String] indexes) -> ActiveRecord::Relation
38
+ def left_outer_joins_with_use_index: (String | Symbol relation_name, String | [String] indexes) -> ActiveRecord::Relation
39
+ def left_outer_joins_with_force_index: (String | Symbol relation_name, String | [String] indexes) -> ActiveRecord::Relation
40
+ end
41
+
42
+ def to_id: -> Integer
43
+ def lock_in_share!: -> untyped
44
+ end
45
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gizzard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takahiro Ooishi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-01 00:00:00.000000000 Z
11
+ date: 2023-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -164,6 +164,34 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '3.0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: typeprof
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: steep
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
167
195
  description: Often use snippet for ActiveRecord.
168
196
  email:
169
197
  - taka0125@gmail.com
@@ -171,30 +199,13 @@ executables: []
171
199
  extensions: []
172
200
  extra_rdoc_files: []
173
201
  files:
174
- - ".github/workflows/main.yml"
175
- - ".github/workflows/release.yml"
176
- - ".gitignore"
177
- - ".rspec"
178
- - ".travis.yml"
179
- - Appraisals
180
- - Gemfile
181
202
  - LICENSE
182
203
  - README.md
183
- - Rakefile
184
- - bin/console
185
- - bin/setup
186
- - docker-compose.yml
187
- - gemfiles/.bundle/config
188
- - gemfiles/activerecord6.0.gemfile
189
- - gemfiles/activerecord6.1.gemfile
190
- - gemfiles/activerecord7.0.gemfile
191
- - gemfiles/activerecord7.1.gemfile
192
- - gizzard.gemspec
193
204
  - lib/gizzard.rb
194
205
  - lib/gizzard/base.rb
195
206
  - lib/gizzard/mysql.rb
196
207
  - lib/gizzard/version.rb
197
- - scripts/setup.sh
208
+ - sig/gizzard.rbs
198
209
  homepage: https://github.com/taka0125/gizzard
199
210
  licenses: []
200
211
  metadata: {}
@@ -213,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
224
  - !ruby/object:Gem::Version
214
225
  version: '0'
215
226
  requirements: []
216
- rubygems_version: 3.3.7
227
+ rubygems_version: 3.4.10
217
228
  signing_key:
218
229
  specification_version: 4
219
230
  summary: Often use snippet for ActiveRecord.
@@ -1,78 +0,0 @@
1
- name: Ruby
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- pull_request:
9
- branches:
10
- - main
11
-
12
- env:
13
- RAILS_ENV: test
14
- DB_PASSWORD: ${{ secrets.MYSQL_ROOT_PASSWORD }}
15
-
16
- jobs:
17
- test:
18
- runs-on: ubuntu-latest
19
- strategy:
20
- fail-fast: false
21
-
22
- matrix:
23
- ruby:
24
- - '3.0'
25
- - '3.1'
26
- activerecord:
27
- - '6.0'
28
- - '6.1'
29
- - '7.0'
30
- - '7.1'
31
- services:
32
- mysql:
33
- image: mysql:8
34
- ports:
35
- - 3306:3306
36
- env:
37
- MYSQL_ROOT_PASSWORD: ${{ secrets.MYSQL_ROOT_PASSWORD }}
38
- MYSQL_DATABASE: ${{ env.DB_NAME }}
39
- options: >-
40
- --health-cmd "mysqladmin ping"
41
- --health-interval 10s
42
- --health-timeout 5s
43
- --health-retries 5
44
-
45
- env:
46
- BUNDLE_GEMFILE: gemfiles/activerecord${{ matrix.activerecord }}.gemfile
47
- DB_HOST: 127.0.0.1
48
-
49
- steps:
50
- - uses: actions/checkout@v2
51
-
52
- - name: Set up Ruby
53
- uses: ruby/setup-ruby@v1
54
- with:
55
- ruby-version: ${{ matrix.ruby }}
56
- bundler-cache: true
57
- cache-version: 1
58
-
59
- - name: set MySQL sql_mode
60
- run: |
61
- mysql --ssl-mode=DISABLE --get-server-public-key --protocol=tcp --host 127.0.0.1 --user=root --password=${{ env.DB_PASSWORD }} mysql <<SQL
62
- SET GLOBAL sql_mode = 'NO_ENGINE_SUBSTITUTION';
63
- SET GLOBAL character_set_server = 'latin1';
64
- SET GLOBAL innodb_file_per_table = ON;
65
- SQL
66
-
67
- - name: set ENV
68
- run: |
69
- echo "DB_PORT=${{ job.services.mysql.ports[3306] }}" >> $GITHUB_ENV
70
-
71
- - name: Setup DB
72
- run: |
73
- ./scripts/setup.sh
74
- continue-on-error: ${{ matrix.allow_failures == 'true' }}
75
-
76
- - name: Run tests
77
- run: bundle exec rspec
78
- continue-on-error: ${{ matrix.allow_failures == 'true' }}
@@ -1,33 +0,0 @@
1
- name: Release gem
2
-
3
- on:
4
- workflow_dispatch:
5
- inputs:
6
- rubygems-otp-code:
7
- description: RubyGems OTP code
8
- required: true
9
-
10
- permissions:
11
- contents: write
12
-
13
- jobs:
14
- release-gem:
15
- runs-on: ubuntu-latest
16
- env:
17
- GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
18
- GEM_HOST_OTP_CODE: ${{ github.event.inputs.rubygems-otp-code }}
19
- steps:
20
- - uses: actions/checkout@v2
21
- with:
22
- fetch-depth: 0 # bundle exec rake release で git tag を見るため、tagをfetchするようにしている
23
- - uses: ruby/setup-ruby@v1
24
- with:
25
- ruby-version: 3.1.1
26
- - name: Bundle install
27
- run: bundle install
28
- - name: Setup git config # bundle exec rake release でgit tagが打たれていない場合、タグを打ってpushしてくれるため用意している
29
- run: |
30
- git config --global user.email "taka0125@gmail.com"
31
- git config --global user.name "Takahiro Ooishi"
32
- - name: Release gem
33
- run: bundle exec rake release
data/.gitignore DELETED
@@ -1,16 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
-
13
- vendor/
14
- Gemfile.lock
15
-
16
- gemfiles/*.gemfile.lock
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.3
7
- before_install: gem install bundler -v 2.0.1
data/Appraisals DELETED
@@ -1,21 +0,0 @@
1
- appraise 'activerecord5.2' do
2
- gem 'activerecord', '~> 5.2.0'
3
- end
4
-
5
- appraise 'activerecord6.0' do
6
- gem 'activerecord', '~> 6.0.0'
7
- end
8
-
9
- appraise 'activerecord6.1' do
10
- gem 'activerecord', '~> 6.1.0'
11
- end
12
-
13
- if RUBY_VERSION >= '2.7.0'
14
- appraise 'activerecord7.0' do
15
- gem 'activerecord', '~> 7.0.0'
16
- end
17
-
18
- appraise 'activerecord7.1' do
19
- gem 'activerecord', '~> 7.1.0'
20
- end
21
- end
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in gizzard.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "gizzard"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/docker-compose.yml DELETED
@@ -1,25 +0,0 @@
1
- version: '3.9'
2
-
3
- x-mysql: &mysql
4
- image: mysql:5.7
5
- container_name: gizzard_mysql57
6
- environment:
7
- MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-5y8m2jzTamDS6M85ateGrA6pihhyCm}
8
- platform: linux/x86_64
9
- ports:
10
- - 127.0.0.1:${DB_PORT:-33306}:3306
11
- volumes:
12
- - mysql:/var/lib/mysql
13
- command: >
14
- mysqld
15
- --sql-mode=NO_ENGINE_SUBSTITUTION
16
- --character-set-server=utf8mb4
17
- --innodb-file-per-table=1
18
- --innodb-large-prefix
19
-
20
- services:
21
- mysql:
22
- <<: *mysql
23
-
24
- volumes:
25
- mysql:
@@ -1,2 +0,0 @@
1
- ---
2
- BUNDLE_RETRY: "1"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 6.0.0"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 6.1.0"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 7.0.0"
6
-
7
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "activerecord", "~> 7.1.0"
6
-
7
- gemspec path: "../"
data/gizzard.gemspec DELETED
@@ -1,37 +0,0 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "gizzard/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "gizzard"
8
- spec.version = Gizzard::VERSION
9
- spec.authors = ["Takahiro Ooishi"]
10
- spec.email = ["taka0125@gmail.com"]
11
-
12
- spec.summary = %q{Often use snippet for ActiveRecord.}
13
- spec.description = %q{Often use snippet for ActiveRecord.}
14
- spec.homepage = "https://github.com/taka0125/gizzard"
15
-
16
- # Specify which files should be added to the gem when it is released.
17
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
- end
21
- spec.bindir = "exe"
22
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
- spec.require_paths = ["lib"]
24
-
25
- spec.add_dependency "activerecord", ">= 5.2"
26
- spec.add_dependency "activesupport", ">= 5.2"
27
-
28
- spec.add_development_dependency "ridgepole"
29
- spec.add_development_dependency "database_cleaner-active_record"
30
- spec.add_development_dependency "mysql2"
31
- spec.add_development_dependency "psych", "~> 3.1"
32
- spec.add_development_dependency "standalone_activerecord_boot_loader", ">= 0.3"
33
- spec.add_development_dependency "appraisal"
34
- spec.add_development_dependency "bundler"
35
- spec.add_development_dependency "rake", ">= 12.3.3"
36
- spec.add_development_dependency "rspec", "~> 3.0"
37
- end
data/scripts/setup.sh DELETED
@@ -1,25 +0,0 @@
1
- #!/bin/bash
2
- set -ex
3
-
4
- CURRENT=$(cd $(dirname $0);pwd)
5
- DOCKER_MYSQL_PORT=$(docker port gizzard_mysql57 3306 2>/dev/null | cut -f 2 -d ':')
6
- DOCKER_MYSQL_PORT=${DOCKER_MYSQL_PORT:-3306}
7
-
8
- export DB_HOST=${DB_HOST:-127.0.0.1}
9
- export DB_PORT=${DB_PORT:-${DOCKER_MYSQL_PORT}}
10
- export DB_NAME=${DB_NAME:-gizzard_test}
11
- export DB_USER=${DB_USER:-root}
12
- export DB_PASSWORD=${DB_PASSWORD:-5y8m2jzTamDS6M85ateGrA6pihhyCm}
13
-
14
- mysql \
15
- -u ${DB_USER} \
16
- -h ${DB_HOST} \
17
- -p${DB_PASSWORD} \
18
- --port ${DB_PORT} \
19
- -e "CREATE DATABASE IF NOT EXISTS ${DB_NAME}"
20
-
21
- bundle exec ridgepole \
22
- -c ${CURRENT}/../spec/dummy/config/database.yml \
23
- --apply \
24
- -f ${CURRENT}/../spec/dummy/db/Schemafile \
25
- -E test