active_record_extended 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +15 -0
- data/.gitignore +18 -0
- data/.rspec +3 -0
- data/.rubocop.yml +85 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +35 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +92 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +102 -0
- data/active_record_extended.gemspec +32 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/gemfiles/activerecord-51.gemfile +8 -0
- data/gemfiles/activerecord-52+.gemfile +8 -0
- data/gemfiles/activerecord-52.gemfile +8 -0
- data/lib/active_record_extended/active_record.rb +15 -0
- data/lib/active_record_extended/arel/nodes.rb +61 -0
- data/lib/active_record_extended/arel/predications.rb +41 -0
- data/lib/active_record_extended/arel/visitors/postgresql_decorator.rb +73 -0
- data/lib/active_record_extended/arel.rb +6 -0
- data/lib/active_record_extended/patch/5_1/where_clause.rb +11 -0
- data/lib/active_record_extended/patch/5_2/where_clause.rb +11 -0
- data/lib/active_record_extended/predicate_builder/array_handler_decorator.rb +20 -0
- data/lib/active_record_extended/query_methods/either.rb +60 -0
- data/lib/active_record_extended/query_methods/where_chain.rb +106 -0
- data/lib/active_record_extended/version.rb +5 -0
- data/lib/active_record_extended.rb +9 -0
- data/spec/active_record_extended_spec.rb +7 -0
- data/spec/query_methods/array_query_spec.rb +64 -0
- data/spec/query_methods/either_spec.rb +36 -0
- data/spec/query_methods/hash_query_spec.rb +45 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/sql_inspections/arel/array_spec.rb +63 -0
- data/spec/sql_inspections/contains_sql_queries_spec.rb +47 -0
- data/spec/sql_inspections/either_sql_spec.rb +55 -0
- data/spec/support/database_cleaner.rb +15 -0
- data/spec/support/models.rb +20 -0
- metadata +203 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fd022475e7df8677d1211cfefe42f7090eca4a29fe54b96254f9490baaf101f0
|
4
|
+
data.tar.gz: ae8827a88842bcba66d440ed1ffa540349007e124516ad2d2d9e8f64d553f840
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5ff916a3e069accb63c3d98c1f46705ac2191de4c40a7b8f67415e0f752c420f6efd5c6601041b11bcc6cf7ae0bd776a4a2c22d2b89c2239bb9fb68c04ba40ed
|
7
|
+
data.tar.gz: 41b2f1e01aab68f69bc6753066c242475a3ecdd6f8fed68214065c5a55ecef5b9c8d261c6bf3f6d9264f9031775ef5d8571f43ca48561a36432c273672d11c9a
|
data/.codeclimate.yml
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.4
|
3
|
+
DisplayStyleGuide: true
|
4
|
+
DisplayCopNames: true
|
5
|
+
|
6
|
+
#################
|
7
|
+
# [i] Overrides #
|
8
|
+
#################
|
9
|
+
|
10
|
+
CollectionMethods:
|
11
|
+
# Mapping from undesired method to desired_method
|
12
|
+
# e.g. to use `detect` over `find`:
|
13
|
+
#
|
14
|
+
# CollectionMethods:
|
15
|
+
# PreferredMethods:
|
16
|
+
# find: detect
|
17
|
+
PreferredMethods:
|
18
|
+
reduce: 'inject'
|
19
|
+
find: 'detect'
|
20
|
+
each_with_index: 'each.with_index'
|
21
|
+
|
22
|
+
# Align ends correctly.
|
23
|
+
EndAlignment:
|
24
|
+
EnforcedStyleAlignWith: variable
|
25
|
+
|
26
|
+
LineLength:
|
27
|
+
Max: 120
|
28
|
+
Exclude:
|
29
|
+
- examples/**/*
|
30
|
+
|
31
|
+
BracesAroundHashParameters:
|
32
|
+
EnforcedStyle: context_dependent
|
33
|
+
|
34
|
+
StringLiterals:
|
35
|
+
EnforcedStyle: double_quotes
|
36
|
+
|
37
|
+
Metrics/AbcSize:
|
38
|
+
Max: 18
|
39
|
+
|
40
|
+
#################
|
41
|
+
# Disabled cops #
|
42
|
+
#################
|
43
|
+
Metrics/ClassLength:
|
44
|
+
Enabled: false
|
45
|
+
|
46
|
+
Metrics/CyclomaticComplexity:
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
Metrics/MethodLength:
|
50
|
+
Enabled: false
|
51
|
+
|
52
|
+
Metrics/BlockLength:
|
53
|
+
Exclude:
|
54
|
+
- spec/**/*
|
55
|
+
|
56
|
+
Style/ClassAndModuleChildren:
|
57
|
+
Enabled: false
|
58
|
+
|
59
|
+
Style/Documentation:
|
60
|
+
Enabled: false
|
61
|
+
|
62
|
+
Style/Lambda:
|
63
|
+
Enabled: false
|
64
|
+
|
65
|
+
Style/IfUnlessModifier:
|
66
|
+
Enabled: false
|
67
|
+
|
68
|
+
Style/TrailingCommaInArrayLiteral:
|
69
|
+
Enabled: true
|
70
|
+
EnforcedStyleForMultiline: comma
|
71
|
+
|
72
|
+
Style/TrailingCommaInHashLiteral:
|
73
|
+
Enabled: true
|
74
|
+
EnforcedStyleForMultiline: comma
|
75
|
+
|
76
|
+
Style/TrailingCommaInArguments:
|
77
|
+
Enabled: true
|
78
|
+
EnforcedStyleForMultiline: comma
|
79
|
+
|
80
|
+
Style/GuardClause:
|
81
|
+
Enabled: false
|
82
|
+
|
83
|
+
Lint/AmbiguousBlockAssociation:
|
84
|
+
Exclude:
|
85
|
+
- spec/**/*
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
active_record_extended
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.1
|
data/.travis.yml
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.3
|
5
|
+
- 2.4
|
6
|
+
- 2.5
|
7
|
+
- ruby-head
|
8
|
+
|
9
|
+
before_install: gem install bundler -v 1.16.1
|
10
|
+
|
11
|
+
branches:
|
12
|
+
only:
|
13
|
+
- master
|
14
|
+
gemfile:
|
15
|
+
- gemfiles/activerecord-51.gemfile
|
16
|
+
- gemfiles/activerecord-52.gemfile
|
17
|
+
- gemfiles/activerecord-52+.gemfile
|
18
|
+
|
19
|
+
matrix:
|
20
|
+
allow_failures:
|
21
|
+
- rvm: ruby-head
|
22
|
+
- gemfile: gemfiles/activerecord-52+.gemfile
|
23
|
+
|
24
|
+
|
25
|
+
env: DATABASE_URL=postgres://postgres@localhost/active_record_extended_test
|
26
|
+
|
27
|
+
before_script:
|
28
|
+
- psql -c 'create database active_record_extended_test;' -U postgres
|
29
|
+
- bundle exec rake db:migrate
|
30
|
+
|
31
|
+
cache:
|
32
|
+
- bundler
|
33
|
+
|
34
|
+
addons:
|
35
|
+
postgresql: '9.6'
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at georgekaraszi@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem "rubocop", "~> 0.52", require: false
|
9
|
+
|
10
|
+
gem "dotenv"
|
11
|
+
|
12
|
+
gem "byebug"
|
13
|
+
gem "pry", "~> 0.11.3"
|
14
|
+
gem "pry-byebug", "~> 3.5", ">= 3.5.1"
|
15
|
+
end
|
16
|
+
|
17
|
+
gemspec
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
active_record_extended (0.1.1)
|
5
|
+
activerecord (>= 5.1, < 6.0)
|
6
|
+
ar_outer_joins (~> 0.2)
|
7
|
+
pg (~> 0.18)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activemodel (5.2.0)
|
13
|
+
activesupport (= 5.2.0)
|
14
|
+
activerecord (5.2.0)
|
15
|
+
activemodel (= 5.2.0)
|
16
|
+
activesupport (= 5.2.0)
|
17
|
+
arel (>= 9.0)
|
18
|
+
activesupport (5.2.0)
|
19
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
|
+
i18n (>= 0.7, < 2)
|
21
|
+
minitest (~> 5.1)
|
22
|
+
tzinfo (~> 1.1)
|
23
|
+
ar_outer_joins (0.2.0)
|
24
|
+
activerecord (>= 3.2)
|
25
|
+
arel (9.0.0)
|
26
|
+
ast (2.4.0)
|
27
|
+
byebug (10.0.2)
|
28
|
+
coderay (1.1.2)
|
29
|
+
concurrent-ruby (1.0.5)
|
30
|
+
database_cleaner (1.7.0)
|
31
|
+
diff-lcs (1.3)
|
32
|
+
dotenv (2.2.2)
|
33
|
+
i18n (1.0.1)
|
34
|
+
concurrent-ruby (~> 1.0)
|
35
|
+
method_source (0.9.0)
|
36
|
+
minitest (5.11.3)
|
37
|
+
parallel (1.12.1)
|
38
|
+
parser (2.5.1.0)
|
39
|
+
ast (~> 2.4.0)
|
40
|
+
pg (0.21.0)
|
41
|
+
powerpack (0.1.1)
|
42
|
+
pry (0.11.3)
|
43
|
+
coderay (~> 1.1.0)
|
44
|
+
method_source (~> 0.9.0)
|
45
|
+
pry-byebug (3.6.0)
|
46
|
+
byebug (~> 10.0)
|
47
|
+
pry (~> 0.10)
|
48
|
+
rainbow (3.0.0)
|
49
|
+
rake (10.5.0)
|
50
|
+
rspec (3.7.0)
|
51
|
+
rspec-core (~> 3.7.0)
|
52
|
+
rspec-expectations (~> 3.7.0)
|
53
|
+
rspec-mocks (~> 3.7.0)
|
54
|
+
rspec-core (3.7.1)
|
55
|
+
rspec-support (~> 3.7.0)
|
56
|
+
rspec-expectations (3.7.0)
|
57
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
58
|
+
rspec-support (~> 3.7.0)
|
59
|
+
rspec-mocks (3.7.0)
|
60
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
61
|
+
rspec-support (~> 3.7.0)
|
62
|
+
rspec-support (3.7.1)
|
63
|
+
rubocop (0.55.0)
|
64
|
+
parallel (~> 1.10)
|
65
|
+
parser (>= 2.5)
|
66
|
+
powerpack (~> 0.1)
|
67
|
+
rainbow (>= 2.2.2, < 4.0)
|
68
|
+
ruby-progressbar (~> 1.7)
|
69
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
70
|
+
ruby-progressbar (1.9.0)
|
71
|
+
thread_safe (0.3.6)
|
72
|
+
tzinfo (1.2.5)
|
73
|
+
thread_safe (~> 0.1)
|
74
|
+
unicode-display_width (1.3.2)
|
75
|
+
|
76
|
+
PLATFORMS
|
77
|
+
ruby
|
78
|
+
|
79
|
+
DEPENDENCIES
|
80
|
+
active_record_extended!
|
81
|
+
bundler (~> 1.16)
|
82
|
+
byebug
|
83
|
+
database_cleaner (~> 1.6)
|
84
|
+
dotenv
|
85
|
+
pry (~> 0.11.3)
|
86
|
+
pry-byebug (~> 3.5, >= 3.5.1)
|
87
|
+
rake (~> 10.0)
|
88
|
+
rspec (~> 3.0)
|
89
|
+
rubocop (~> 0.52)
|
90
|
+
|
91
|
+
BUNDLED WITH
|
92
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 George Protacio-Karaszi
|
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,45 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/GeorgeKaraszi/active_record_extended.svg?branch=master)](https://travis-ci.org/GeorgeKaraszi/active_record_extended) [![Maintainability](https://api.codeclimate.com/v1/badges/98ecffc0239417098cbc/maintainability)](https://codeclimate.com/github/GeorgeKaraszi/active_record_extended/maintainability)
|
2
|
+
|
3
|
+
# Active Record Extended
|
4
|
+
|
5
|
+
Active Record Extended is the continuation of maintaining and improving the work done by **Dan McClain**, the original author of [postgres_ext](https://github.com/DavyJonesLocker/postgres_ext).
|
6
|
+
|
7
|
+
Overtime the lack of updating to support the latest versions of ActiveRecord 5.x has caused quite a bit of users forking off the project to create their own patches jobs to maintain compatibility.
|
8
|
+
The only problem is that this has created a wild west of environments of sorts. The problem has grown to the point no one is attempting to directly contribute to the original source. And forked repositories are finding themselves as equally as dead with little to no activity.
|
9
|
+
|
10
|
+
Active Record Extended is intended to be a supporting community that will maintain compatibility for the foreseeable future.
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'active_record_extended'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install active_record_extended
|
27
|
+
|
28
|
+
|
29
|
+
## Development
|
30
|
+
|
31
|
+
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.
|
32
|
+
|
33
|
+
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).
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/postgres_extended. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
38
|
+
|
39
|
+
## License
|
40
|
+
|
41
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
42
|
+
|
43
|
+
## Code of Conduct
|
44
|
+
|
45
|
+
Everyone interacting in the ActiveRecordExtended project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/postgres_extended/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,102 @@
|
|
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
|
+
|
8
|
+
task default: :spec
|
9
|
+
|
10
|
+
task :setup do
|
11
|
+
if File.exist?(".env")
|
12
|
+
puts "This will overwrite your existing .env file"
|
13
|
+
end
|
14
|
+
db_name = fetch_input("Enter your database name: [postgres_ext_test] ")
|
15
|
+
db_user = fetch_input("Enter your database user: [] ")
|
16
|
+
db_password = fetch_input("Enter your database password: [] ")
|
17
|
+
db_server = fetch_input("Enter your database server: [localhost] ")
|
18
|
+
|
19
|
+
db_name = "active_record_extended_test" if db_name.empty?
|
20
|
+
db_password = ":#{db_password}" unless db_password.empty?
|
21
|
+
db_server = "localhost" if db_server.empty?
|
22
|
+
db_server = "@#{db_server}" unless db_user.empty?
|
23
|
+
env_path = File.expand_path("./.env")
|
24
|
+
|
25
|
+
File.open(env_path, "w") do |file|
|
26
|
+
file.puts "DATABASE_NAME=#{db_name}"
|
27
|
+
file.puts "DATABASE_URL=\"postgres://#{db_user}#{db_password}#{db_server}/#{db_name}\""
|
28
|
+
end
|
29
|
+
|
30
|
+
puts ".env file saved"
|
31
|
+
end
|
32
|
+
|
33
|
+
# rubocop:disable Metrics/BlockLength
|
34
|
+
|
35
|
+
namespace :db do
|
36
|
+
task :load_db_settings do
|
37
|
+
require "active_record"
|
38
|
+
unless ENV["DATABASE_URL"]
|
39
|
+
require "dotenv"
|
40
|
+
Dotenv.load
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
task drop: :load_db_settings do
|
45
|
+
`dropdb #{ENV["DATABASE_NAME"]}`
|
46
|
+
end
|
47
|
+
|
48
|
+
task create: :load_db_settings do
|
49
|
+
`createdb #{ENV["DATABASE_NAME"]}`
|
50
|
+
end
|
51
|
+
|
52
|
+
task migrate: :load_db_settings do
|
53
|
+
ActiveRecord::Base.establish_connection(ENV["DATABASE_URL"])
|
54
|
+
|
55
|
+
ActiveRecord::Schema.define do
|
56
|
+
enable_extension "hstore"
|
57
|
+
|
58
|
+
create_table :people, force: true do |t|
|
59
|
+
t.integer "tag_ids", array: true
|
60
|
+
t.string "tags", array: true
|
61
|
+
t.integer "personal_id"
|
62
|
+
t.hstore "data"
|
63
|
+
t.jsonb "jsonb_data"
|
64
|
+
t.datetime "created_at"
|
65
|
+
t.datetime "updated_at"
|
66
|
+
end
|
67
|
+
|
68
|
+
create_table :tags, force: true do |t|
|
69
|
+
t.belongs_to :person
|
70
|
+
end
|
71
|
+
|
72
|
+
create_table :profile_ls, force: true do |t|
|
73
|
+
t.belongs_to :person
|
74
|
+
t.integer :likes
|
75
|
+
end
|
76
|
+
|
77
|
+
create_table :profile_rs, force: true do |t|
|
78
|
+
t.belongs_to :person
|
79
|
+
t.integer :dislikes
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
puts "Database migrated"
|
84
|
+
end
|
85
|
+
|
86
|
+
task setup: :load_db_settings do
|
87
|
+
unless ENV["DATABASE_URL"]
|
88
|
+
Rake::Task["setup"].invoke
|
89
|
+
Dotenv.load
|
90
|
+
end
|
91
|
+
|
92
|
+
Rake::Task["db:create"].invoke
|
93
|
+
Rake::Task["db:migrate"].invoke
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# rubocop:enable Metrics/BlockLength
|
98
|
+
|
99
|
+
def fetch_input(message)
|
100
|
+
print message
|
101
|
+
STDIN.gets.chomp
|
102
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "lib"))
|
5
|
+
|
6
|
+
require "active_record_extended/version"
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = "active_record_extended"
|
10
|
+
spec.version = ActiveRecordExtended::VERSION
|
11
|
+
spec.authors = ["George Protacio-Karaszi", "Dan McClain"]
|
12
|
+
spec.email = ["georgekaraszi@gmail.com", "git@danmcclain.net"]
|
13
|
+
|
14
|
+
spec.summary = "Adds extended functionality to Activerecord Postgres implementation"
|
15
|
+
spec.description = "Adds extended functionality to Activerecord Postgres implementation"
|
16
|
+
spec.homepage = "https://github.com/georgekaraszi/active_record_extended"
|
17
|
+
spec.license = "MIT"
|
18
|
+
|
19
|
+
spec.files = `git ls-files`.split("\n")
|
20
|
+
spec.test_files = `git ls-files -- spec/*`.split("\n")
|
21
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_dependency "activerecord", ">= 5.1", "< 6.0"
|
25
|
+
spec.add_dependency "ar_outer_joins", "~> 0.2"
|
26
|
+
spec.add_dependency "pg", "~> 0.18"
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
29
|
+
spec.add_development_dependency "database_cleaner", "~> 1.6"
|
30
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
32
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "active_record_extended"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_record"
|
4
|
+
|
5
|
+
require "active_record_extended/predicate_builder/array_handler_decorator"
|
6
|
+
require "active_record_extended/query_methods/where_chain"
|
7
|
+
require "active_record_extended/query_methods/either"
|
8
|
+
|
9
|
+
if ActiveRecord::VERSION::MAJOR >= 5
|
10
|
+
if ActiveRecord::VERSION::MINOR >= 2
|
11
|
+
require "active_record_extended/patch/5_2/where_clause"
|
12
|
+
else
|
13
|
+
require "active_record_extended/patch/5_1/where_clause"
|
14
|
+
end
|
15
|
+
end
|