active_record_extended 0.5.0.beta3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +0 -0
  3. data/.gitignore +1 -0
  4. data/.rspec +0 -0
  5. data/.rubocop.yml +0 -0
  6. data/.ruby-gemset +0 -0
  7. data/.ruby-version +0 -0
  8. data/.travis.yml +6 -0
  9. data/CHANGELOG.md +4 -0
  10. data/CODE_OF_CONDUCT.md +0 -0
  11. data/Gemfile +0 -0
  12. data/Gemfile.lock +9 -1
  13. data/LICENSE.txt +0 -0
  14. data/README.md +110 -70
  15. data/Rakefile +0 -0
  16. data/active_record_extended.gemspec +1 -0
  17. data/gemfiles/activerecord-50.gemfile +0 -0
  18. data/gemfiles/activerecord-51.gemfile +0 -0
  19. data/gemfiles/activerecord-52+.gemfile +0 -0
  20. data/gemfiles/activerecord-52.gemfile +0 -0
  21. data/lib/active_record_extended/active_record.rb +0 -0
  22. data/lib/active_record_extended/arel/nodes.rb +0 -33
  23. data/lib/active_record_extended/arel/predications.rb +0 -0
  24. data/lib/active_record_extended/arel/visitors/postgresql_decorator.rb +0 -0
  25. data/lib/active_record_extended/arel.rb +0 -0
  26. data/lib/active_record_extended/patch/5_0/predicate_builder_decorator.rb +0 -0
  27. data/lib/active_record_extended/patch/5_1/where_clause.rb +0 -0
  28. data/lib/active_record_extended/patch/5_2/where_clause.rb +0 -0
  29. data/lib/active_record_extended/predicate_builder/array_handler_decorator.rb +0 -0
  30. data/lib/active_record_extended/query_methods/any_of.rb +0 -0
  31. data/lib/active_record_extended/query_methods/either.rb +0 -0
  32. data/lib/active_record_extended/query_methods/inet.rb +0 -0
  33. data/lib/active_record_extended/query_methods/where_chain.rb +0 -0
  34. data/lib/active_record_extended/version.rb +1 -1
  35. data/lib/active_record_extended.rb +0 -0
  36. data/spec/active_record_extended_spec.rb +0 -0
  37. data/spec/query_methods/any_of_spec.rb +0 -0
  38. data/spec/query_methods/array_query_spec.rb +0 -0
  39. data/spec/query_methods/either_spec.rb +12 -4
  40. data/spec/query_methods/hash_query_spec.rb +0 -0
  41. data/spec/query_methods/inet_query_spec.rb +0 -0
  42. data/spec/spec_helper.rb +3 -0
  43. data/spec/sql_inspections/any_of_sql_spec.rb +0 -0
  44. data/spec/sql_inspections/arel/array_spec.rb +0 -0
  45. data/spec/sql_inspections/arel/inet_spec.rb +0 -0
  46. data/spec/sql_inspections/contains_sql_queries_spec.rb +0 -0
  47. data/spec/sql_inspections/either_sql_spec.rb +0 -0
  48. data/spec/support/database_cleaner.rb +0 -0
  49. data/spec/support/models.rb +0 -0
  50. metadata +18 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af96e1630626fddb09778e5ff69dc4bf01b06e17e2e462c7e65a2a165cac43dc
4
- data.tar.gz: 512da6651d7413301e720414ecddfdca47700ce3bd22adce5957f444c8b34f9f
3
+ metadata.gz: a9eeb9aca8c378f3cdb7d615c59b9d2c0490f1c208029d8873af2ed44f75685e
4
+ data.tar.gz: 2964c85f3aef6d185f416965356248b6a4af918e9e30d9bf238e7bd02aab33b1
5
5
  SHA512:
6
- metadata.gz: d165d1174ccb1f3fe3eb38cd08b399507564116da0a41847600b1dbc170f362b7cc763ef1191564a40c635abb1e07e0ec93bb92675f2283328cab78d032a5eda
7
- data.tar.gz: 3b790bf77539c16b30ecb217400601b1d0e1bc7ddae2e01ca11c3886ff054acf062eefceab6f766b4c37e050659a098083197696055cbaa75ea796854a574c9f
6
+ metadata.gz: 35abb91e76d72d6c49ac746817a5071dbbc1081493f8506e01f16a4caf462664e890ba9dea3e8d69820bcbd2e0461bc556fada21e3a6e6967150596dcaff3cfd
7
+ data.tar.gz: 4c550088739bda0c8e42ded831a213abdaa86461864d25e9e236b9a2376758bf69a42afbe3e3c084cfda6294075a77a25415ca7907e7ed94503fb8b998b4c8ff
data/.codeclimate.yml CHANGED
File without changes
data/.gitignore CHANGED
@@ -16,3 +16,4 @@
16
16
  *.DS_Store
17
17
 
18
18
  .pryrc
19
+ coverage
data/.rspec CHANGED
File without changes
data/.rubocop.yml CHANGED
File without changes
data/.ruby-gemset CHANGED
File without changes
data/.ruby-version CHANGED
File without changes
data/.travis.yml CHANGED
@@ -26,9 +26,15 @@ matrix:
26
26
  env: DATABASE_URL=postgres://postgres@localhost/active_record_extended_test
27
27
 
28
28
  before_script:
29
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
30
+ - chmod +x ./cc-test-reporter
31
+ - ./cc-test-reporter before-build
29
32
  - psql -c 'create database active_record_extended_test;' -U postgres
30
33
  - bundle exec rake db:migrate
31
34
 
35
+ after_script:
36
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
37
+
32
38
  cache:
33
39
  - bundler
34
40
 
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.5.0 - May 31st 2018
2
+
3
+ Released non-marked beta version.
4
+
1
5
  # 0.5.0.beta3 - May 28th 2018
2
6
 
3
7
  Added `inet_contains_or_contained_within/1` method
data/CODE_OF_CONDUCT.md CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_record_extended (0.5.0.beta3)
4
+ active_record_extended (0.5.0)
5
5
  activerecord (>= 5.0, < 6.0)
6
6
  ar_outer_joins (~> 0.2)
7
7
  pg (~> 0.18)
@@ -29,9 +29,11 @@ GEM
29
29
  concurrent-ruby (1.0.5)
30
30
  database_cleaner (1.7.0)
31
31
  diff-lcs (1.3)
32
+ docile (1.3.0)
32
33
  dotenv (2.4.0)
33
34
  i18n (1.0.1)
34
35
  concurrent-ruby (~> 1.0)
36
+ json (2.1.0)
35
37
  method_source (0.9.0)
36
38
  minitest (5.11.3)
37
39
  parallel (1.12.1)
@@ -68,6 +70,11 @@ GEM
68
70
  ruby-progressbar (~> 1.7)
69
71
  unicode-display_width (~> 1.0, >= 1.0.1)
70
72
  ruby-progressbar (1.9.0)
73
+ simplecov (0.16.1)
74
+ docile (~> 1.1)
75
+ json (>= 1.8, < 3)
76
+ simplecov-html (~> 0.10.0)
77
+ simplecov-html (0.10.2)
71
78
  thread_safe (0.3.6)
72
79
  tzinfo (1.2.5)
73
80
  thread_safe (~> 0.1)
@@ -87,6 +94,7 @@ DEPENDENCIES
87
94
  rake (~> 10.0)
88
95
  rspec (~> 3.0)
89
96
  rubocop (~> 0.52)
97
+ simplecov (~> 0.16)
90
98
 
91
99
  BUNDLED WITH
92
100
  1.16.1
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
- [![Build Status](https://travis-ci.com/GeorgeKaraszi/ActiveRecordExtended.svg?branch=master)](https://travis-ci.com/GeorgeKaraszi/ActiveRecordExtended) [![Maintainability](https://api.codeclimate.com/v1/badges/98ecffc0239417098cbc/maintainability)](https://codeclimate.com/github/GeorgeKaraszi/active_record_extended/maintainability)
2
-
1
+ [![Build Status](https://travis-ci.com/GeorgeKaraszi/ActiveRecordExtended.svg?branch=master)](https://travis-ci.com/GeorgeKaraszi/ActiveRecordExtended)
2
+ [![Maintainability](https://api.codeclimate.com/v1/badges/98ecffc0239417098cbc/maintainability)](https://codeclimate.com/github/GeorgeKaraszi/active_record_extended/maintainability)
3
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/f22154211bb3a8feb89f/test_coverage)](https://codeclimate.com/github/GeorgeKaraszi/ActiveRecordExtended/test_coverage)
3
4
  ## Index
4
5
  - [Description and history](#description-and-history)
5
6
  - [Installation](#installation)
@@ -40,11 +41,11 @@ Active Record Extended is intended to be a supporting community that will mainta
40
41
  In Postgres the `ANY` expression is used for gather record's that have an Array column type that contain a single matchable value within its array.
41
42
 
42
43
  ```ruby
43
- alice = Person.create!(tags: [1])
44
- bob = Person.create!(tags: [1, 2])
45
- randy = Person.create!(tags: [3])
44
+ alice = User.create!(tags: [1])
45
+ bob = User.create!(tags: [1, 2])
46
+ randy = User.create!(tags: [3])
46
47
 
47
- Person.where.any(tags: 1) #=> [alice, bob]
48
+ User.where.any(tags: 1) #=> [alice, bob]
48
49
 
49
50
  ```
50
51
 
@@ -57,11 +58,11 @@ This only accepts a single value. So querying for example multiple tag numbers `
57
58
  In Postgres the `ALL` expression is used for gather record's that have an Array column type that contains only a **single** and matchable element.
58
59
 
59
60
  ```ruby
60
- alice = Person.create!(tags: [1])
61
- bob = Person.create!(tags: [1, 2])
62
- randy = Person.create!(tags: [3])
61
+ alice = User.create!(tags: [1])
62
+ bob = User.create!(tags: [1, 2])
63
+ randy = User.create!(tags: [3])
63
64
 
64
- Person.where.all(tags: 1) #=> [alice]
65
+ User.where.all(tags: 1) #=> [alice]
65
66
 
66
67
  ```
67
68
 
@@ -78,20 +79,20 @@ That contains all of the provided values.
78
79
 
79
80
  Array Type:
80
81
  ```ruby
81
- alice = Person.create!(tags: [1, 4])
82
- bob = Person.create!(tags: [3, 1])
83
- randy = Person.create!(tags: [4, 1])
82
+ alice = User.create!(tags: [1, 4])
83
+ bob = User.create!(tags: [3, 1])
84
+ randy = User.create!(tags: [4, 1])
84
85
 
85
- Person.where.contains(tags: [1, 4]) #=> [alice, randy]
86
+ User.where.contains(tags: [1, 4]) #=> [alice, randy]
86
87
  ```
87
88
 
88
89
  HSTORE / JSONB Type:
89
90
  ```ruby
90
- alice = Person.create!(data: { nickname: "ARExtend" })
91
- bob = Person.create!(data: { nickname: "ARExtended" })
92
- randy = Person.create!(data: { nickname: "ARExtended" })
91
+ alice = User.create!(data: { nickname: "ARExtend" })
92
+ bob = User.create!(data: { nickname: "ARExtended" })
93
+ randy = User.create!(data: { nickname: "ARExtended" })
93
94
 
94
- Person.where.contains(data: { nickname: "ARExtended" }) #=> [bob, randy]
95
+ User.where.contains(data: { nickname: "ARExtended" }) #=> [bob, randy]
95
96
  ```
96
97
 
97
98
  #### Overlap
@@ -100,13 +101,13 @@ Person.where.contains(data: { nickname: "ARExtended" }) #=> [bob, randy]
100
101
  The `overlap/1` method will match an Array column type that contains any of the provided values within its column.
101
102
 
102
103
  ```ruby
103
- alice = Person.create!(tags: [1, 4])
104
- bob = Person.create!(tags: [3, 4])
105
- randy = Person.create!(tags: [4, 8])
104
+ alice = User.create!(tags: [1, 4])
105
+ bob = User.create!(tags: [3, 4])
106
+ randy = User.create!(tags: [4, 8])
106
107
 
107
- Person.where.overlap(tags: [4]) #=> [alice, bob, randy]
108
- Person.where.overlap(tags: [1, 8]) #=> [alice, randy]
109
- Person.where.overlap(tags: [1, 3, 8]) #=> [alice, bob, randy]
108
+ User.where.overlap(tags: [4]) #=> [alice, bob, randy]
109
+ User.where.overlap(tags: [1, 8]) #=> [alice, randy]
110
+ User.where.overlap(tags: [1, 3, 8]) #=> [alice, bob, randy]
110
111
 
111
112
  ```
112
113
 
@@ -118,12 +119,12 @@ The `inet_contains` method works by taking a column(inet type) that has a submas
118
119
  And tries to find related records that fall within a given IP's range.
119
120
 
120
121
  ```ruby
121
- alice = Person.create!(ip: "127.0.0.1/16")
122
- bob = Person.create!(ip: "192.168.0.1/16")
122
+ alice = User.create!(ip: "127.0.0.1/16")
123
+ bob = User.create!(ip: "192.168.0.1/16")
123
124
 
124
- Person.where.inet_contains(ip: "127.0.0.254") #=> [alice]
125
- Person.where.inet_contains(ip: "192.168.20.44") #=> [bob]
126
- Person.where.inet_contains(ip: "192.255.1.1") #=> []
125
+ User.where.inet_contains(ip: "127.0.0.254") #=> [alice]
126
+ User.where.inet_contains(ip: "192.168.20.44") #=> [bob]
127
+ User.where.inet_contains(ip: "192.255.1.1") #=> []
127
128
  ```
128
129
 
129
130
  ##### Inet Contains or Equals
@@ -132,12 +133,12 @@ Person.where.inet_contains(ip: "192.255.1.1") #=> []
132
133
  The `inet_contains_or_equals` method works much like the [Inet Contains](#inet-contains) method, but will also accept a submask range.
133
134
 
134
135
  ```ruby
135
- alice = Person.create!(ip: "127.0.0.1/10")
136
- bob = Person.create!(ip: "127.0.0.44/24")
136
+ alice = User.create!(ip: "127.0.0.1/10")
137
+ bob = User.create!(ip: "127.0.0.44/24")
137
138
 
138
- Person.where.inet_contains_or_equals(ip: "127.0.0.1/16") #=> [alice]
139
- Person.where.inet_contains_or_equals(ip: "127.0.0.1/10") #=> [alice]
140
- Person.where.inet_contains_or_equals(ip: "127.0.0.1/32") #=> [alice, bob]
139
+ User.where.inet_contains_or_equals(ip: "127.0.0.1/16") #=> [alice]
140
+ User.where.inet_contains_or_equals(ip: "127.0.0.1/10") #=> [alice]
141
+ User.where.inet_contains_or_equals(ip: "127.0.0.1/32") #=> [alice, bob]
141
142
  ```
142
143
 
143
144
  ##### Inet Contained Within
@@ -146,12 +147,12 @@ Person.where.inet_contains_or_equals(ip: "127.0.0.1/32") #=> [alice, bob]
146
147
  For the `inet_contained_within` method, we try to find IP's that fall within a submasking range we provide.
147
148
 
148
149
  ```ruby
149
- alice = Person.create!(ip: "127.0.0.1")
150
- bob = Person.create!(ip: "127.0.0.44")
151
- randy = Person.create!(ip: "127.0.55.20")
150
+ alice = User.create!(ip: "127.0.0.1")
151
+ bob = User.create!(ip: "127.0.0.44")
152
+ randy = User.create!(ip: "127.0.55.20")
152
153
 
153
- Person.where.inet_contained_within(ip: "127.0.0.1/24") #=> [alice, bob]
154
- Person.where.inet_contained_within(ip: "127.0.0.1/16") #=> [alice, bob, randy]
154
+ User.where.inet_contained_within(ip: "127.0.0.1/24") #=> [alice, bob]
155
+ User.where.inet_contained_within(ip: "127.0.0.1/16") #=> [alice, bob, randy]
155
156
  ```
156
157
 
157
158
  ##### Inet Contained Within or Equals
@@ -160,13 +161,13 @@ Person.where.inet_contained_within(ip: "127.0.0.1/16") #=> [alice, bob, randy]
160
161
  The `inet_contained_within_or_equals` method works much like the [Inet Contained Within](#inet-contained-within) method, but will also accept a submask range.
161
162
 
162
163
  ```ruby
163
- alice = Person.create!(ip: "127.0.0.1/10")
164
- bob = Person.create!(ip: "127.0.0.44/32")
165
- randy = Person.create!(ip: "127.0.99.1")
164
+ alice = User.create!(ip: "127.0.0.1/10")
165
+ bob = User.create!(ip: "127.0.0.44/32")
166
+ randy = User.create!(ip: "127.0.99.1")
166
167
 
167
- Person.where.inet_contained_within_or_equals(ip: "127.0.0.44/32") #=> [bob]
168
- Person.where.inet_contained_within_or_equals(ip: "127.0.0.1/16") #=> [bob, randy]
169
- Person.where.inet_contained_within_or_equals(ip: "127.0.0.44/8") #=> [alice, bob, randy]
168
+ User.where.inet_contained_within_or_equals(ip: "127.0.0.44/32") #=> [bob]
169
+ User.where.inet_contained_within_or_equals(ip: "127.0.0.1/16") #=> [bob, randy]
170
+ User.where.inet_contained_within_or_equals(ip: "127.0.0.44/8") #=> [alice, bob, randy]
170
171
  ```
171
172
 
172
173
  ##### Inet Contains or Contained Within
@@ -176,13 +177,13 @@ The `inet_contains_or_contained_within` method is a combination of [Inet Contain
176
177
  It essentially (the database) tries to use both methods to find as many records as possible that match either condition on both sides.
177
178
 
178
179
  ```ruby
179
- alice = Person.create!(ip: "127.0.0.1/24")
180
- bob = Person.create!(ip: "127.0.22.44/8")
181
- randy = Person.create!(ip: "127.0.99.1")
180
+ alice = User.create!(ip: "127.0.0.1/24")
181
+ bob = User.create!(ip: "127.0.22.44/8")
182
+ randy = User.create!(ip: "127.0.99.1")
182
183
 
183
- Person.where.inet_contains_or_is_contained_within(ip: "127.0.255.80") #=> [bob]
184
- Person.where.inet_contains_or_is_contained_within(ip: "127.0.0.80") #=> [alice, bob]
185
- Person.where.inet_contains_or_is_contained_within(ip: "127.0.0.80/8") #=> [alice, bob, randy]
184
+ User.where.inet_contains_or_is_contained_within(ip: "127.0.255.80") #=> [bob]
185
+ User.where.inet_contains_or_is_contained_within(ip: "127.0.0.80") #=> [alice, bob]
186
+ User.where.inet_contains_or_is_contained_within(ip: "127.0.0.80/8") #=> [alice, bob, randy]
186
187
  ```
187
188
 
188
189
  ### Conditional Methods
@@ -195,43 +196,82 @@ Person.where.inet_contains_or_is_contained_within(ip: "127.0.0.80/8") #=> [alice
195
196
 
196
197
  Querying With Attributes:
197
198
  ```ruby
198
- alice = Person.create!(uid: 1)
199
- bob = Person.create!(uid: 2)
200
- randy = Person.create!(uid: 3)
199
+ alice = User.create!(uid: 1)
200
+ bob = User.create!(uid: 2)
201
+ randy = User.create!(uid: 3)
201
202
 
202
- Person.where.any_of({ uid: 1 }, { uid: 2 }) #=> [alice, bob]
203
+ User.where.any_of({ uid: 1 }, { uid: 2 }) #=> [alice, bob]
203
204
  ```
204
205
 
205
206
  Querying With ActiveRecord Objects:
206
207
  ```ruby
207
- alice = Person.create!(uid: 1)
208
- bob = Person.create!(uid: 2)
209
- randy = Person.create!(uid: 3)
208
+ alice = User.create!(uid: 1)
209
+ bob = User.create!(uid: 2)
210
+ randy = User.create!(uid: 3)
210
211
 
211
- uid_one = Person.where(uid: 1)
212
- uid_two = Person.where(uid: 2)
212
+ uid_one = User.where(uid: 1)
213
+ uid_two = User.where(uid: 2)
213
214
 
214
- Person.where.any_of(uid_one, uid_two) #=> [alice, bob]
215
+ User.where.any_of(uid_one, uid_two) #=> [alice, bob]
215
216
  ```
216
217
 
217
218
  Querying with Joined Relationships:
218
219
  ```ruby
219
- alice = Person.create!(uid: 1)
220
- bob = Person.create!(uid: 2)
221
- randy = Person.create!(uid: 3)
222
- tag_alice = Tag.create!(person_id: alice.id)
223
- tag_bob = Tag.create!(person_id: person_two.id)
224
- tag_randy = Tag.create!(person_id: person_three.id)
220
+ alice = User.create!(uid: 1)
221
+ bob = User.create!(uid: 2)
222
+ randy = User.create!(uid: 3)
223
+ tag_alice = Tag.create!(user_id: alice.id)
224
+ tag_bob = Tag.create!(user_id: bob.id)
225
+ tag_randy = Tag.create!(user_id: randy.id)
225
226
 
226
- bob_tag_query = Tag.where(people: { id: two.id }).includes(:person)
227
- randy_tag_query = Tag.where(people: { id: three.id }).joins(:person)
227
+ bob_tag_query = Tag.where(users: { id: bob.id }).includes(:user)
228
+ randy_tag_query = Tag.where(users: { id: randy.id }).joins(:user)
228
229
 
229
- Tag.joins(:person).where.any_of(bob_tag_query, randy_tag_query) #=> [tag_bob, tag_randy] (with person table joined)
230
+ Tag.joins(:user).where.any_of(bob_tag_query, randy_tag_query) #=> [tag_bob, tag_randy] (with users table joined)
230
231
  ```
231
232
 
232
233
  #### Either Join
234
+
235
+ The `#either_join/2` method is a base ActiveRecord querying method that will joins records based on a set of conditionally joinable tables.
236
+
237
+ ```ruby
238
+ class User < ActiveRecord::Base
239
+ has_one :profile_l, class: "ProfileL"
240
+ has_one :profile_r, class: "ProfileR"
241
+
242
+ scope :completed_profile, -> { either_joins(:profile_l, :profile_r) }
243
+ end
244
+
245
+ alice = User.create!
246
+ bob = User.create!
247
+ randy = User.create! # Does not have a single completed profile type
248
+ ProfileL.create!(user_id: alice.id)
249
+ ProfileR.create!(user_id: bob.id)
250
+
251
+ User.completed_profile #=> [alice, bob]
252
+ # alternatively
253
+ User.either_joins(:profile_l, :profile_r) #=> [alice, bob]
254
+ ```
255
+
233
256
  #### Either Order
234
257
 
258
+ The `#either_order/3` method is a base ActiveRecord querying method that will order a set of columns that may or may not exist for each record.
259
+ This works similar to how [Either Join](#either-join) works. This does not however exclude records that do not have relationships.
260
+
261
+ ```ruby
262
+ alice = User.create!
263
+ bob = User.create!
264
+ ProfileL.create!(user_id: alice.id, left_turns: 100)
265
+ ProfileR.create!(user_id: bob.id, right_turns: 50)
266
+
267
+ User.either_order(:asc, profile_l: :left_turns, profile_r: :right_turns) #=> [bob, alice]
268
+ User.either_order(:desc, profile_l: :left_turns, profile_r: :right_turns) #=> [alice, bob]
269
+
270
+ randy = User.create!
271
+ User.either_order(:asc, profile_l: :left_turns, profile_r: :right_turns) #=> [bob, alice, randy]
272
+ User.either_order(:desc, profile_l: :left_turns, profile_r: :right_turns) #=> [randy, alice, bob]
273
+ ```
274
+
235
275
  ## Installation
236
276
 
237
277
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
File without changes
@@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "database_cleaner", "~> 1.6"
30
30
  spec.add_development_dependency "rake", "~> 10.0"
31
31
  spec.add_development_dependency "rspec", "~> 3.0"
32
+ spec.add_development_dependency "simplecov", "~> 0.16"
32
33
  end
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -5,64 +5,31 @@ require "arel/nodes/binary"
5
5
  module Arel
6
6
  module Nodes
7
7
  class Overlap < Arel::Nodes::Binary
8
- def operator
9
- :"&&"
10
- end
11
8
  end
12
9
 
13
10
  class Contains < Arel::Nodes::Binary
14
- def operator
15
- :>>
16
- end
17
11
  end
18
12
 
19
13
  class ContainsHStore < Arel::Nodes::Binary
20
- def operator
21
- :"@>"
22
- end
23
14
  end
24
15
 
25
16
  class ContainsArray < Arel::Nodes::Binary
26
- def operator
27
- :"@>"
28
- end
29
17
  end
30
18
 
31
19
  class ContainedInArray < Arel::Nodes::Binary
32
- def operator
33
- :"<@"
34
- end
35
20
  end
36
21
 
37
22
  module Inet
38
23
  class ContainsEquals < Arel::Nodes::Binary
39
- def operator
40
- :">>="
41
- end
42
24
  end
43
25
 
44
26
  class ContainedWithin < Arel::Nodes::Binary
45
- def operator
46
- :<<
47
- end
48
27
  end
49
28
 
50
29
  class ContainedWithinEquals < Arel::Nodes::Binary
51
- def operator
52
- :"<<="
53
- end
54
30
  end
55
31
 
56
32
  class ContainsOrContainedWithin < Arel::Nodes::Binary
57
- def operator
58
- :"&&"
59
- end
60
- end
61
- end
62
-
63
- class Node
64
- def group_or(right)
65
- Arel::Nodes::Or.new self, Arel::Nodes::Grouping.new(right)
66
33
  end
67
34
  end
68
35
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecordExtended
4
- VERSION = "0.5.0.beta3"
4
+ VERSION = "0.5.0"
5
5
  end
File without changes
File without changes
File without changes
File without changes
@@ -28,23 +28,31 @@ RSpec.describe "Active Record Either Methods" do
28
28
  describe ".either_order/2" do
29
29
  it "Should not exclude anyone who does not have a relationship" do
30
30
  query = Person.either_order(:asc, profile_l: :likes, profile_r: :dislikes)
31
- expect(query).to include(one, two, three)
31
+ expect(query.count).to eq(3)
32
+ expect(query[0]).to eq(two)
33
+ expect(query[1]).to eq(one)
34
+ expect(query[2]).to eq(three)
32
35
  end
33
36
 
34
37
  it "Should order people based on their likes and dislikes in ascended order" do
35
38
  query = Person.either_order(:asc, profile_l: :likes, profile_r: :dislikes).where(id: [one.id, two.id])
36
- expect(query).to match_array([two, one])
39
+ expect(query.count).to eq(2)
40
+ expect(query.first).to eq(two)
41
+ expect(query.last).to eq(one)
37
42
  end
38
43
 
39
44
  it "Should order people based on their likes and dislikes in descending order" do
40
45
  query = Person.either_order(:desc, profile_l: :likes, profile_r: :dislikes).where(id: [one.id, two.id])
41
- expect(query).to match_array([one, two])
46
+ expect(query.first).to eq(one)
47
+ expect(query.last).to eq(two)
42
48
  end
43
49
 
44
50
  context "Alias .either_order/2" do
45
51
  it "Should order people based on their likes and dislikes in ascended order" do
46
52
  query = Person.either_orders(:asc, profile_l: :likes, profile_r: :dislikes).where(id: [one.id, two.id])
47
- expect(query).to match_array([two, one])
53
+ expect(query.count).to eq(2)
54
+ expect(query.first).to eq(two)
55
+ expect(query.last).to eq(one)
48
56
  end
49
57
  end
50
58
  end
File without changes
File without changes
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "simplecov"
4
+ SimpleCov.start
5
+
3
6
  require "active_record_extended"
4
7
 
5
8
  unless ENV["DATABASE_URL"]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_extended
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.beta3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - George Protacio-Karaszi
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-05-27 00:00:00.000000000 Z
13
+ date: 2018-05-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -116,6 +116,20 @@ dependencies:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
118
118
  version: '3.0'
119
+ - !ruby/object:Gem::Dependency
120
+ name: simplecov
121
+ requirement: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '0.16'
126
+ type: :development
127
+ prerelease: false
128
+ version_requirements: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '0.16'
119
133
  description: Adds extended functionality to Activerecord Postgres implementation
120
134
  email:
121
135
  - georgekaraszi@gmail.com
@@ -192,9 +206,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
192
206
  version: '0'
193
207
  required_rubygems_version: !ruby/object:Gem::Requirement
194
208
  requirements:
195
- - - ">"
209
+ - - ">="
196
210
  - !ruby/object:Gem::Version
197
- version: 1.3.1
211
+ version: '0'
198
212
  requirements: []
199
213
  rubyforge_project:
200
214
  rubygems_version: 2.7.6