rocket_tag 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -7
- data/VERSION +1 -1
- data/lib/rocket_tag/taggable.rb +1 -34
- data/rocket_tag.gemspec +1 -1
- data/spec/rocket_tag/taggable_spec.rb +7 -7
- metadata +2 -2
data/README.md
CHANGED
@@ -93,11 +93,6 @@ then the two below would not be identical.
|
|
93
93
|
model.tagged_similar :on => ["skills", "habits"]
|
94
94
|
model.tagged_similar
|
95
95
|
|
96
|
-
Find similar models based on tags on every context and return in decending order
|
97
|
-
of 'tags_count'. Note that each tag is still scoped according to it's context
|
98
|
-
|
99
|
-
model.tagged_similar
|
100
|
-
|
101
96
|
Find popular tags and generate tags clouds for specific scopes
|
102
97
|
|
103
98
|
User.where{email="bradphelan@xtargets.com"}.documents.popular_tags
|
@@ -117,7 +112,8 @@ and you can access the field *tags_count* on each Tag instance returned
|
|
117
112
|
by the above query. Generating the CSS and html for your tag cloud
|
118
113
|
is outside the scope of this project but it should be easy to do.
|
119
114
|
|
120
|
-
|
115
|
+
Contributing to rocket_tag
|
116
|
+
--------------------------
|
121
117
|
|
122
118
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
123
119
|
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
@@ -127,7 +123,8 @@ is outside the scope of this project but it should be easy to do.
|
|
127
123
|
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
128
124
|
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
129
125
|
|
130
|
-
|
126
|
+
Copyright
|
127
|
+
---------
|
131
128
|
|
132
129
|
Copyright (c) 2011 Brad Phelan. See LICENSE.txt for
|
133
130
|
further details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.5
|
data/lib/rocket_tag/taggable.rb
CHANGED
@@ -4,16 +4,6 @@ module Squeel
|
|
4
4
|
module ActiveRecord
|
5
5
|
module RelationExtensions
|
6
6
|
|
7
|
-
# The purpose of this call is to close a query and make
|
8
|
-
# it behave as a simple table or view. If a query has
|
9
|
-
# aggregate functions applied then downstream active
|
10
|
-
# relation chaining causes unpredictable behaviour.
|
11
|
-
#
|
12
|
-
# This call isolates the group by behaviours.
|
13
|
-
def isolate_group_by_as(type)
|
14
|
-
type.from(self.arel.as(type.table_name))
|
15
|
-
end
|
16
|
-
|
17
7
|
# We really only want to group on id for practical
|
18
8
|
# purposes but POSTGRES requires that a group by outputs
|
19
9
|
# all the column names not under an aggregate function.
|
@@ -33,7 +23,6 @@ module RocketTag
|
|
33
23
|
module Taggable
|
34
24
|
def self.included(base)
|
35
25
|
base.extend ClassMethods
|
36
|
-
#base.send :include, InstanceMethods
|
37
26
|
end
|
38
27
|
|
39
28
|
class Manager
|
@@ -135,28 +124,6 @@ module RocketTag
|
|
135
124
|
@rocket_tag ||= RocketTag::Taggable::Manager.new(self)
|
136
125
|
end
|
137
126
|
|
138
|
-
# Provides the tag counting functionality by adding an
|
139
|
-
# aggregate count on id. Assumes valid a join has been
|
140
|
-
# made.
|
141
|
-
#
|
142
|
-
# Note that I should be able to chain count tags to
|
143
|
-
# the relation instead of passing the rel parameter in
|
144
|
-
# however my tests fails with wrong counts. This is
|
145
|
-
# not so elegant
|
146
|
-
#
|
147
|
-
# rel can be passed as the last expression in a block
|
148
|
-
# if desired.
|
149
|
-
def tags_count(type=self)
|
150
|
-
if block_given?
|
151
|
-
rel = yield
|
152
|
-
end
|
153
|
-
rel.select('*').
|
154
|
-
select{count(~id).as(tags_count)}.
|
155
|
-
group_by_all_columns.
|
156
|
-
order("tags_count DESC").
|
157
|
-
isolate_group_by_as(type)
|
158
|
-
end
|
159
|
-
|
160
127
|
def is_valid_context? context
|
161
128
|
rocket_tag.contexts.include? context
|
162
129
|
end
|
@@ -278,7 +245,7 @@ module RocketTag
|
|
278
245
|
select('*').
|
279
246
|
order("tags_count desc")
|
280
247
|
|
281
|
-
# Isolate the aggregate
|
248
|
+
# Isolate the aggregate query by wrapping it as
|
282
249
|
#
|
283
250
|
# select * from ( ..... ) tags
|
284
251
|
q = RocketTag::Tag.from(q.arel.as(RocketTag::Tag.table_name))
|
data/rocket_tag.gemspec
CHANGED
@@ -358,13 +358,13 @@ describe TaggableModel do
|
|
358
358
|
|
359
359
|
describe "tag cloud calculations" do
|
360
360
|
it "should return tags on an association and the counts thereof" do
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
361
|
+
# @user0.taggable_models.popular_tags.each do |tag|
|
362
|
+
# puts "#{tag.name}\t#{tag.tags_count}"
|
363
|
+
# end
|
364
|
+
# puts "-------------"
|
365
|
+
# @user1.taggable_models.popular_tags.each do |tag|
|
366
|
+
# puts "#{tag.name}\t#{tag.tags_count}"
|
367
|
+
# end
|
368
368
|
|
369
369
|
# Check that the tags_count on each tag is in
|
370
370
|
# descending order.
|
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.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brad Phelan
|
@@ -144,7 +144,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
144
|
requirements:
|
145
145
|
- - ">="
|
146
146
|
- !ruby/object:Gem::Version
|
147
|
-
hash: -
|
147
|
+
hash: -401049524358643574
|
148
148
|
segments:
|
149
149
|
- 0
|
150
150
|
version: "0"
|