arel_assist 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cb16acdda43ccffa5110592d8c5536c470fc3cf4426d235b61a3c01fb44992b3
4
+ data.tar.gz: afabe030ee58a4254065a840739bb7e2920ae4dee5fe785fd359b9083724b543
5
+ SHA512:
6
+ metadata.gz: d8f56d74bb15829e477bf78ed8de009c89a57d5faefb468289f38cf485a02ac775de466fae7dd908a1e260b170b232fdd4090cc4794a9751860615c3b9b6ad08
7
+ data.tar.gz: 0a43832a802ea628e9ab244ca789868f14307610fcda14877115ba55956db6ab8befe4ed1863d5eee0f7304ebda4610eec38ffc77480e7d34e31779261930e9f
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
3
+ ruby_version: 2.6
data/Appraisals ADDED
@@ -0,0 +1,11 @@
1
+ appraise "rails-6.0.x" do
2
+ gem "activerecord", "~> 6.0.0"
3
+ end
4
+
5
+ appraise "rails-6.1.x" do
6
+ gem "activerecord", "~> 6.1.0"
7
+ end
8
+
9
+ appraise "rails-7.0.x" do
10
+ gem "activerecord", "~> 7.0.0"
11
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-09-30
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at eric@berry.sh. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in arel_assist.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+ gem "minitest", "~> 5.0"
10
+ gem "standard", "~> 1.3"
data/Gemfile.lock ADDED
@@ -0,0 +1,196 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ arel_assist (0.1.0)
5
+ activerecord (>= 6, < 8)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (7.0.4)
11
+ actionview (= 7.0.4)
12
+ activesupport (= 7.0.4)
13
+ rack (~> 2.0, >= 2.2.0)
14
+ rack-test (>= 0.6.3)
15
+ rails-dom-testing (~> 2.0)
16
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
17
+ actionview (7.0.4)
18
+ activesupport (= 7.0.4)
19
+ builder (~> 3.1)
20
+ erubi (~> 1.4)
21
+ rails-dom-testing (~> 2.0)
22
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
23
+ activemodel (7.0.4)
24
+ activesupport (= 7.0.4)
25
+ activerecord (7.0.4)
26
+ activemodel (= 7.0.4)
27
+ activesupport (= 7.0.4)
28
+ activesupport (7.0.4)
29
+ concurrent-ruby (~> 1.0, >= 1.0.2)
30
+ i18n (>= 1.6, < 2)
31
+ minitest (>= 5.1)
32
+ tzinfo (~> 2.0)
33
+ anbt-sql-formatter (0.1.0)
34
+ appraisal (2.4.1)
35
+ bundler
36
+ rake
37
+ thor (>= 0.14.0)
38
+ ast (2.4.2)
39
+ builder (3.2.4)
40
+ bump (0.10.0)
41
+ byebug (11.1.3)
42
+ codecov (0.6.0)
43
+ simplecov (>= 0.15, < 0.22)
44
+ coderay (1.1.3)
45
+ colorize (0.8.1)
46
+ combustion (1.3.7)
47
+ activesupport (>= 3.0.0)
48
+ railties (>= 3.0.0)
49
+ thor (>= 0.14.6)
50
+ commander (4.6.0)
51
+ highline (~> 2.0.0)
52
+ concurrent-ruby (1.1.10)
53
+ crass (1.0.6)
54
+ database_cleaner (2.0.1)
55
+ database_cleaner-active_record (~> 2.0.0)
56
+ database_cleaner-active_record (2.0.1)
57
+ activerecord (>= 5.a)
58
+ database_cleaner-core (~> 2.0.0)
59
+ database_cleaner-core (2.0.1)
60
+ diff-lcs (1.5.0)
61
+ docile (1.4.0)
62
+ erubi (1.11.0)
63
+ highline (2.0.3)
64
+ i18n (1.12.0)
65
+ concurrent-ruby (~> 1.0)
66
+ json (2.6.2)
67
+ loofah (2.19.0)
68
+ crass (~> 1.0.2)
69
+ nokogiri (>= 1.5.9)
70
+ magic_frozen_string_literal (1.2.0)
71
+ method_source (1.0.0)
72
+ minitest (5.16.3)
73
+ nokogiri (1.13.8-arm64-darwin)
74
+ racc (~> 1.4)
75
+ nokogiri (1.13.8-x86_64-linux)
76
+ racc (~> 1.4)
77
+ parallel (1.22.1)
78
+ parlour (5.0.0)
79
+ commander (~> 4.5)
80
+ parser
81
+ rainbow (~> 3.0)
82
+ sorbet-runtime (>= 0.5)
83
+ parser (3.1.2.1)
84
+ ast (~> 2.4.1)
85
+ pry (0.14.1)
86
+ coderay (~> 1.1)
87
+ method_source (~> 1.0)
88
+ pry-byebug (3.10.1)
89
+ byebug (~> 11.0)
90
+ pry (>= 0.13, < 0.15)
91
+ racc (1.6.0)
92
+ rack (2.2.4)
93
+ rack-test (2.0.2)
94
+ rack (>= 1.3)
95
+ rails-dom-testing (2.0.3)
96
+ activesupport (>= 4.2.0)
97
+ nokogiri (>= 1.6)
98
+ rails-html-sanitizer (1.4.3)
99
+ loofah (~> 2.3)
100
+ railties (7.0.4)
101
+ actionpack (= 7.0.4)
102
+ activesupport (= 7.0.4)
103
+ method_source
104
+ rake (>= 12.2)
105
+ thor (~> 1.0)
106
+ zeitwerk (~> 2.5)
107
+ rainbow (3.1.1)
108
+ rake (13.0.6)
109
+ regexp_parser (2.6.0)
110
+ rexml (3.2.5)
111
+ rouge (4.0.0)
112
+ rspec (3.11.0)
113
+ rspec-core (~> 3.11.0)
114
+ rspec-expectations (~> 3.11.0)
115
+ rspec-mocks (~> 3.11.0)
116
+ rspec-core (3.11.0)
117
+ rspec-support (~> 3.11.0)
118
+ rspec-expectations (3.11.1)
119
+ diff-lcs (>= 1.2.0, < 2.0)
120
+ rspec-support (~> 3.11.0)
121
+ rspec-mocks (3.11.1)
122
+ diff-lcs (>= 1.2.0, < 2.0)
123
+ rspec-support (~> 3.11.0)
124
+ rspec-support (3.11.1)
125
+ rubocop (1.35.1)
126
+ json (~> 2.3)
127
+ parallel (~> 1.10)
128
+ parser (>= 3.1.2.1)
129
+ rainbow (>= 2.2.2, < 4.0)
130
+ regexp_parser (>= 1.8, < 3.0)
131
+ rexml (>= 3.2.5, < 4.0)
132
+ rubocop-ast (>= 1.20.1, < 2.0)
133
+ ruby-progressbar (~> 1.7)
134
+ unicode-display_width (>= 1.4.0, < 3.0)
135
+ rubocop-ast (1.21.0)
136
+ parser (>= 3.1.1.0)
137
+ rubocop-performance (1.14.3)
138
+ rubocop (>= 1.7.0, < 2.0)
139
+ rubocop-ast (>= 0.4.0)
140
+ ruby-progressbar (1.11.0)
141
+ simplecov (0.21.2)
142
+ docile (~> 1.1)
143
+ simplecov-html (~> 0.11)
144
+ simplecov_json_formatter (~> 0.1)
145
+ simplecov-html (0.12.3)
146
+ simplecov_json_formatter (0.1.4)
147
+ sorbet-runtime (0.5.10470)
148
+ sord (4.0.0)
149
+ commander (~> 4.5)
150
+ parlour (~> 5.0)
151
+ sorbet-runtime
152
+ yard
153
+ sqlite3 (1.5.1-arm64-darwin)
154
+ sqlite3 (1.5.1-x86_64-linux)
155
+ standard (1.16.1)
156
+ rubocop (= 1.35.1)
157
+ rubocop-performance (= 1.14.3)
158
+ thor (1.2.1)
159
+ tzinfo (2.0.5)
160
+ concurrent-ruby (~> 1.0)
161
+ unicode-display_width (2.3.0)
162
+ webrick (1.7.0)
163
+ whoop (1.0.2)
164
+ activerecord (>= 6.1.4)
165
+ activesupport (>= 6.1.4)
166
+ anbt-sql-formatter
167
+ colorize
168
+ rouge
169
+ yard (0.9.28)
170
+ webrick (~> 1.7.0)
171
+ zeitwerk (2.6.0)
172
+
173
+ PLATFORMS
174
+ arm64-darwin-21
175
+ x86_64-linux
176
+
177
+ DEPENDENCIES
178
+ appraisal
179
+ arel_assist!
180
+ bump
181
+ codecov
182
+ combustion
183
+ database_cleaner
184
+ magic_frozen_string_literal
185
+ minitest (~> 5.0)
186
+ pry-byebug
187
+ rake (~> 13.0)
188
+ rspec
189
+ simplecov
190
+ sord
191
+ sqlite3
192
+ standard (~> 1.3)
193
+ whoop
194
+
195
+ BUNDLED WITH
196
+ 2.3.22
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Eric Berry
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.
data/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # Arel Assist
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/arel_asssist.svg)](https://badge.fury.io/rb/arel_assist)
4
+ [![Contribute](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/coderberry/arel_assist)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/7f616d89b47b56f132cc/maintainability)](https://codeclimate.com/github/coderberry/arel_assist/maintainability)
6
+ [![Test Coverage](https://codecov.io/gh/coderberry/arel_assist/branch/main/graph/badge.svg?token=64VN84C475)](https://codecov.io/gh/coderberry/arel_assist)
7
+ [![Tests](https://github.com/coderberry/arel_assist/actions/workflows/tests.yml/badge.svg)](https://github.com/coderberry/arel_assist/actions/workflows/tests.yml)
8
+ [![CodeQL](https://github.com/coderberry/arel_assist/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/coderberry/arel_assist/actions/workflows/codeql-analysis.yml)
9
+ [![StandardRB](https://github.com/coderberry/arel_assist/actions/workflows/standardrb.yml/badge.svg)](https://github.com/coderberry/arel_assist/actions/workflows/standardrb.yml)
10
+ [![GEM Version](https://img.shields.io/gem/v/arel_assist?color=168AFE&include_prereleases&logo=ruby&logoColor=FE1616)](https://rubygems.org/gems/arel_assist)
11
+ [![GEM Downloads](https://img.shields.io/gem/dt/arel_assist?color=168AFE&logo=ruby&logoColor=FE1616)](https://rubygems.org/gems/arel_assist)
12
+ [![Ruby Style](https://img.shields.io/badge/style-standard-168AFE?logo=ruby&logoColor=FE1616)](https://github.com/testdouble/standard)
13
+ [![Twitter Follow](https://img.shields.io/twitter/follow/coderberry?logo=twitter&style=social)](https://twitter.com/coderberry)
14
+
15
+ Arel helper methods to assist in creating clean, sexy database queries using ActiveRecord and Arel.
16
+
17
+ ## Installation
18
+
19
+ Install the gem and add to the application's Gemfile by executing:
20
+
21
+ ```bash
22
+ $ bundle add arel_assist
23
+ ```
24
+
25
+ If bundler is not being used to manage dependencies, install the gem by executing:
26
+
27
+ ```bash
28
+ $ gem install arel_assist
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ```ruby
34
+ require "arel_assist"
35
+ ```
36
+
37
+ TODO: Coming soon
38
+
39
+ ## Requirements
40
+
41
+ Requires ActiveRecord >= 6, < 8
42
+
43
+ ## Development
44
+
45
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
46
+
47
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
48
+
49
+ ## Contributing
50
+
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/arel_assist. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/arel_assist/blob/main/CODE_OF_CONDUCT.md).
52
+
53
+ ## License
54
+
55
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
56
+
57
+ ## Code of Conduct
58
+
59
+ Everyone interacting in the ArelAssist project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/arel_assist/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ GEM_NAME = "arel_assist"
8
+ GEM_VERSION = ArelAssist::VERSION
9
+
10
+ require "standard/rake"
11
+ require "bump/tasks"
12
+
13
+ task default: %i[spec standard]
14
+
15
+ task :build do
16
+ system "gem build #{GEM_NAME}.gemspec"
17
+ end
18
+
19
+ task install: :build do
20
+ system "gem install #{GEM_NAME}-#{GEM_VERSION}.gem"
21
+ end
22
+
23
+ task publish: :build do
24
+ system "gem push #{GEM_NAME}-#{GEM_VERSION}.gem"
25
+ system "gem push --key github --host https://rubygems.pkg.github.com/coderberry #{GEM_NAME}-#{GEM_VERSION}.gem"
26
+ end
27
+
28
+ task :clean do
29
+ system "rm *.gem"
30
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/arel_assist/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "arel_assist"
7
+ spec.version = ArelAssist::VERSION
8
+ spec.authors = ["Eric Berry"]
9
+ spec.email = ["eric@berry.sh"]
10
+
11
+ spec.summary = "Helpers and shortcuts with Arel"
12
+ spec.description = spec.summary
13
+ spec.homepage = "https://github.com/coderberry/arel_assist"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+ spec.metadata["changelog_uri"] = spec.homepage
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject do |f|
25
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
26
+ end
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_dependency "activerecord", ">= 6", "< 8"
33
+
34
+ spec.add_development_dependency "appraisal"
35
+ spec.add_development_dependency "sqlite3"
36
+ spec.add_development_dependency "magic_frozen_string_literal"
37
+ spec.add_development_dependency "combustion"
38
+ spec.add_development_dependency "database_cleaner"
39
+ spec.add_development_dependency "pry-byebug"
40
+ spec.add_development_dependency "rspec"
41
+ spec.add_development_dependency "rake"
42
+ spec.add_development_dependency "standard"
43
+ spec.add_development_dependency "bump"
44
+ spec.add_development_dependency "sord"
45
+ spec.add_development_dependency "simplecov"
46
+ spec.add_development_dependency "codecov"
47
+ spec.add_development_dependency "whoop"
48
+ end
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_RETRY: "1"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 13.0"
6
+ gem "minitest", "~> 5.0"
7
+ gem "standard", "~> 1.3"
8
+ gem "activerecord", "~> 6.0.0"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 13.0"
6
+ gem "minitest", "~> 5.0"
7
+ gem "standard", "~> 1.3"
8
+ gem "activerecord", "~> 6.1.0"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake", "~> 13.0"
6
+ gem "minitest", "~> 5.0"
7
+ gem "standard", "~> 1.3"
8
+ gem "activerecord", "~> 7.0.0"
9
+
10
+ gemspec path: "../"
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ArelAssist
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "arel_assist/version"
4
+ require "active_record"
5
+
6
+ module ArelAssist
7
+ extend self
8
+
9
+ def self.included(base)
10
+ base.extend self
11
+ end
12
+
13
+ # Generates SQL: COUNT("<table-name>"."<column-name>")
14
+ #
15
+ # @example
16
+ # arel_count(Post.arel_table[:days_active])
17
+ # #=> 'COUNT("member_summaries"."days_active")'
18
+ #
19
+ # @param [Arel::Attributes::Attribute] field
20
+ # @return [Arel::Nodes::NamedFunction]
21
+ def arel_count(field)
22
+ Arel::Nodes::NamedFunction.new("COUNT", [field])
23
+ end
24
+
25
+ # Generates SQL: date_trunc('<date-part>', "<table-name>"."<column-name>")
26
+ #
27
+ # @example
28
+ # arel_date_trunc('day', MemberSummary.arel_table[:created_at])
29
+ # #=> "date_trunc('day', \"member_summaries\".\"created_at\")"
30
+ #
31
+ # @param [String,Symbol] date_part - one of the following: year, month, day, hour, minute, second, millisecond, microsecond
32
+ # @param [Arel::Attributes::Attribute] field
33
+ # @return [Arel::Nodes::NamedFunction]
34
+ def arel_date_trunc(date_part, field)
35
+ Arel::Nodes::NamedFunction.new("date_trunc", [sqlv(date_part), field])
36
+ end
37
+
38
+ # Generates SQL: MAX("<table-name>"."<column-name>")
39
+ #
40
+ # @example
41
+ # arel_max(Activity.arel_table[:occurred_at])
42
+ # #=> 'MAX("activities"."occurred_at")'
43
+ #
44
+ # @param [Arel::Attributes::Attribute] field
45
+ # @return [Arel::Nodes::NamedFunction]
46
+ def arel_max(field)
47
+ Arel::Nodes::NamedFunction.new("MAX", [field])
48
+ end
49
+
50
+ # Generates SQL: MIN("<table-name>"."<column-name>")
51
+ #
52
+ # @example
53
+ # arel_max(Activity.arel_table[:occurred_at])
54
+ # #=> 'MIN("activities"."occurred_at")'
55
+ #
56
+ # @example with 'AS'
57
+ # arel_max(Activity.arel_table[:occurred_at]).as("first_activity_occurred_at")
58
+ # #=> 'MIN("activities"."occurred_at") AS first_activity_occurred_at'
59
+ #
60
+ # @param [Arel::Attributes::Attribute] field
61
+ # @return [Arel::Nodes::NamedFunction]
62
+ def arel_min(field)
63
+ Arel::Nodes::NamedFunction.new("MIN", [field])
64
+ end
65
+
66
+ def sqlv(node)
67
+ case node
68
+ when ->(n) { n.respond_to?(:to_sql) }
69
+ node.to_sql
70
+ when Arel::Attributes::Attribute
71
+ Arel::Nodes::SqlLiteral.new("\"#{node.relation.name}\".\"#{node.name}\"")
72
+ when Array, Range
73
+ value = node.map { |x| x.is_a?(String) ? "'#{x}'" : x }.join(",")
74
+ Arel::Nodes::SqlLiteral.new "ARRAY[#{value}]"
75
+ when Time, DateTime, Date, String
76
+ Arel::Nodes.build_quoted node
77
+ else
78
+ Arel::Nodes::SqlLiteral.new node.to_s
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,128 @@
1
+ module ArelAssist
2
+ extend ArelAssist
3
+ VERSION: untyped
4
+
5
+ # sord omit - no YARD type given for "base", using untyped
6
+ # sord omit - no YARD return type given, using untyped
7
+ def self.included: (untyped base) -> untyped
8
+
9
+ # sord warn - Arel::Attributes::Attribute wasn't able to be resolved to a constant in this project
10
+ # sord warn - Arel::Nodes::NamedFunction wasn't able to be resolved to a constant in this project
11
+ # Generates SQL: COUNT("<table-name>"."<column-name>")
12
+ #
13
+ # _@param_ `field`
14
+ #
15
+ # ```ruby
16
+ # arel_count(Post.arel_table[:days_active])
17
+ # #=> 'COUNT("member_summaries"."days_active")'
18
+ # ```
19
+ def arel_count: (Arel::Attributes::Attribute field) -> Arel::Nodes::NamedFunction
20
+
21
+ # sord warn - Arel::Attributes::Attribute wasn't able to be resolved to a constant in this project
22
+ # sord warn - Arel::Nodes::NamedFunction wasn't able to be resolved to a constant in this project
23
+ # Generates SQL: date_trunc('<date-part>', "<table-name>"."<column-name>")
24
+ #
25
+ # _@param_ `date_part` — - one of the following: year, month, day, hour, minute, second, millisecond, microsecond
26
+ #
27
+ # _@param_ `field`
28
+ #
29
+ # ```ruby
30
+ # arel_date_trunc('day', MemberSummary.arel_table[:created_at])
31
+ # #=> "date_trunc('day', \"member_summaries\".\"created_at\")"
32
+ # ```
33
+ def arel_date_trunc: ((String | Symbol) date_part, Arel::Attributes::Attribute field) -> Arel::Nodes::NamedFunction
34
+
35
+ # sord warn - Arel::Attributes::Attribute wasn't able to be resolved to a constant in this project
36
+ # sord warn - Arel::Nodes::NamedFunction wasn't able to be resolved to a constant in this project
37
+ # Generates SQL: MAX("<table-name>"."<column-name>")
38
+ #
39
+ # _@param_ `field`
40
+ #
41
+ # ```ruby
42
+ # arel_max(Activity.arel_table[:occurred_at])
43
+ # #=> 'MAX("activities"."occurred_at")'
44
+ # ```
45
+ def arel_max: (Arel::Attributes::Attribute field) -> Arel::Nodes::NamedFunction
46
+
47
+ # sord warn - Arel::Attributes::Attribute wasn't able to be resolved to a constant in this project
48
+ # sord warn - Arel::Nodes::NamedFunction wasn't able to be resolved to a constant in this project
49
+ # Generates SQL: MIN("<table-name>"."<column-name>")
50
+ #
51
+ # _@param_ `field`
52
+ #
53
+ # ```ruby
54
+ # arel_max(Activity.arel_table[:occurred_at])
55
+ # #=> 'MIN("activities"."occurred_at")'
56
+ # ```
57
+ #
58
+ # with 'AS'
59
+ # ```ruby
60
+ # arel_max(Activity.arel_table[:occurred_at]).as("first_activity_occurred_at")
61
+ # #=> 'MIN("activities"."occurred_at") AS first_activity_occurred_at'
62
+ # ```
63
+ def arel_min: (Arel::Attributes::Attribute field) -> Arel::Nodes::NamedFunction
64
+
65
+ # sord omit - no YARD type given for "node", using untyped
66
+ # sord omit - no YARD return type given, using untyped
67
+ def sqlv: (untyped node) -> untyped
68
+
69
+ # sord warn - Arel::Attributes::Attribute wasn't able to be resolved to a constant in this project
70
+ # sord warn - Arel::Nodes::NamedFunction wasn't able to be resolved to a constant in this project
71
+ # Generates SQL: COUNT("<table-name>"."<column-name>")
72
+ #
73
+ # _@param_ `field`
74
+ #
75
+ # ```ruby
76
+ # arel_count(Post.arel_table[:days_active])
77
+ # #=> 'COUNT("member_summaries"."days_active")'
78
+ # ```
79
+ def self.arel_count: (Arel::Attributes::Attribute field) -> Arel::Nodes::NamedFunction
80
+
81
+ # sord warn - Arel::Attributes::Attribute wasn't able to be resolved to a constant in this project
82
+ # sord warn - Arel::Nodes::NamedFunction wasn't able to be resolved to a constant in this project
83
+ # Generates SQL: date_trunc('<date-part>', "<table-name>"."<column-name>")
84
+ #
85
+ # _@param_ `date_part` — - one of the following: year, month, day, hour, minute, second, millisecond, microsecond
86
+ #
87
+ # _@param_ `field`
88
+ #
89
+ # ```ruby
90
+ # arel_date_trunc('day', MemberSummary.arel_table[:created_at])
91
+ # #=> "date_trunc('day', \"member_summaries\".\"created_at\")"
92
+ # ```
93
+ def self.arel_date_trunc: ((String | Symbol) date_part, Arel::Attributes::Attribute field) -> Arel::Nodes::NamedFunction
94
+
95
+ # sord warn - Arel::Attributes::Attribute wasn't able to be resolved to a constant in this project
96
+ # sord warn - Arel::Nodes::NamedFunction wasn't able to be resolved to a constant in this project
97
+ # Generates SQL: MAX("<table-name>"."<column-name>")
98
+ #
99
+ # _@param_ `field`
100
+ #
101
+ # ```ruby
102
+ # arel_max(Activity.arel_table[:occurred_at])
103
+ # #=> 'MAX("activities"."occurred_at")'
104
+ # ```
105
+ def self.arel_max: (Arel::Attributes::Attribute field) -> Arel::Nodes::NamedFunction
106
+
107
+ # sord warn - Arel::Attributes::Attribute wasn't able to be resolved to a constant in this project
108
+ # sord warn - Arel::Nodes::NamedFunction wasn't able to be resolved to a constant in this project
109
+ # Generates SQL: MIN("<table-name>"."<column-name>")
110
+ #
111
+ # _@param_ `field`
112
+ #
113
+ # ```ruby
114
+ # arel_max(Activity.arel_table[:occurred_at])
115
+ # #=> 'MIN("activities"."occurred_at")'
116
+ # ```
117
+ #
118
+ # with 'AS'
119
+ # ```ruby
120
+ # arel_max(Activity.arel_table[:occurred_at]).as("first_activity_occurred_at")
121
+ # #=> 'MIN("activities"."occurred_at") AS first_activity_occurred_at'
122
+ # ```
123
+ def self.arel_min: (Arel::Attributes::Attribute field) -> Arel::Nodes::NamedFunction
124
+
125
+ # sord omit - no YARD type given for "node", using untyped
126
+ # sord omit - no YARD return type given, using untyped
127
+ def self.sqlv: (untyped node) -> untyped
128
+ end
metadata ADDED
@@ -0,0 +1,280 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: arel_assist
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Eric Berry
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-09-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activerecord
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '6'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '8'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '6'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '8'
33
+ - !ruby/object:Gem::Dependency
34
+ name: appraisal
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: sqlite3
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: magic_frozen_string_literal
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: combustion
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: database_cleaner
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: pry-byebug
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: rspec
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: rake
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ - !ruby/object:Gem::Dependency
146
+ name: standard
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ - !ruby/object:Gem::Dependency
160
+ name: bump
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ - !ruby/object:Gem::Dependency
174
+ name: sord
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ type: :development
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ - !ruby/object:Gem::Dependency
188
+ name: simplecov
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ type: :development
195
+ prerelease: false
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: '0'
201
+ - !ruby/object:Gem::Dependency
202
+ name: codecov
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
208
+ type: :development
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - ">="
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
215
+ - !ruby/object:Gem::Dependency
216
+ name: whoop
217
+ requirement: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - ">="
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ type: :development
223
+ prerelease: false
224
+ version_requirements: !ruby/object:Gem::Requirement
225
+ requirements:
226
+ - - ">="
227
+ - !ruby/object:Gem::Version
228
+ version: '0'
229
+ description: Helpers and shortcuts with Arel
230
+ email:
231
+ - eric@berry.sh
232
+ executables: []
233
+ extensions: []
234
+ extra_rdoc_files: []
235
+ files:
236
+ - ".rspec"
237
+ - ".standard.yml"
238
+ - Appraisals
239
+ - CHANGELOG.md
240
+ - CODE_OF_CONDUCT.md
241
+ - Gemfile
242
+ - Gemfile.lock
243
+ - LICENSE.txt
244
+ - README.md
245
+ - Rakefile
246
+ - arel_assist.gemspec
247
+ - gemfiles/.bundle/config
248
+ - gemfiles/rails_6.0.x.gemfile
249
+ - gemfiles/rails_6.1.x.gemfile
250
+ - gemfiles/rails_7.0.x.gemfile
251
+ - lib/arel_assist.rb
252
+ - lib/arel_assist/version.rb
253
+ - sig/arel_assist.rbs
254
+ homepage: https://github.com/coderberry/arel_assist
255
+ licenses:
256
+ - MIT
257
+ metadata:
258
+ homepage_uri: https://github.com/coderberry/arel_assist
259
+ source_code_uri: https://github.com/coderberry/arel_assist
260
+ changelog_uri: https://github.com/coderberry/arel_assist
261
+ post_install_message:
262
+ rdoc_options: []
263
+ require_paths:
264
+ - lib
265
+ required_ruby_version: !ruby/object:Gem::Requirement
266
+ requirements:
267
+ - - ">="
268
+ - !ruby/object:Gem::Version
269
+ version: 2.6.0
270
+ required_rubygems_version: !ruby/object:Gem::Requirement
271
+ requirements:
272
+ - - ">="
273
+ - !ruby/object:Gem::Version
274
+ version: '0'
275
+ requirements: []
276
+ rubygems_version: 3.3.7
277
+ signing_key:
278
+ specification_version: 4
279
+ summary: Helpers and shortcuts with Arel
280
+ test_files: []