partisan 0.4.2 → 0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/README.md +5 -2
- data/gemfiles/Gemfile.activerecord-5.0 +5 -0
- data/lib/partisan/helper.rb +1 -1
- data/lib/partisan/version.rb +1 -1
- data/partisan.gemspec +1 -1
- data/spec/partisan/helper_spec.rb +12 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34e1fc2af5b77d30d9f279c2217ac74d28f6c1f2
|
4
|
+
data.tar.gz: 86500ae07a16b4538c98ade54751295c8f62961f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ab7dfac955e6db1c6741d6e7737629ee2a31331d355368e2118f14ea05c850bb527c8880fd1dd9ca39f82a443a0e5dbde1cc7c8713e5a3ff04122295d5ac575
|
7
|
+
data.tar.gz: 311eed5f77657c68e0498491cbccfe12dd028605d47fc27bfb02ce14db267deb0ce86021ede16ac52ce93b53ade06d70439d248c9bacf53e040c505efb8fd601
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -22,7 +22,7 @@ It’s heavily inspired by `acts_as_follower`. However, it’s not 100% compatib
|
|
22
22
|
But I also added awesome new ones:
|
23
23
|
|
24
24
|
* You can use `following_team_ids` but also `following_team_names` (basically any `following_team_<column>s`). It takes advantage of the `pluck` method, so it doesn’t create an instance of each follower, it just return the relevant column values. (Go check `pluck` documentation, it’s simply awesome).
|
25
|
-
* The `
|
25
|
+
* The `follows` and `followings` methods now return an `ActiveRecord::Relation` for easy chaining, scoping, counting, pagination, etc.
|
26
26
|
|
27
27
|
## Installation
|
28
28
|
|
@@ -72,6 +72,9 @@ fan.follow(band)
|
|
72
72
|
fan.following_bands
|
73
73
|
# => [<Band id=2>]
|
74
74
|
|
75
|
+
band.fan_followers
|
76
|
+
# => [<Fan id=1>]
|
77
|
+
|
75
78
|
fan.follows?(band)
|
76
79
|
# => true
|
77
80
|
|
@@ -89,7 +92,7 @@ However, if the *followed* record has a `followers_count` column, Partisan will
|
|
89
92
|
```ruby
|
90
93
|
fan.follow(band)
|
91
94
|
|
92
|
-
band.
|
95
|
+
band.followings.count
|
93
96
|
# SQL query that counts records and returns `1`
|
94
97
|
|
95
98
|
band.followers_count
|
data/lib/partisan/helper.rb
CHANGED
@@ -9,7 +9,7 @@ module Partisan
|
|
9
9
|
klass ||= obj.object.class if obj.respond_to?(:object) && obj.object.class < ActiveRecord::Base
|
10
10
|
|
11
11
|
# In case we’re using STI, loop back until we find the top-level ActiveRecord model
|
12
|
-
klass = klass.superclass while klass.superclass != ActiveRecord::Base
|
12
|
+
klass = klass.superclass while !klass.superclass.abstract_class && klass.superclass != ActiveRecord::Base
|
13
13
|
|
14
14
|
klass.name
|
15
15
|
end
|
data/lib/partisan/version.rb
CHANGED
data/partisan.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(spec)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency 'activerecord', '>=
|
21
|
+
spec.add_dependency 'activerecord', '>= 5.0.0'
|
22
22
|
|
23
23
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
24
|
spec.add_development_dependency 'rake'
|
@@ -24,6 +24,18 @@ describe Partisan::Helper do
|
|
24
24
|
it { expect(parent_class_name).to eql 'Article' }
|
25
25
|
end
|
26
26
|
|
27
|
+
context 'with object that inherits from abstract class' do
|
28
|
+
let(:object) do
|
29
|
+
spawn_model('ApplicationRecord', ActiveRecord::Base) do
|
30
|
+
self.abstract_class = true
|
31
|
+
end
|
32
|
+
|
33
|
+
spawn_model('Article', ApplicationRecord).new
|
34
|
+
end
|
35
|
+
|
36
|
+
it { expect(parent_class_name).to eql 'Article' }
|
37
|
+
end
|
38
|
+
|
27
39
|
context 'with a presented record object' do
|
28
40
|
let(:presenter_class) do
|
29
41
|
Class.new(::SimpleDelegator) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: partisan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Prévost
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-07-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 5.0.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 5.0.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: bundler
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- Rakefile
|
101
101
|
- gemfiles/Gemfile.activerecord-4.1
|
102
102
|
- gemfiles/Gemfile.activerecord-4.2
|
103
|
+
- gemfiles/Gemfile.activerecord-5.0
|
103
104
|
- lib/generators/partisan/USAGE
|
104
105
|
- lib/generators/partisan/install_generator.rb
|
105
106
|
- lib/generators/partisan/templates/migration.rb
|
@@ -138,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
139
|
version: '0'
|
139
140
|
requirements: []
|
140
141
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.
|
142
|
+
rubygems_version: 2.5.1
|
142
143
|
signing_key:
|
143
144
|
specification_version: 4
|
144
145
|
summary: Partisan is a Ruby library that allows ActiveRecord records to be follower
|