rocket_tag 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +3 -1
- data/VERSION +1 -1
- data/lib/rocket_tag/tag.rb +3 -0
- data/lib/rocket_tag/taggable.rb +11 -4
- data/rocket_tag.gemspec +5 -2
- data/spec/database.yml +4 -4
- data/spec/rocket_tag/taggable_spec.rb +2 -2
- metadata +26 -15
data/Gemfile
CHANGED
@@ -8,6 +8,7 @@ gem "squeel", '~> 1.0.0', :require => false
|
|
8
8
|
# Add dependencies to develop your gem here.
|
9
9
|
# Include everything needed to run rake, tests, features, etc.
|
10
10
|
group :development do
|
11
|
+
gem "pg"
|
11
12
|
gem "rspec", "~> 2.10.0"
|
12
13
|
gem "yard", "~> 0.6.0"
|
13
14
|
gem "bundler", "~> 1.1.0"
|
data/Gemfile.lock
CHANGED
@@ -22,6 +22,7 @@ GEM
|
|
22
22
|
git (>= 1.2.5)
|
23
23
|
rake
|
24
24
|
multi_json (1.3.6)
|
25
|
+
pg (0.14.0)
|
25
26
|
polyamorous (0.5.0)
|
26
27
|
activerecord (~> 3.0)
|
27
28
|
rake (0.9.2.2)
|
@@ -33,7 +34,7 @@ GEM
|
|
33
34
|
rspec-expectations (2.10.0)
|
34
35
|
diff-lcs (~> 1.1.3)
|
35
36
|
rspec-mocks (2.10.1)
|
36
|
-
sqlite3 (1.3.
|
37
|
+
sqlite3 (1.3.6)
|
37
38
|
squeel (1.0.6)
|
38
39
|
activerecord (~> 3.0)
|
39
40
|
activesupport (~> 3.0)
|
@@ -48,6 +49,7 @@ DEPENDENCIES
|
|
48
49
|
activerecord (>= 3.2.0)
|
49
50
|
bundler (~> 1.1.0)
|
50
51
|
jeweler (~> 1.6.4)
|
52
|
+
pg
|
51
53
|
rake
|
52
54
|
rspec (~> 2.10.0)
|
53
55
|
sqlite3
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.6
|
data/lib/rocket_tag/tag.rb
CHANGED
data/lib/rocket_tag/taggable.rb
CHANGED
@@ -70,6 +70,7 @@ module RocketTag
|
|
70
70
|
end
|
71
71
|
|
72
72
|
module InstanceMethods
|
73
|
+
|
73
74
|
def reload_with_tags(options = nil)
|
74
75
|
self.class.rocket_tag.contexts.each do |context|
|
75
76
|
write_context context, []
|
@@ -177,7 +178,7 @@ module RocketTag
|
|
177
178
|
def tagged_with tags_list, options = {}
|
178
179
|
|
179
180
|
# Grab table name
|
180
|
-
t = self.
|
181
|
+
t = self.table_name
|
181
182
|
|
182
183
|
q = joins{taggings.tag}
|
183
184
|
|
@@ -203,8 +204,8 @@ module RocketTag
|
|
203
204
|
end
|
204
205
|
|
205
206
|
q = q.group_by_all_columns.
|
206
|
-
select{count(tags.id).as(tags_count)}.
|
207
|
-
select
|
207
|
+
select{count(tags.id).as( tags_count)}.
|
208
|
+
select{"#{t}.*"}.
|
208
209
|
order("tags_count desc")
|
209
210
|
|
210
211
|
# Isolate the aggregate uery by wrapping it as
|
@@ -242,7 +243,7 @@ module RocketTag
|
|
242
243
|
where(with_tag_context(options.delete(:on))). # Restrict by context
|
243
244
|
group_by_all_columns.
|
244
245
|
select{count(tags.id).as(tags_count)}.
|
245
|
-
select('
|
246
|
+
select('tags.*').
|
246
247
|
order("tags_count desc")
|
247
248
|
|
248
249
|
# Isolate the aggregate query by wrapping it as
|
@@ -342,6 +343,12 @@ module RocketTag
|
|
342
343
|
end
|
343
344
|
end
|
344
345
|
|
346
|
+
# This is to compensate for a rails bug that returns
|
347
|
+
# a string for postgres
|
348
|
+
def tags_count
|
349
|
+
self[:tags_count].to_i
|
350
|
+
end
|
351
|
+
|
345
352
|
# Return an array of RocketTag::Tags for the context
|
346
353
|
define_method "#{context}" do
|
347
354
|
cache_tags
|
data/rocket_tag.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "rocket_tag"
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brad Phelan"]
|
12
|
-
s.date = "2012-07-
|
12
|
+
s.date = "2012-07-11"
|
13
13
|
s.description = ""
|
14
14
|
s.email = "bradphelan@xtargets.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -51,6 +51,7 @@ Gem::Specification.new do |s|
|
|
51
51
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
52
|
s.add_runtime_dependency(%q<activerecord>, [">= 3.2.0"])
|
53
53
|
s.add_runtime_dependency(%q<squeel>, ["~> 1.0.0"])
|
54
|
+
s.add_development_dependency(%q<pg>, [">= 0"])
|
54
55
|
s.add_development_dependency(%q<rspec>, ["~> 2.10.0"])
|
55
56
|
s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
|
56
57
|
s.add_development_dependency(%q<bundler>, ["~> 1.1.0"])
|
@@ -60,6 +61,7 @@ Gem::Specification.new do |s|
|
|
60
61
|
else
|
61
62
|
s.add_dependency(%q<activerecord>, [">= 3.2.0"])
|
62
63
|
s.add_dependency(%q<squeel>, ["~> 1.0.0"])
|
64
|
+
s.add_dependency(%q<pg>, [">= 0"])
|
63
65
|
s.add_dependency(%q<rspec>, ["~> 2.10.0"])
|
64
66
|
s.add_dependency(%q<yard>, ["~> 0.6.0"])
|
65
67
|
s.add_dependency(%q<bundler>, ["~> 1.1.0"])
|
@@ -70,6 +72,7 @@ Gem::Specification.new do |s|
|
|
70
72
|
else
|
71
73
|
s.add_dependency(%q<activerecord>, [">= 3.2.0"])
|
72
74
|
s.add_dependency(%q<squeel>, ["~> 1.0.0"])
|
75
|
+
s.add_dependency(%q<pg>, [">= 0"])
|
73
76
|
s.add_dependency(%q<rspec>, ["~> 2.10.0"])
|
74
77
|
s.add_dependency(%q<yard>, ["~> 0.6.0"])
|
75
78
|
s.add_dependency(%q<bundler>, ["~> 1.1.0"])
|
data/spec/database.yml
CHANGED
@@ -5,15 +5,15 @@ sqlite3:
|
|
5
5
|
mysql:
|
6
6
|
adapter: mysql2
|
7
7
|
hostname: localhost
|
8
|
-
username:
|
8
|
+
username: rails
|
9
9
|
password:
|
10
|
-
database:
|
10
|
+
database: rocket_tag
|
11
11
|
charset: utf8
|
12
12
|
|
13
13
|
postgresql:
|
14
14
|
adapter: postgresql
|
15
15
|
hostname: localhost
|
16
|
-
username:
|
16
|
+
username: rails
|
17
17
|
password:
|
18
|
-
database:
|
18
|
+
database: rocket_tag
|
19
19
|
encoding: utf8
|
@@ -31,7 +31,7 @@ describe TaggableModel do
|
|
31
31
|
@model.languages = ["x", "y"]
|
32
32
|
@model.save
|
33
33
|
@model.reload
|
34
|
-
@model.languages.should == ["x", "y"]
|
34
|
+
@model.languages.sort.should == ["x", "y"]
|
35
35
|
end
|
36
36
|
|
37
37
|
it "validates the model wrt to the context" do
|
@@ -206,7 +206,7 @@ describe TaggableModel do
|
|
206
206
|
similar[2].tags_count.should == 1
|
207
207
|
|
208
208
|
# ----
|
209
|
-
similar = @t00.tagged_similar(:on => :languages).all
|
209
|
+
similar = @t00.tagged_similar(:on => :languages).all.sort
|
210
210
|
similar[0].id.should == @t01.id
|
211
211
|
similar[1].id.should == @t10.id
|
212
212
|
similar[2].id.should == @t21.id
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rocket_tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brad Phelan
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-07-
|
13
|
+
date: 2012-07-11 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|
@@ -35,8 +35,19 @@ dependencies:
|
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: *id002
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
38
|
+
name: pg
|
39
39
|
requirement: &id003 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rspec
|
50
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
40
51
|
none: false
|
41
52
|
requirements:
|
42
53
|
- - ~>
|
@@ -44,10 +55,10 @@ dependencies:
|
|
44
55
|
version: 2.10.0
|
45
56
|
type: :development
|
46
57
|
prerelease: false
|
47
|
-
version_requirements: *
|
58
|
+
version_requirements: *id004
|
48
59
|
- !ruby/object:Gem::Dependency
|
49
60
|
name: yard
|
50
|
-
requirement: &
|
61
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
51
62
|
none: false
|
52
63
|
requirements:
|
53
64
|
- - ~>
|
@@ -55,10 +66,10 @@ dependencies:
|
|
55
66
|
version: 0.6.0
|
56
67
|
type: :development
|
57
68
|
prerelease: false
|
58
|
-
version_requirements: *
|
69
|
+
version_requirements: *id005
|
59
70
|
- !ruby/object:Gem::Dependency
|
60
71
|
name: bundler
|
61
|
-
requirement: &
|
72
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
62
73
|
none: false
|
63
74
|
requirements:
|
64
75
|
- - ~>
|
@@ -66,10 +77,10 @@ dependencies:
|
|
66
77
|
version: 1.1.0
|
67
78
|
type: :development
|
68
79
|
prerelease: false
|
69
|
-
version_requirements: *
|
80
|
+
version_requirements: *id006
|
70
81
|
- !ruby/object:Gem::Dependency
|
71
82
|
name: jeweler
|
72
|
-
requirement: &
|
83
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
73
84
|
none: false
|
74
85
|
requirements:
|
75
86
|
- - ~>
|
@@ -77,10 +88,10 @@ dependencies:
|
|
77
88
|
version: 1.6.4
|
78
89
|
type: :development
|
79
90
|
prerelease: false
|
80
|
-
version_requirements: *
|
91
|
+
version_requirements: *id007
|
81
92
|
- !ruby/object:Gem::Dependency
|
82
93
|
name: sqlite3
|
83
|
-
requirement: &
|
94
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
84
95
|
none: false
|
85
96
|
requirements:
|
86
97
|
- - ">="
|
@@ -88,10 +99,10 @@ dependencies:
|
|
88
99
|
version: "0"
|
89
100
|
type: :development
|
90
101
|
prerelease: false
|
91
|
-
version_requirements: *
|
102
|
+
version_requirements: *id008
|
92
103
|
- !ruby/object:Gem::Dependency
|
93
104
|
name: rake
|
94
|
-
requirement: &
|
105
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
95
106
|
none: false
|
96
107
|
requirements:
|
97
108
|
- - ">="
|
@@ -99,7 +110,7 @@ dependencies:
|
|
99
110
|
version: "0"
|
100
111
|
type: :development
|
101
112
|
prerelease: false
|
102
|
-
version_requirements: *
|
113
|
+
version_requirements: *id009
|
103
114
|
description: ""
|
104
115
|
email: bradphelan@xtargets.com
|
105
116
|
executables: []
|
@@ -144,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
155
|
requirements:
|
145
156
|
- - ">="
|
146
157
|
- !ruby/object:Gem::Version
|
147
|
-
hash: -
|
158
|
+
hash: -669736319260482617
|
148
159
|
segments:
|
149
160
|
- 0
|
150
161
|
version: "0"
|