acts-as-taggable-on 3.1.1 → 3.2.2
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/.gitignore +1 -1
- data/.travis.yml +9 -7
- data/Appraisals +13 -8
- data/CHANGELOG.md +27 -7
- data/Gemfile +1 -2
- data/README.md +36 -19
- data/Rakefile +5 -17
- data/UPGRADING.md +6 -0
- data/acts-as-taggable-on.gemspec +15 -15
- data/db/migrate/1_acts_as_taggable_on_migration.rb +3 -3
- data/db/migrate/2_add_missing_unique_indices.rb +3 -5
- data/db/migrate/3_add_taggings_counter_cache_to_tags.rb +1 -1
- data/gemfiles/activerecord_3.2.gemfile +15 -0
- data/gemfiles/activerecord_4.0.gemfile +15 -0
- data/gemfiles/activerecord_4.1.gemfile +15 -0
- data/gemfiles/activerecord_edge.gemfile +16 -0
- data/lib/acts-as-taggable-on.rb +23 -21
- data/lib/acts_as_taggable_on/acts_as_taggable_on/cache.rb +2 -4
- data/lib/acts_as_taggable_on/acts_as_taggable_on/collection.rb +29 -20
- data/lib/acts_as_taggable_on/acts_as_taggable_on/compatibility.rb +11 -10
- data/lib/acts_as_taggable_on/acts_as_taggable_on/core.rb +103 -85
- data/lib/acts_as_taggable_on/acts_as_taggable_on/ownership.rb +5 -12
- data/lib/acts_as_taggable_on/acts_as_taggable_on/related.rb +11 -11
- data/lib/acts_as_taggable_on/engine.rb +0 -1
- data/lib/acts_as_taggable_on/tag.rb +24 -19
- data/lib/acts_as_taggable_on/tag_list.rb +97 -22
- data/lib/acts_as_taggable_on/taggable.rb +26 -30
- data/lib/acts_as_taggable_on/tagger.rb +30 -18
- data/lib/acts_as_taggable_on/tagging.rb +7 -8
- data/lib/acts_as_taggable_on/tags_helper.rb +1 -1
- data/lib/acts_as_taggable_on/utils.rb +57 -35
- data/lib/acts_as_taggable_on/version.rb +1 -1
- data/spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb +133 -138
- data/spec/acts_as_taggable_on/acts_as_tagger_spec.rb +55 -58
- data/spec/acts_as_taggable_on/caching_spec.rb +34 -35
- data/spec/acts_as_taggable_on/related_spec.rb +59 -113
- data/spec/acts_as_taggable_on/single_table_inheritance_spec.rb +118 -95
- data/spec/acts_as_taggable_on/tag_list_spec.rb +89 -57
- data/spec/acts_as_taggable_on/tag_spec.rb +129 -116
- data/spec/acts_as_taggable_on/taggable_spec.rb +539 -352
- data/spec/acts_as_taggable_on/tagger_spec.rb +81 -78
- data/spec/acts_as_taggable_on/tagging_spec.rb +13 -14
- data/spec/acts_as_taggable_on/tags_helper_spec.rb +25 -25
- data/spec/acts_as_taggable_on/utils_spec.rb +7 -13
- data/spec/internal/app/models/altered_inheriting_taggable_model.rb +3 -0
- data/spec/internal/app/models/cached_model.rb +3 -0
- data/spec/internal/app/models/cached_model_with_array.rb +5 -0
- data/spec/internal/app/models/company.rb +15 -0
- data/spec/internal/app/models/inheriting_taggable_model.rb +2 -0
- data/spec/internal/app/models/market.rb +2 -0
- data/spec/{models.rb → internal/app/models/models.rb} +34 -2
- data/spec/internal/app/models/non_standard_id_taggable_model.rb +8 -0
- data/spec/internal/app/models/ordered_taggable_model.rb +4 -0
- data/spec/internal/app/models/other_cached_model.rb +3 -0
- data/spec/internal/app/models/other_taggable_model.rb +4 -0
- data/spec/internal/app/models/student.rb +2 -0
- data/spec/internal/app/models/taggable_model.rb +13 -0
- data/spec/internal/app/models/untaggable_model.rb +3 -0
- data/spec/internal/app/models/user.rb +3 -0
- data/spec/{database.yml.sample → internal/config/database.yml.sample} +2 -2
- data/spec/internal/db/schema.rb +97 -0
- data/spec/schema.rb +11 -0
- data/spec/spec_helper.rb +9 -62
- data/spec/support/array.rb +9 -0
- data/spec/support/database.rb +42 -0
- data/spec/support/database_cleaner.rb +21 -0
- metadata +105 -43
- data/gemfiles/rails_3.2.gemfile +0 -7
- data/gemfiles/rails_4.0.gemfile +0 -7
- data/gemfiles/rails_4.1.gemfile +0 -7
- data/gemfiles/rails_edge.gemfile +0 -7
- data/spec/bm.rb +0 -52
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bc40e6d7c5c8b741bfc71aee7ae2406c6f824108
|
|
4
|
+
data.tar.gz: 3c89e20ed3b39ef33d52724d4bb8b9aa3e5738f9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e4142af492646d113a10fa0ae4815d91a281f2a55d60fb70b653a96d4ac58e24c56e1e10bcbf9907bbcc06cee2b476b6ec4a568cc25e5247578a140cbf388d85
|
|
7
|
+
data.tar.gz: eceb8e025f83cdbc9e237405eac982aa3b7c7ef0f54d803fcd80d1ed837b833d4f07fe549f0eb0eaa443edb5cdc84bcad79555a67a886e7fc706b46aa5d37b35
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
rvm:
|
|
2
2
|
- 1.9.3
|
|
3
3
|
- 2.0.0
|
|
4
|
-
- 2.1.0
|
|
5
4
|
- 2.1.1
|
|
5
|
+
- rbx-2
|
|
6
6
|
env:
|
|
7
7
|
- DB=sqlite3
|
|
8
8
|
- DB=mysql
|
|
9
9
|
- DB=postgresql
|
|
10
10
|
gemfile:
|
|
11
|
-
- gemfiles/
|
|
12
|
-
- gemfiles/
|
|
13
|
-
- gemfiles/
|
|
14
|
-
- gemfiles/
|
|
11
|
+
- gemfiles/activerecord_3.2.gemfile
|
|
12
|
+
- gemfiles/activerecord_4.0.gemfile
|
|
13
|
+
- gemfiles/activerecord_4.1.gemfile
|
|
14
|
+
- gemfiles/activerecord_edge.gemfile
|
|
15
15
|
cache: bundler
|
|
16
16
|
script: bundle exec rake
|
|
17
|
-
before_install:
|
|
18
|
-
- gem install bundler
|
|
17
|
+
before_install: gem install bundler
|
|
19
18
|
bundler_args: '--without local_development'
|
|
20
19
|
matrix:
|
|
21
20
|
fast_finish: true
|
|
21
|
+
allow_failures:
|
|
22
|
+
- gemfile: gemfiles/activerecord_edge.gemfile
|
|
23
|
+
- rvm: rbx-2
|
data/Appraisals
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
appraise "
|
|
2
|
-
gem "
|
|
1
|
+
appraise "activerecord-3.2" do
|
|
2
|
+
gem "activerecord", "~> 3.2"
|
|
3
|
+
gem "actionpack", "~> 3.2"
|
|
3
4
|
end
|
|
4
5
|
|
|
5
|
-
appraise "
|
|
6
|
-
gem "
|
|
6
|
+
appraise "activerecord-4.0" do
|
|
7
|
+
gem "activerecord", "~> 4.0"
|
|
8
|
+
gem "actionpack", "~> 4.0"
|
|
7
9
|
end
|
|
8
10
|
|
|
9
|
-
appraise "
|
|
10
|
-
gem "
|
|
11
|
+
appraise "activerecord-4.1" do
|
|
12
|
+
gem "activerecord", "~> 4.1"
|
|
13
|
+
gem "actionpack", "~> 4.1"
|
|
11
14
|
end
|
|
12
15
|
|
|
13
|
-
appraise "
|
|
14
|
-
gem "
|
|
16
|
+
appraise "activerecord-edge" do
|
|
17
|
+
gem "activerecord", github: "rails/rails"
|
|
18
|
+
gem "actionpack", github: "rails/rails"
|
|
19
|
+
gem 'arel', github: 'rails/arel'
|
|
15
20
|
end
|
data/CHANGELOG.md
CHANGED
|
@@ -4,13 +4,33 @@ Each change should fall into categories that would affect whether the release is
|
|
|
4
4
|
|
|
5
5
|
As such, a _Feature_ would map to either major or minor. A _bug fix_ to a patch. And _misc_ is either minor or patch, the difference being kind of fuzzy for the purposes of history. Adding tests would be patch level.
|
|
6
6
|
|
|
7
|
-
### Master [changes](https://github.com/mbleigh/acts-as-taggable-on/compare/v3.
|
|
8
|
-
|
|
9
|
-
* Breaking Changes
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
7
|
+
### Master [changes](https://github.com/mbleigh/acts-as-taggable-on/compare/v3.2.0...master)
|
|
8
|
+
|
|
9
|
+
* Breaking Changes
|
|
10
|
+
* Taggable models are not extend with ActsAsTaggableOn::Utils anymore
|
|
11
|
+
* Features
|
|
12
|
+
* Fixes
|
|
13
|
+
* Performance
|
|
14
|
+
* Misc
|
|
15
|
+
* Deleted outdated benchmark script
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### [3.2.0 / 2014-05-1](https://github.com/mbleigh/acts-as-taggable-on/compare/v3.1.1...v3.2.0)
|
|
19
|
+
|
|
20
|
+
* Breaking Changes
|
|
21
|
+
* ActsAsTaggableOn::Tag is not extend with ActsAsTaggableOn::Utils anymore
|
|
22
|
+
* Features
|
|
23
|
+
* [@chess #413 Hook to support STI subclasses of Tag in save_tags](https://github.com/mbleigh/acts-as-taggable-on/pull/413)
|
|
24
|
+
* Fixes
|
|
25
|
+
* [@jdelStrother #515 Rename Compatibility methods to reduce chance of conflicts ](https://github.com/mbleigh/acts-as-taggable-on/pull/515)
|
|
26
|
+
* [@seuros #512 fix for << method](https://github.com/mbleigh/acts-as-taggable-on/pull/512)
|
|
27
|
+
* [@sonots #510 fix IN subquery error for mysql](https://github.com/mbleigh/acts-as-taggable-on/pull/510)
|
|
28
|
+
* [@jonseaberg #499 fix for race condition when multiple processes try to add the same tag](https://github.com/mbleigh/acts-as-taggable-on/pull/499)
|
|
29
|
+
* [@leklund #496 Fix for distinct and postgresql json columns errors](https://github.com/mbleigh/acts-as-taggable-on/pull/496)
|
|
30
|
+
* [@thatbettina & @plexus #394 Multiple quoted tags](https://github.com/mbleigh/acts-as-taggable-on/pull/496)
|
|
31
|
+
* Performance
|
|
32
|
+
* Misc
|
|
33
|
+
* [@seuros #511 Rspec 3](https://github.com/mbleigh/acts-as-taggable-on/pull/511)
|
|
14
34
|
|
|
15
35
|
### [3.1.0 / 2014-03-31](https://github.com/mbleigh/acts-as-taggable-on/compare/v3.0.1...v3.1.0)
|
|
16
36
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -76,14 +76,14 @@ end
|
|
|
76
76
|
Add and remove a single tag
|
|
77
77
|
|
|
78
78
|
```ruby
|
|
79
|
-
@user.tag_list.add("
|
|
79
|
+
@user.tag_list.add("awesome") # add a single tag. alias for <<
|
|
80
80
|
@user.tag_list.remove("awesome") # remove a single tag
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
Add and remove multiple tags in an array
|
|
84
84
|
|
|
85
85
|
```ruby
|
|
86
|
-
@user.tag_list.add("
|
|
86
|
+
@user.tag_list.add("awesome", "slick")
|
|
87
87
|
@user.tag_list.remove("awesome", "slick")
|
|
88
88
|
```
|
|
89
89
|
|
|
@@ -98,7 +98,7 @@ a change on delimiter setting, make sure the string will match. See
|
|
|
98
98
|
[configuration](#configuration) for more about delimiter.
|
|
99
99
|
|
|
100
100
|
```ruby
|
|
101
|
-
@user.tag_list.add("
|
|
101
|
+
@user.tag_list.add("awesome, slick", parse: true)
|
|
102
102
|
@user.tag_list.remove("awesome, slick", parse: true)
|
|
103
103
|
```
|
|
104
104
|
|
|
@@ -107,29 +107,41 @@ remove existing tags so use it with attention.
|
|
|
107
107
|
|
|
108
108
|
```ruby
|
|
109
109
|
@user.tag_list = "awesome, slick, hefty"
|
|
110
|
+
@user.save
|
|
111
|
+
@user.reload
|
|
110
112
|
@user.tags
|
|
111
|
-
|
|
113
|
+
=> [#<ActsAsTaggableOn::Tag id: 1, name: "awesome", taggings_count: 1>,
|
|
114
|
+
#<ActsAsTaggableOn::Tag id: 2, name: "slick", taggings_count: 1>,
|
|
115
|
+
#<ActsAsTaggableOn::Tag id: 3, name: "hefty", taggings_count: 1>]
|
|
112
116
|
```
|
|
113
117
|
|
|
114
118
|
With the defined context in model, you have multiple new methods at disposal
|
|
115
119
|
to manage and view the tags in the context. For example, with `:skill` context
|
|
116
120
|
these methods are added to the model: `skill_list`(and `skill_list.add`, `skill_list.remove`
|
|
117
|
-
`skill_list=`), `skills`(plural), skill_counts
|
|
118
|
-
|
|
121
|
+
`skill_list=`), `skills`(plural), `skill_counts`.
|
|
119
122
|
|
|
120
123
|
```ruby
|
|
121
124
|
@user.skill_list = "joking, clowning, boxing"
|
|
122
|
-
|
|
125
|
+
@user.save
|
|
126
|
+
@user.reload
|
|
123
127
|
@user.skills
|
|
124
|
-
|
|
128
|
+
=> [#<ActsAsTaggableOn::Tag id: 1, name: "joking", taggings_count: 1>,
|
|
129
|
+
#<ActsAsTaggableOn::Tag id: 2, name: "clowning", taggings_count: 1>,
|
|
130
|
+
#<ActsAsTaggableOn::Tag id: 3, name: "boxing", taggings_count: 1>]
|
|
125
131
|
|
|
126
132
|
@user.skill_list.add("coding")
|
|
127
133
|
|
|
128
134
|
@user.skill_list
|
|
129
|
-
# => ["joking","clowning","boxing", "coding"]
|
|
135
|
+
# => ["joking", "clowning", "boxing", "coding"]
|
|
136
|
+
|
|
137
|
+
@another_user = User.new(:name => "Alice")
|
|
138
|
+
@another_user.skill_list.add("clowning")
|
|
139
|
+
@another_user.save
|
|
130
140
|
|
|
131
141
|
User.skill_counts
|
|
132
|
-
|
|
142
|
+
=> [#<ActsAsTaggableOn::Tag id: 1, name: "joking", taggings_count: 1>,
|
|
143
|
+
#<ActsAsTaggableOn::Tag id: 2, name: "clowning", taggings_count: 2>,
|
|
144
|
+
#<ActsAsTaggableOn::Tag id: 3, name: "boxing", taggings_count: 1>]
|
|
133
145
|
```
|
|
134
146
|
|
|
135
147
|
To preserve the order in which tags are created use `acts_as_ordered_taggable`:
|
|
@@ -166,22 +178,22 @@ end
|
|
|
166
178
|
User.tagged_with("awesome").by_join_date
|
|
167
179
|
User.tagged_with("awesome").by_join_date.paginate(:page => params[:page], :per_page => 20)
|
|
168
180
|
|
|
169
|
-
# Find
|
|
181
|
+
# Find users that matches all given tags:
|
|
170
182
|
User.tagged_with(["awesome", "cool"], :match_all => true)
|
|
171
183
|
|
|
172
|
-
# Find
|
|
184
|
+
# Find users with any of the specified tags:
|
|
173
185
|
User.tagged_with(["awesome", "cool"], :any => true)
|
|
174
186
|
|
|
175
|
-
# Find
|
|
187
|
+
# Find users that has not been tagged with awesome or cool:
|
|
176
188
|
User.tagged_with(["awesome", "cool"], :exclude => true)
|
|
177
189
|
|
|
178
|
-
# Find
|
|
190
|
+
# Find users with any of the tags based on context:
|
|
179
191
|
User.tagged_with(['awesome', 'cool'], :on => :tags, :any => true).tagged_with(['smart', 'shy'], :on => :skills, :any => true)
|
|
180
192
|
```
|
|
181
193
|
|
|
182
|
-
You can also use `:wild => true` option along with `:any` or `:exclude` option. It will looking for `%awesome%` and `%cool%` in
|
|
194
|
+
You can also use `:wild => true` option along with `:any` or `:exclude` option. It will be looking for `%awesome%` and `%cool%` in SQL.
|
|
183
195
|
|
|
184
|
-
__Tip:__ `User.tagged_with([])` or `User.tagged_with('')` will return `[]`,
|
|
196
|
+
__Tip:__ `User.tagged_with([])` or `User.tagged_with('')` will return `[]`, an empty set of records.
|
|
185
197
|
|
|
186
198
|
### Relationships
|
|
187
199
|
|
|
@@ -199,7 +211,7 @@ matched tags.
|
|
|
199
211
|
@tom = User.find_by_name("Tom")
|
|
200
212
|
@tom.skill_list # => ["hacking", "jogging", "diving"]
|
|
201
213
|
|
|
202
|
-
@tom.find_related_skills # => [<User name="Bobby"
|
|
214
|
+
@tom.find_related_skills # => [<User name="Bobby">, <User name="Frankie">]
|
|
203
215
|
@bobby.find_related_skills # => [<User name="Tom">]
|
|
204
216
|
@frankie.find_related_skills # => [<User name="Tom">]
|
|
205
217
|
```
|
|
@@ -212,7 +224,7 @@ to allow for dynamic tag contexts (this could be user generated tag contexts!)
|
|
|
212
224
|
```ruby
|
|
213
225
|
@user = User.new(:name => "Bobby")
|
|
214
226
|
@user.set_tag_list_on(:customs, "same, as, tag, list")
|
|
215
|
-
@user.tag_list_on(:customs) # => ["same","as","tag","list"]
|
|
227
|
+
@user.tag_list_on(:customs) # => ["same", "as", "tag", "list"]
|
|
216
228
|
@user.save
|
|
217
229
|
@user.tags_on(:customs) # => [<Tag name='same'>,...]
|
|
218
230
|
@user.tag_counts_on(:customs)
|
|
@@ -263,7 +275,7 @@ Photo.tagged_with("paris", :on => :locations, :owned_by => @some_user)
|
|
|
263
275
|
To construct tag clouds, the frequency of each tag needs to be calculated.
|
|
264
276
|
Because we specified `acts_as_taggable_on` on the `User` class, we can
|
|
265
277
|
get a calculation of all the tag counts by using `User.tag_counts_on(:customs)`. But what if we wanted a tag count for
|
|
266
|
-
|
|
278
|
+
a single user's posts? To achieve this we call tag_counts on the association:
|
|
267
279
|
|
|
268
280
|
```ruby
|
|
269
281
|
User.find(:first).posts.tag_counts_on(:tags)
|
|
@@ -350,6 +362,11 @@ We have a long list of valued contributors. [Check them all](https://github.com/
|
|
|
350
362
|
|
|
351
363
|
* [Joost Baaij](https://github.com/tilsammans)
|
|
352
364
|
|
|
365
|
+
## TODO
|
|
366
|
+
|
|
367
|
+
- Write benchmark script
|
|
368
|
+
- Resolve concurrency issues
|
|
369
|
+
|
|
353
370
|
## Testing
|
|
354
371
|
|
|
355
372
|
Acts As Taggable On uses RSpec for its test coverage. Inside the gem
|
data/Rakefile
CHANGED
|
@@ -1,31 +1,19 @@
|
|
|
1
1
|
require 'rubygems'
|
|
2
|
-
|
|
3
|
-
require 'bundler/setup'
|
|
4
|
-
rescue LoadError
|
|
5
|
-
STDERR.puts "Bundler not loaded"
|
|
6
|
-
end
|
|
2
|
+
require 'bundler/setup'
|
|
7
3
|
|
|
8
4
|
desc 'Default: run specs'
|
|
9
|
-
task :
|
|
5
|
+
task default: :spec
|
|
10
6
|
|
|
11
7
|
desc 'Copy sample spec database.yml over if not exists'
|
|
12
8
|
task :copy_db_config do
|
|
13
|
-
cp 'spec/database.yml.sample', 'spec/database.yml'
|
|
9
|
+
cp 'spec/internal/config/database.yml.sample', 'spec/internal/config/database.yml'
|
|
14
10
|
end
|
|
15
11
|
|
|
16
|
-
task :
|
|
17
|
-
|
|
18
|
-
begin
|
|
19
|
-
require 'appraisal'
|
|
20
|
-
desc 'Run tests across gemfiles specified in Appraisals'
|
|
21
|
-
task :appraise => ['appraisal:cleanup', 'appraisal:install', 'appraisal']
|
|
22
|
-
rescue LoadError
|
|
23
|
-
puts "appraisal tasks not available"
|
|
24
|
-
end
|
|
12
|
+
task spec: [:copy_db_config]
|
|
25
13
|
|
|
26
14
|
require 'rspec/core/rake_task'
|
|
27
15
|
RSpec::Core::RakeTask.new do |t|
|
|
28
|
-
t.pattern =
|
|
16
|
+
t.pattern = 'spec/**/*_spec.rb'
|
|
29
17
|
end
|
|
30
18
|
|
|
31
19
|
Bundler::GemHelper.install_tasks
|
data/UPGRADING.md
CHANGED
|
@@ -5,3 +5,9 @@ Re-run the migrations generator
|
|
|
5
5
|
rake acts_as_taggable_on_engine:install:migrations
|
|
6
6
|
|
|
7
7
|
It will create any new migrations and skip existing ones
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
##Breaking changes:
|
|
11
|
+
|
|
12
|
+
- ActsAsTaggableOn::Tag is not extend with ActsAsTaggableOn::Utils anymore.
|
|
13
|
+
Please use ActsAsTaggableOn::Utils instead
|
data/acts-as-taggable-on.gemspec
CHANGED
|
@@ -4,35 +4,35 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
4
4
|
require 'acts_as_taggable_on/version'
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |gem|
|
|
7
|
-
gem.name =
|
|
7
|
+
gem.name = 'acts-as-taggable-on'
|
|
8
8
|
gem.version = ActsAsTaggableOn::VERSION
|
|
9
|
-
gem.authors = [
|
|
10
|
-
gem.email =
|
|
9
|
+
gem.authors = ['Michael Bleigh', 'Joost Baaij']
|
|
10
|
+
gem.email = %w(michael@intridea.com joost@spacebabies.nl)
|
|
11
11
|
gem.description = %q{With ActsAsTaggableOn, you can tag a single model on several contexts, such as skills, interests, and awards. It also provides other advanced functionality.}
|
|
12
|
-
gem.summary =
|
|
12
|
+
gem.summary = 'Advanced tagging for Rails.'
|
|
13
13
|
gem.homepage = 'https://github.com/mbleigh/acts-as-taggable-on'
|
|
14
|
-
gem.license =
|
|
14
|
+
gem.license = 'MIT'
|
|
15
15
|
|
|
16
16
|
gem.files = `git ls-files`.split($/)
|
|
17
|
-
gem.
|
|
18
|
-
gem.
|
|
19
|
-
gem.require_paths = ["lib"]
|
|
17
|
+
gem.test_files = gem.files.grep(%r{^spec/})
|
|
18
|
+
gem.require_paths = ['lib']
|
|
20
19
|
gem.required_ruby_version = '>= 1.9.3'
|
|
21
20
|
|
|
22
|
-
if File.
|
|
21
|
+
if File.exist?('UPGRADING.md')
|
|
23
22
|
gem.post_install_message = File.read('UPGRADING.md')
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
gem.add_runtime_dependency 'activerecord', ['>= 3', '< 5']
|
|
27
|
-
gem.add_runtime_dependency 'activesupport', ['>= 3', '< 5']
|
|
28
26
|
gem.add_runtime_dependency 'actionpack', ['>= 3', '< 5']
|
|
29
27
|
|
|
30
28
|
gem.add_development_dependency 'sqlite3'
|
|
31
|
-
gem.add_development_dependency 'mysql2'
|
|
29
|
+
gem.add_development_dependency 'mysql2'
|
|
32
30
|
gem.add_development_dependency 'pg'
|
|
33
31
|
|
|
34
|
-
gem.add_development_dependency 'rspec-rails', '
|
|
35
|
-
gem.add_development_dependency 'rspec', '~>
|
|
36
|
-
gem.add_development_dependency '
|
|
37
|
-
|
|
32
|
+
gem.add_development_dependency 'rspec-rails' , '~> 3.0.0.beta2'
|
|
33
|
+
gem.add_development_dependency 'rspec-its', '~> 1.0'
|
|
34
|
+
gem.add_development_dependency 'rspec', '3.0.0.beta2'
|
|
35
|
+
gem.add_development_dependency 'ammeter', '~> 1.0'
|
|
36
|
+
gem.add_development_dependency 'barrier', '~> 1.0'
|
|
37
|
+
gem.add_development_dependency 'database_cleaner', '~> 1.2'
|
|
38
38
|
end
|
|
@@ -9,12 +9,12 @@ class ActsAsTaggableOnMigration < ActiveRecord::Migration
|
|
|
9
9
|
|
|
10
10
|
# You should make sure that the column created is
|
|
11
11
|
# long enough to store the required class names.
|
|
12
|
-
t.references :taggable, :
|
|
13
|
-
t.references :tagger, :
|
|
12
|
+
t.references :taggable, polymorphic: true
|
|
13
|
+
t.references :tagger, polymorphic: true
|
|
14
14
|
|
|
15
15
|
# Limit is created to prevent MySQL error on index
|
|
16
16
|
# length for MyISAM table type: http://bit.ly/vgW2Ql
|
|
17
|
-
t.string :context, :
|
|
17
|
+
t.string :context, limit: 128
|
|
18
18
|
|
|
19
19
|
t.datetime :created_at
|
|
20
20
|
end
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
class AddMissingUniqueIndices < ActiveRecord::Migration
|
|
2
|
-
|
|
3
2
|
def self.up
|
|
4
3
|
add_index :tags, :name, unique: true
|
|
5
4
|
|
|
6
5
|
remove_index :taggings, :tag_id
|
|
7
6
|
remove_index :taggings, [:taggable_id, :taggable_type, :context]
|
|
8
7
|
add_index :taggings,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
[:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
|
|
9
|
+
unique: true, name: 'taggings_idx'
|
|
10
|
+
end
|
|
12
11
|
|
|
13
12
|
def self.down
|
|
14
13
|
remove_index :tags, :name
|
|
@@ -17,5 +16,4 @@ class AddMissingUniqueIndices < ActiveRecord::Migration
|
|
|
17
16
|
add_index :taggings, :tag_id
|
|
18
17
|
add_index :taggings, [:taggable_id, :taggable_type, :context]
|
|
19
18
|
end
|
|
20
|
-
|
|
21
19
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration
|
|
2
2
|
def self.up
|
|
3
|
-
add_column :tags, :taggings_count, :integer, :
|
|
3
|
+
add_column :tags, :taggings_count, :integer, default: 0
|
|
4
4
|
|
|
5
5
|
ActsAsTaggableOn::Tag.reset_column_information
|
|
6
6
|
ActsAsTaggableOn::Tag.find_each do |tag|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "activerecord", "~> 3.2"
|
|
6
|
+
gem "actionpack", "~> 3.2"
|
|
7
|
+
|
|
8
|
+
group :local_development do
|
|
9
|
+
gem "guard"
|
|
10
|
+
gem "guard-rspec"
|
|
11
|
+
gem "appraisal"
|
|
12
|
+
gem "rake"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
gemspec :path => "../"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "activerecord", "~> 4.0"
|
|
6
|
+
gem "actionpack", "~> 4.0"
|
|
7
|
+
|
|
8
|
+
group :local_development do
|
|
9
|
+
gem "guard"
|
|
10
|
+
gem "guard-rspec"
|
|
11
|
+
gem "appraisal"
|
|
12
|
+
gem "rake"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
gemspec :path => "../"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "activerecord", "~> 4.1"
|
|
6
|
+
gem "actionpack", "~> 4.1"
|
|
7
|
+
|
|
8
|
+
group :local_development do
|
|
9
|
+
gem "guard"
|
|
10
|
+
gem "guard-rspec"
|
|
11
|
+
gem "appraisal"
|
|
12
|
+
gem "rake"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
gemspec :path => "../"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "activerecord", :github => "rails/rails"
|
|
6
|
+
gem "actionpack", :github => "rails/rails"
|
|
7
|
+
gem "arel", :github => "rails/arel"
|
|
8
|
+
|
|
9
|
+
group :local_development do
|
|
10
|
+
gem "guard"
|
|
11
|
+
gem "guard-rspec"
|
|
12
|
+
gem "appraisal"
|
|
13
|
+
gem "rake"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
gemspec :path => "../"
|
data/lib/acts-as-taggable-on.rb
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
require
|
|
4
|
-
require
|
|
1
|
+
require 'active_record'
|
|
2
|
+
require 'active_record/version'
|
|
3
|
+
require 'active_support/core_ext/module'
|
|
4
|
+
require 'action_view'
|
|
5
5
|
|
|
6
|
-
require
|
|
6
|
+
require 'digest/sha1'
|
|
7
7
|
|
|
8
8
|
module ActsAsTaggableOn
|
|
9
|
+
class DuplicateTagError < StandardError
|
|
10
|
+
end
|
|
11
|
+
|
|
9
12
|
def self.setup
|
|
10
13
|
@configuration ||= Configuration.new
|
|
11
14
|
yield @configuration if block_given?
|
|
@@ -23,7 +26,7 @@ module ActsAsTaggableOn
|
|
|
23
26
|
def self.glue
|
|
24
27
|
setting = @configuration.delimiter
|
|
25
28
|
delimiter = setting.kind_of?(Array) ? setting[0] : setting
|
|
26
|
-
delimiter.ends_with?(
|
|
29
|
+
delimiter.ends_with?(' ') ? delimiter : "#{delimiter} "
|
|
27
30
|
end
|
|
28
31
|
|
|
29
32
|
class Configuration
|
|
@@ -42,23 +45,22 @@ module ActsAsTaggableOn
|
|
|
42
45
|
setup
|
|
43
46
|
end
|
|
44
47
|
|
|
48
|
+
require 'acts_as_taggable_on/utils'
|
|
45
49
|
|
|
46
|
-
require
|
|
47
|
-
|
|
48
|
-
require
|
|
49
|
-
require
|
|
50
|
-
require
|
|
51
|
-
require
|
|
52
|
-
require
|
|
53
|
-
require
|
|
54
|
-
require "acts_as_taggable_on/acts_as_taggable_on/related"
|
|
55
|
-
require "acts_as_taggable_on/acts_as_taggable_on/dirty"
|
|
50
|
+
require 'acts_as_taggable_on/taggable'
|
|
51
|
+
require 'acts_as_taggable_on/acts_as_taggable_on/compatibility'
|
|
52
|
+
require 'acts_as_taggable_on/acts_as_taggable_on/core'
|
|
53
|
+
require 'acts_as_taggable_on/acts_as_taggable_on/collection'
|
|
54
|
+
require 'acts_as_taggable_on/acts_as_taggable_on/cache'
|
|
55
|
+
require 'acts_as_taggable_on/acts_as_taggable_on/ownership'
|
|
56
|
+
require 'acts_as_taggable_on/acts_as_taggable_on/related'
|
|
57
|
+
require 'acts_as_taggable_on/acts_as_taggable_on/dirty'
|
|
56
58
|
|
|
57
|
-
require
|
|
58
|
-
require
|
|
59
|
-
require
|
|
60
|
-
require
|
|
61
|
-
require
|
|
59
|
+
require 'acts_as_taggable_on/tagger'
|
|
60
|
+
require 'acts_as_taggable_on/tag'
|
|
61
|
+
require 'acts_as_taggable_on/tag_list'
|
|
62
|
+
require 'acts_as_taggable_on/tags_helper'
|
|
63
|
+
require 'acts_as_taggable_on/tagging'
|
|
62
64
|
require 'acts_as_taggable_on/engine'
|
|
63
65
|
|
|
64
66
|
ActiveSupport.on_load(:active_record) do
|
|
@@ -31,12 +31,11 @@ module ActsAsTaggableOn::Taggable
|
|
|
31
31
|
# to mimic the underlying behavior. While processing this first
|
|
32
32
|
# call to columns, we do the caching column check and dynamically add
|
|
33
33
|
# the class and instance methods
|
|
34
|
+
# FIXME: this method cannot compile in rubinius
|
|
34
35
|
def columns
|
|
35
36
|
@acts_as_taggable_on_cache_columns ||= begin
|
|
36
37
|
db_columns = super
|
|
37
|
-
if _has_tags_cache_columns?(db_columns)
|
|
38
|
-
_add_tags_caching_methods
|
|
39
|
-
end
|
|
38
|
+
_add_tags_caching_methods if _has_tags_cache_columns?(db_columns)
|
|
40
39
|
db_columns
|
|
41
40
|
end
|
|
42
41
|
end
|
|
@@ -79,6 +78,5 @@ module ActsAsTaggableOn::Taggable
|
|
|
79
78
|
true
|
|
80
79
|
end
|
|
81
80
|
end
|
|
82
|
-
|
|
83
81
|
end
|
|
84
82
|
end
|