acts-as-taggable-array-on 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +12 -3
- data/README.md +54 -0
- data/acts-as-taggable-array-on.gemspec +3 -2
- data/gemfiles/rails_4.gemfile +7 -0
- data/gemfiles/rails_5.gemfile +7 -0
- data/lib/acts-as-taggable-array-on/taggable.rb +1 -1
- data/lib/acts-as-taggable-array-on/version.rb +1 -1
- data/spec/spec_helper.rb +3 -3
- metadata +19 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 571322f949adda3190c96102b3f5c5884aab591a
|
4
|
+
data.tar.gz: 35675504cfeb7e6bba4bb2616da65403abe91904
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdf1581fb54a72305b93c52c09ce192bef5bb7b88dd6647a5e2be90e32a6c094a643c4475a5de44224c94ef894314f47bf25f34e35c8096f99d178fb1a811681
|
7
|
+
data.tar.gz: 1ad9dbef4a56e0aca0de2e39c9af3bd6b263fe9a079893dc700fba14c11fa247492f4b83d08e25f69d09d3e083c5dd16870d467e62077dc24d7d6335e0cf14fe
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -2,15 +2,24 @@ language: ruby
|
|
2
2
|
rvm:
|
3
3
|
- 2.0.0
|
4
4
|
- 2.1.1
|
5
|
-
- 2.
|
5
|
+
- 2.2.2
|
6
|
+
- 2.3.0
|
6
7
|
addons:
|
7
8
|
postgresql: 9.3
|
8
9
|
gemfile:
|
9
|
-
- gemfiles/rails_4.
|
10
|
-
- gemfiles/
|
10
|
+
- gemfiles/rails_4.gemfile
|
11
|
+
- gemfiles/rails_5.gemfile
|
11
12
|
before_script:
|
12
13
|
- createuser -d acts-as-taggable-array-on -U postgres
|
13
14
|
- createdb --username=acts-as-taggable-array-on acts-as-taggable-array-on_test
|
14
15
|
script:
|
15
16
|
- bundle
|
16
17
|
- bundle exec rspec
|
18
|
+
matrix:
|
19
|
+
exclude:
|
20
|
+
- rvm: 2.0.0
|
21
|
+
gemfile: gemfiles/rails_5.gemfile
|
22
|
+
- rvm: 2.1.1
|
23
|
+
gemfile: gemfiles/rails_5.gemfile
|
24
|
+
- rvm: 2.1.2
|
25
|
+
gemfile: gemfiles/rails_5.gemfile
|
data/README.md
CHANGED
@@ -155,6 +155,60 @@ To handle the result tags named 'tag', prepend scopes.
|
|
155
155
|
User.where('tag like ?', 'aws%').all_tags { where name: ['ken', 'tom'] }
|
156
156
|
```
|
157
157
|
|
158
|
+
## Benchmark
|
159
|
+
Based on the [article](https://adamnengland.wordpress.com/2014/02/19/benchmarks-acts-as-taggable-on-vs-postgresql-arrays/), I built [simple benchmark app](https://github.com/tmiyamon/acts-as-taggable-benchmark/) to compare only the main features acts-as-taggable-array-on has.
|
160
|
+
|
161
|
+
This result does NOT insist acts-as-taggable-array-on is better than acts-as-taggable-on since it provides much more features than this gem.
|
162
|
+
In the case you need simple tag functionality, acts-as-taggable-array-on may be helpful to improve its performance.
|
163
|
+
|
164
|
+
```bash
|
165
|
+
% rake bench:write bench:find_by_id bench:find_by_tag
|
166
|
+
Deleted all ActsAsTaggableOn::Tag
|
167
|
+
Deleted all ActsAsTaggableOn::Tagging
|
168
|
+
Deleted all TaggableUser
|
169
|
+
Deleted all TaggableArrayUser
|
170
|
+
Finsihed to clean
|
171
|
+
|
172
|
+
|
173
|
+
###################################################################
|
174
|
+
|
175
|
+
bench:write
|
176
|
+
Rehearsal ---------------------------------------------------------
|
177
|
+
Using Taggable 6.950000 0.420000 7.370000 ( 9.223704)
|
178
|
+
Using Postgres Arrays 0.710000 0.090000 0.800000 ( 1.184734)
|
179
|
+
------------------------------------------------ total: 8.170000sec
|
180
|
+
|
181
|
+
user system total real
|
182
|
+
Using Taggable 5.800000 0.340000 6.140000 ( 7.842051)
|
183
|
+
Using Postgres Arrays 0.680000 0.090000 0.770000 ( 1.117812)
|
184
|
+
|
185
|
+
###################################################################
|
186
|
+
|
187
|
+
bench:find_by_id
|
188
|
+
Rehearsal ---------------------------------------------------------
|
189
|
+
Using Taggable 1.490000 0.110000 1.600000 ( 2.079776)
|
190
|
+
Using Postgres Arrays 0.240000 0.030000 0.270000 ( 0.419430)
|
191
|
+
------------------------------------------------ total: 1.870000sec
|
192
|
+
|
193
|
+
user system total real
|
194
|
+
Using Taggable 1.440000 0.100000 1.540000 ( 2.023188)
|
195
|
+
Using Postgres Arrays 0.250000 0.040000 0.290000 ( 0.434233)
|
196
|
+
|
197
|
+
###################################################################
|
198
|
+
|
199
|
+
bench:find_by_tag
|
200
|
+
Rehearsal ---------------------------------------------------------
|
201
|
+
Using Taggable 0.600000 0.040000 0.640000 ( 1.107227)
|
202
|
+
Using Postgres Arrays 0.060000 0.000000 0.060000 ( 0.060019)
|
203
|
+
------------------------------------------------ total: 0.700000sec
|
204
|
+
|
205
|
+
user system total real
|
206
|
+
Using Taggable 0.600000 0.040000 0.640000 ( 1.100302)
|
207
|
+
Using Postgres Arrays 0.030000 0.000000 0.030000 ( 0.033001)
|
208
|
+
rake bench:write bench:find_by_id bench:find_by_tag 20.29s user 1.52s system 77% cpu 28.322 total
|
209
|
+
```
|
210
|
+
|
211
|
+
|
158
212
|
## Contributing
|
159
213
|
|
160
214
|
1. Fork it ( http://github.com/tmiyamon/acts-as-taggable-array-on/fork )
|
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency 'activerecord', ['>= 4'
|
22
|
-
spec.add_runtime_dependency 'activesupport', ['>= 4'
|
21
|
+
spec.add_runtime_dependency 'activerecord', ['>= 4']
|
22
|
+
spec.add_runtime_dependency 'activesupport', ['>= 4']
|
23
23
|
|
24
24
|
spec.add_development_dependency 'pg'
|
25
25
|
|
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency "rake"
|
28
28
|
spec.add_development_dependency "rspec-rails"
|
29
29
|
spec.add_development_dependency "guard-rspec"
|
30
|
+
spec.add_development_dependency "listen", "~> 3.0.0"
|
30
31
|
end
|
@@ -16,7 +16,7 @@ module ActsAsTaggableArrayOn
|
|
16
16
|
|
17
17
|
self.class.class_eval do
|
18
18
|
define_method :"all_#{tag_name}" do |options = {}, &block|
|
19
|
-
subquery_scope = unscoped.select("unnest(#{table_name}.#{tag_name}) as tag").
|
19
|
+
subquery_scope = unscoped.select("unnest(#{table_name}.#{tag_name}) as tag").distinct
|
20
20
|
subquery_scope = subquery_scope.instance_eval(&block) if block
|
21
21
|
|
22
22
|
from(subquery_scope).pluck('tag')
|
data/spec/spec_helper.rb
CHANGED
@@ -16,7 +16,7 @@ class User < ActiveRecord::Base; end
|
|
16
16
|
RSpec.configure do |config|
|
17
17
|
config.before(:all) do
|
18
18
|
ActiveRecord::Base.establish_connection(
|
19
|
-
adapter: "postgresql",
|
19
|
+
adapter: "postgresql",
|
20
20
|
encoding: 'unicode',
|
21
21
|
database: "acts-as-taggable-array-on_test",
|
22
22
|
username: "acts-as-taggable-array-on"
|
@@ -37,8 +37,8 @@ def create_database
|
|
37
37
|
ActiveRecord::Schema.define(:version => 1) do
|
38
38
|
create_table :users do |t|
|
39
39
|
t.string :name
|
40
|
-
t.string :colors, array: true,
|
41
|
-
t.timestamps
|
40
|
+
t.string :colors, array: true, default: []
|
41
|
+
t.timestamps null: true
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts-as-taggable-array-on
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takuya Miyamoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -17,9 +17,6 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4'
|
20
|
-
- - "<"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '5'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,9 +24,6 @@ dependencies:
|
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '4'
|
30
|
-
- - "<"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '5'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: activesupport
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -37,9 +31,6 @@ dependencies:
|
|
37
31
|
- - ">="
|
38
32
|
- !ruby/object:Gem::Version
|
39
33
|
version: '4'
|
40
|
-
- - "<"
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '5'
|
43
34
|
type: :runtime
|
44
35
|
prerelease: false
|
45
36
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -47,9 +38,6 @@ dependencies:
|
|
47
38
|
- - ">="
|
48
39
|
- !ruby/object:Gem::Version
|
49
40
|
version: '4'
|
50
|
-
- - "<"
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: '5'
|
53
41
|
- !ruby/object:Gem::Dependency
|
54
42
|
name: pg
|
55
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,6 +108,20 @@ dependencies:
|
|
120
108
|
- - ">="
|
121
109
|
- !ruby/object:Gem::Version
|
122
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: listen
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 3.0.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 3.0.0
|
123
125
|
description: Simple tagging gem for Rails using postgres array.
|
124
126
|
email:
|
125
127
|
- miyamototakuya@gmail.com
|
@@ -135,6 +137,8 @@ files:
|
|
135
137
|
- README.md
|
136
138
|
- Rakefile
|
137
139
|
- acts-as-taggable-array-on.gemspec
|
140
|
+
- gemfiles/rails_4.gemfile
|
141
|
+
- gemfiles/rails_5.gemfile
|
138
142
|
- lib/acts-as-taggable-array-on.rb
|
139
143
|
- lib/acts-as-taggable-array-on/parser.rb
|
140
144
|
- lib/acts-as-taggable-array-on/taggable.rb
|
@@ -163,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
167
|
version: '0'
|
164
168
|
requirements: []
|
165
169
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.
|
170
|
+
rubygems_version: 2.5.1
|
167
171
|
signing_key:
|
168
172
|
specification_version: 4
|
169
173
|
summary: Simple tagging gem for Rails using postgres array.
|