edge_rider 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +99 -0
- data/.rspec +1 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +16 -6
- data/Gemfile +1 -0
- data/Gemfile.4.2.mysql2 +2 -2
- data/Gemfile.4.2.mysql2.lock +20 -20
- data/Gemfile.4.2.pg +1 -1
- data/Gemfile.4.2.pg.lock +18 -18
- data/Gemfile.5.2.mysql2 +2 -2
- data/Gemfile.5.2.mysql2.lock +6 -6
- data/Gemfile.5.2.pg +1 -1
- data/Gemfile.5.2.pg.lock +4 -4
- data/{Gemfile.6.0.pg → Gemfile.6.1.pg} +2 -2
- data/Gemfile.6.1.pg.lock +78 -0
- data/Gemfile.lock +1 -0
- data/README.md +84 -60
- data/edge_rider.gemspec +24 -16
- data/lib/edge_rider/util.rb +1 -1
- data/lib/edge_rider/version.rb +1 -1
- metadata +13 -24
- data/.travis.yml +0 -51
- data/Gemfile.3.2.mysql2 +0 -17
- data/Gemfile.3.2.mysql2.lock +0 -72
- data/Gemfile.6.0.pg.lock +0 -74
- data/spec/edge_rider/collect_column_spec.rb +0 -85
- data/spec/edge_rider/collect_ids_spec.rb +0 -108
- data/spec/edge_rider/origin_class_spec.rb +0 -32
- data/spec/edge_rider/preload_associations_spec.rb +0 -31
- data/spec/edge_rider/scoped_spec.rb +0 -53
- data/spec/edge_rider/to_id_query_spec.rb +0 -29
- data/spec/edge_rider/traverse_association_spec.rb +0 -175
- data/spec/edge_rider/util_spec.rb +0 -5
- data/spec/spec_helper.rb +0 -14
- data/spec/support/database.rb +0 -39
- data/spec/support/database.sample.yml +0 -10
- data/spec/support/database.travis.yml +0 -9
- data/spec/support/models.rb +0 -97
data/.travis.yml
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
dist: trusty
|
4
|
-
|
5
|
-
matrix:
|
6
|
-
include:
|
7
|
-
- rvm: 2.2.4
|
8
|
-
gemfile: Gemfile.3.2.mysql2
|
9
|
-
- rvm: 2.2.4
|
10
|
-
gemfile: Gemfile.4.2.mysql2
|
11
|
-
- rvm: 2.3.1
|
12
|
-
gemfile: Gemfile.4.2.mysql2
|
13
|
-
- rvm: 2.2.4
|
14
|
-
gemfile: Gemfile.4.2.pg
|
15
|
-
- rvm: 2.3.1
|
16
|
-
gemfile: Gemfile.4.2.pg
|
17
|
-
- rvm: 2.2.4
|
18
|
-
gemfile: Gemfile.5.2.mysql2
|
19
|
-
- rvm: 2.3.1
|
20
|
-
gemfile: Gemfile.5.2.mysql2
|
21
|
-
- rvm: 2.4.1
|
22
|
-
gemfile: Gemfile.5.2.mysql2
|
23
|
-
- rvm: 2.5.3
|
24
|
-
gemfile: Gemfile.5.2.mysql2
|
25
|
-
- rvm: 2.2.4
|
26
|
-
gemfile: Gemfile.5.2.pg
|
27
|
-
- rvm: 2.3.1
|
28
|
-
gemfile: Gemfile.5.2.pg
|
29
|
-
- rvm: 2.4.1
|
30
|
-
gemfile: Gemfile.5.2.pg
|
31
|
-
- rvm: 2.5.3
|
32
|
-
gemfile: Gemfile.5.2.pg
|
33
|
-
- rvm: 2.5.3
|
34
|
-
gemfile: Gemfile.6.0.pg
|
35
|
-
|
36
|
-
services:
|
37
|
-
- mysql
|
38
|
-
|
39
|
-
install:
|
40
|
-
# Replace default Travis CI bundler script with a version that doesn't
|
41
|
-
# explode when lockfile doesn't match recently bumped version
|
42
|
-
- bundle install --no-deployment --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
|
43
|
-
|
44
|
-
addons:
|
45
|
-
postgresql: 9.3
|
46
|
-
|
47
|
-
before_script:
|
48
|
-
- psql -c 'create database edge_rider_test;' -U postgres
|
49
|
-
- mysql -e 'create database IF NOT EXISTS edge_rider_test;'
|
50
|
-
|
51
|
-
script: bundle exec rake current_rspec
|
data/Gemfile.3.2.mysql2
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# Runtime dependencies
|
4
|
-
gem 'activerecord', '=3.2.22'
|
5
|
-
gem 'mysql2', '= 0.3.17'
|
6
|
-
gem 'i18n', '=0.6.11' # 0.7 no longer builds for Ruby 1.8.7
|
7
|
-
|
8
|
-
# Development dependencies
|
9
|
-
gem 'rake', '=10.0.4'
|
10
|
-
gem 'database_cleaner'
|
11
|
-
gem 'rspec', '~> 3.4'
|
12
|
-
gem 'has_defaults' # used by test models
|
13
|
-
gem 'gemika'
|
14
|
-
gem 'pry-byebug'
|
15
|
-
|
16
|
-
# Gem under test
|
17
|
-
gem 'edge_rider', path: '.'
|
data/Gemfile.3.2.mysql2.lock
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
edge_rider (1.1.0)
|
5
|
-
activerecord (>= 3.2)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
activemodel (3.2.22)
|
11
|
-
activesupport (= 3.2.22)
|
12
|
-
builder (~> 3.0.0)
|
13
|
-
activerecord (3.2.22)
|
14
|
-
activemodel (= 3.2.22)
|
15
|
-
activesupport (= 3.2.22)
|
16
|
-
arel (~> 3.0.2)
|
17
|
-
tzinfo (~> 0.3.29)
|
18
|
-
activesupport (3.2.22)
|
19
|
-
i18n (~> 0.6, >= 0.6.4)
|
20
|
-
multi_json (~> 1.0)
|
21
|
-
arel (3.0.3)
|
22
|
-
builder (3.0.4)
|
23
|
-
byebug (10.0.2)
|
24
|
-
coderay (1.1.2)
|
25
|
-
database_cleaner (1.0.1)
|
26
|
-
diff-lcs (1.2.5)
|
27
|
-
gemika (0.4.0)
|
28
|
-
has_defaults (0.4.4)
|
29
|
-
activerecord
|
30
|
-
i18n (0.6.11)
|
31
|
-
method_source (0.9.2)
|
32
|
-
multi_json (1.12.1)
|
33
|
-
mysql2 (0.3.17)
|
34
|
-
pry (0.12.2)
|
35
|
-
coderay (~> 1.1.0)
|
36
|
-
method_source (~> 0.9.0)
|
37
|
-
pry-byebug (3.6.0)
|
38
|
-
byebug (~> 10.0)
|
39
|
-
pry (~> 0.10)
|
40
|
-
rake (10.0.4)
|
41
|
-
rspec (3.5.0)
|
42
|
-
rspec-core (~> 3.5.0)
|
43
|
-
rspec-expectations (~> 3.5.0)
|
44
|
-
rspec-mocks (~> 3.5.0)
|
45
|
-
rspec-core (3.5.3)
|
46
|
-
rspec-support (~> 3.5.0)
|
47
|
-
rspec-expectations (3.5.0)
|
48
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
-
rspec-support (~> 3.5.0)
|
50
|
-
rspec-mocks (3.5.0)
|
51
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
-
rspec-support (~> 3.5.0)
|
53
|
-
rspec-support (3.5.0)
|
54
|
-
tzinfo (0.3.51)
|
55
|
-
|
56
|
-
PLATFORMS
|
57
|
-
ruby
|
58
|
-
|
59
|
-
DEPENDENCIES
|
60
|
-
activerecord (= 3.2.22)
|
61
|
-
database_cleaner
|
62
|
-
edge_rider!
|
63
|
-
gemika
|
64
|
-
has_defaults
|
65
|
-
i18n (= 0.6.11)
|
66
|
-
mysql2 (= 0.3.17)
|
67
|
-
pry-byebug
|
68
|
-
rake (= 10.0.4)
|
69
|
-
rspec (~> 3.4)
|
70
|
-
|
71
|
-
BUNDLED WITH
|
72
|
-
1.17.3
|
data/Gemfile.6.0.pg.lock
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
edge_rider (1.1.0)
|
5
|
-
activerecord (>= 3.2)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
activemodel (6.0.0.rc1)
|
11
|
-
activesupport (= 6.0.0.rc1)
|
12
|
-
activerecord (6.0.0.rc1)
|
13
|
-
activemodel (= 6.0.0.rc1)
|
14
|
-
activesupport (= 6.0.0.rc1)
|
15
|
-
activesupport (6.0.0.rc1)
|
16
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
-
i18n (>= 0.7, < 2)
|
18
|
-
minitest (~> 5.1)
|
19
|
-
tzinfo (~> 1.1)
|
20
|
-
zeitwerk (~> 2.1, >= 2.1.4)
|
21
|
-
byebug (10.0.2)
|
22
|
-
coderay (1.1.2)
|
23
|
-
concurrent-ruby (1.1.5)
|
24
|
-
database_cleaner (1.7.0)
|
25
|
-
diff-lcs (1.3)
|
26
|
-
gemika (0.4.0)
|
27
|
-
has_defaults (0.4.4)
|
28
|
-
activerecord
|
29
|
-
i18n (1.6.0)
|
30
|
-
concurrent-ruby (~> 1.0)
|
31
|
-
method_source (0.9.2)
|
32
|
-
minitest (5.11.3)
|
33
|
-
pg (1.1.4)
|
34
|
-
pry (0.12.2)
|
35
|
-
coderay (~> 1.1.0)
|
36
|
-
method_source (~> 0.9.0)
|
37
|
-
pry-byebug (3.6.0)
|
38
|
-
byebug (~> 10.0)
|
39
|
-
pry (~> 0.10)
|
40
|
-
rake (12.3.2)
|
41
|
-
rspec (3.8.0)
|
42
|
-
rspec-core (~> 3.8.0)
|
43
|
-
rspec-expectations (~> 3.8.0)
|
44
|
-
rspec-mocks (~> 3.8.0)
|
45
|
-
rspec-core (3.8.0)
|
46
|
-
rspec-support (~> 3.8.0)
|
47
|
-
rspec-expectations (3.8.2)
|
48
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
-
rspec-support (~> 3.8.0)
|
50
|
-
rspec-mocks (3.8.0)
|
51
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
-
rspec-support (~> 3.8.0)
|
53
|
-
rspec-support (3.8.0)
|
54
|
-
thread_safe (0.3.6)
|
55
|
-
tzinfo (1.2.5)
|
56
|
-
thread_safe (~> 0.1)
|
57
|
-
zeitwerk (2.1.6)
|
58
|
-
|
59
|
-
PLATFORMS
|
60
|
-
ruby
|
61
|
-
|
62
|
-
DEPENDENCIES
|
63
|
-
activerecord (~> 6.0.0.rc1)
|
64
|
-
database_cleaner
|
65
|
-
edge_rider!
|
66
|
-
gemika
|
67
|
-
has_defaults
|
68
|
-
pg
|
69
|
-
pry-byebug
|
70
|
-
rake
|
71
|
-
rspec
|
72
|
-
|
73
|
-
BUNDLED WITH
|
74
|
-
1.17.3
|
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe EdgeRider::CollectColumn do
|
4
|
-
|
5
|
-
describe '#collect_column' do
|
6
|
-
|
7
|
-
it 'should collect the given value from a scope' do
|
8
|
-
Forum.create!(id: 1, name: 'Name 1')
|
9
|
-
Forum.create!(id: 2, name: 'Name 2')
|
10
|
-
Forum.create!(id: 3, name: 'Name 3')
|
11
|
-
scope = Forum.scoped(conditions: { id: [2, 3] })
|
12
|
-
scope.collect_column(:name).should =~ ['Name 2', 'Name 3']
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should collect the given value from an ActiveRecord class' do
|
16
|
-
Forum.create!(id: 1, name: 'Name 1')
|
17
|
-
Forum.create!(id: 2, name: 'Name 2')
|
18
|
-
Forum.collect_column(:name).should =~ ['Name 1', 'Name 2']
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should cast the collected value to their equivalent Ruby type' do
|
22
|
-
Post.create!
|
23
|
-
Post.collect_column(:created_at).first.should be_a(Time)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should not instantiate ActiveRecord objects when collecting values' do
|
27
|
-
Forum.create!(name: 'Name')
|
28
|
-
Forum.should_not_receive(:new)
|
29
|
-
Forum.collect_column(:name).should == ['Name']
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should qualify the column name to resolve any ambiguities' do
|
33
|
-
expect { Topic.scoped(joins: :forum).collect_column(:id) }.to_not raise_error
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'with :distinct option' do
|
37
|
-
|
38
|
-
it 'should return unique values' do
|
39
|
-
Forum.create!(id: 1, name: 'Name 1')
|
40
|
-
Forum.create!(id: 2, name: 'Name 2')
|
41
|
-
Forum.create!(id: 3, name: 'Name 2')
|
42
|
-
scope = Forum.scoped(conditions: { id: [2, 3] })
|
43
|
-
scope.collect_column(:name, distinct: true).should =~ ['Name 2']
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
context 'when called on a has many association' do
|
49
|
-
|
50
|
-
it 'should collect the given value' do
|
51
|
-
topic = Topic.create!
|
52
|
-
post = Post.create!(topic: topic, id: 1)
|
53
|
-
post = Post.create!(topic: topic, id: 2)
|
54
|
-
topic.reload
|
55
|
-
topic.posts.to_a
|
56
|
-
topic.posts.collect_column(:id).should =~ [1,2]
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'should return values when further restricted with an anonymous scope' do
|
60
|
-
topic = Topic.create!
|
61
|
-
post = Post.create!(topic: topic, id: 1)
|
62
|
-
post = Post.create!(topic: topic, id: 2)
|
63
|
-
topic.reload
|
64
|
-
topic.posts.to_a
|
65
|
-
if topic.posts.respond_to?(:where)
|
66
|
-
topic.posts.where(id: [1]).collect_ids.should =~ [1]
|
67
|
-
else
|
68
|
-
topic.posts.scoped(conditions: {id: [1]}).collect_column(:id).should =~ [1]
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'should return values when further restricted with a named scope' do
|
73
|
-
topic = Topic.create!
|
74
|
-
post = Post.create!(topic: topic, id: 1)
|
75
|
-
post = Post.create!(topic: topic, id: 2)
|
76
|
-
topic.reload
|
77
|
-
topic.posts.to_a
|
78
|
-
topic.posts.these([1]).collect_column(:id).should =~ [1]
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
@@ -1,108 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe EdgeRider::CollectIds do
|
4
|
-
|
5
|
-
describe '#collect_ids' do
|
6
|
-
|
7
|
-
context 'when called on an ActiveRecord class' do
|
8
|
-
|
9
|
-
it 'should return the ids for all records of that class' do
|
10
|
-
Forum.create!(id: 1)
|
11
|
-
Forum.create!(id: 2)
|
12
|
-
Forum.collect_ids.should =~ [1, 2]
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'when called on a scope' do
|
18
|
-
|
19
|
-
it 'should return the ids for all records matching that scope' do
|
20
|
-
Forum.create!(id: 1, name: 'Name 1')
|
21
|
-
Forum.create!(id: 2, name: 'Name 2')
|
22
|
-
Forum.create!(id: 3, name: 'Name 2')
|
23
|
-
scope = Forum.scoped(conditions: { name: 'Name 2' })
|
24
|
-
scope.collect_ids.should =~ [2, 3]
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'when called on an Integer' do
|
30
|
-
|
31
|
-
it 'should return the number as an array with a single element' do
|
32
|
-
5.collect_ids.should == [5]
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'when called on another scalar value' do
|
38
|
-
|
39
|
-
it 'should not be defined' do
|
40
|
-
expect { "foo".collect_ids }.to raise_error(NoMethodError)
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'when called on an array of Integers' do
|
46
|
-
|
47
|
-
it 'should return the list itself' do
|
48
|
-
[1, 3].collect_ids.should == [1, 3]
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
context 'when called on an array of ActiveRecords' do
|
54
|
-
|
55
|
-
it 'should return the ids collected from that list' do
|
56
|
-
forum_1 = Forum.create!(id: 1)
|
57
|
-
forum_2 = Forum.create!(id: 2)
|
58
|
-
[forum_1, forum_2].collect_ids.should =~ [1, 2]
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'when called on an array of other values' do
|
64
|
-
|
65
|
-
it 'should raise an error' do
|
66
|
-
expect { [1, 'foo', 3].collect_ids }.to raise_error(EdgeRider::CollectIds::Uncollectable)
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
context 'when called on a has many association' do
|
72
|
-
|
73
|
-
it 'should return the ids' do
|
74
|
-
topic = Topic.create!
|
75
|
-
post = Post.create!(topic: topic, id: 1)
|
76
|
-
post = Post.create!(topic: topic, id: 2)
|
77
|
-
topic.reload
|
78
|
-
topic.posts.to_a
|
79
|
-
topic.posts.collect_ids.should =~ [1,2]
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'should return ids when further restricted with an anonymous scope' do
|
83
|
-
topic = Topic.create!
|
84
|
-
post = Post.create!(topic: topic, id: 1)
|
85
|
-
post = Post.create!(topic: topic, id: 2)
|
86
|
-
topic.reload
|
87
|
-
topic.posts.to_a
|
88
|
-
if topic.posts.respond_to?(:where)
|
89
|
-
topic.posts.where(id: [1]).collect_ids.should =~ [1]
|
90
|
-
else
|
91
|
-
topic.posts.scoped(conditions: {id: [1]}).collect_ids.should =~ [1]
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'should return ids when further restricted with a named scope' do
|
96
|
-
topic = Topic.create!
|
97
|
-
post = Post.create!(topic: topic, id: 1)
|
98
|
-
post = Post.create!(topic: topic, id: 2)
|
99
|
-
topic.reload
|
100
|
-
topic.posts.to_a
|
101
|
-
topic.posts.these([1]).collect_ids.should =~ [1]
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe EdgeRider::OriginClass do
|
4
|
-
|
5
|
-
describe '#origin_class' do
|
6
|
-
|
7
|
-
it "should return the class a scope is based on" do
|
8
|
-
Forum.create!(id: 1)
|
9
|
-
Forum.create!(id: 2)
|
10
|
-
scope = Forum.scoped(conditions: { id: [1] })
|
11
|
-
scope.origin_class.should == Forum
|
12
|
-
scope.origin_class.collect_ids.should == [1, 2]
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should return the class a scope chain is based on" do
|
16
|
-
Forum.create!(id: 1, name: 'A')
|
17
|
-
Forum.create!(id: 2, name: 'B')
|
18
|
-
Forum.create!(id: 3, name: 'C')
|
19
|
-
scope_chain = Forum.scoped(conditions: { id: [1, 2] }).scoped(conditions: { name: ['A', 'B'] })
|
20
|
-
scope_chain.origin_class.should == Forum
|
21
|
-
scope_chain.origin_class.collect_ids.should == [1, 2, 3]
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should return itself when called on an ActiveRecord class" do
|
25
|
-
Forum.create!(id: 1)
|
26
|
-
Forum.create!(id: 2)
|
27
|
-
Forum.origin_class.should == Forum
|
28
|
-
Forum.origin_class.collect_ids.should == [1, 2]
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|