taxonomy 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +28 -0
- data/Rakefile +31 -0
- data/lib/generators/taxonomy/migration/migration_generator.rb +39 -0
- data/lib/generators/taxonomy/migration/templates/active_record/migration.rb +36 -0
- data/lib/tasks/taxonomy_tasks.rake +4 -0
- data/lib/taxonomy.rb +25 -0
- data/lib/taxonomy/group_helper.rb +12 -0
- data/lib/taxonomy/has_tagger.rb +52 -0
- data/lib/taxonomy/has_taxonomy.rb +502 -0
- data/lib/taxonomy/tag.rb +485 -0
- data/lib/taxonomy/tag_list.rb +97 -0
- data/lib/taxonomy/tagging.rb +12 -0
- data/lib/taxonomy/tags_helper.rb +13 -0
- data/lib/taxonomy/version.rb +3 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/altered_inheriting_taggable_model.rb +3 -0
- data/spec/dummy/app/models/inheriting_taggable_model.rb +2 -0
- data/spec/dummy/app/models/other_taggable_model.rb +4 -0
- data/spec/dummy/app/models/post.rb +2 -0
- data/spec/dummy/app/models/taggable_model.rb +6 -0
- data/spec/dummy/app/models/taggable_user.rb +3 -0
- data/spec/dummy/app/models/treed_model.rb +3 -0
- data/spec/dummy/app/models/untaggable_model.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +19 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +30 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/db/migrate/20111221004133_create_posts.rb +8 -0
- data/spec/dummy/db/migrate/20111221023928_taxonomy_migration.rb +35 -0
- data/spec/dummy/db/migrate/20111221024100_create_bulk.rb +18 -0
- data/spec/dummy/db/schema.rb +65 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +100915 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/posts.rb +6 -0
- data/spec/generators/taxonomy/migration/migration_generator_spec.rb +22 -0
- data/spec/models/post_spec.rb +5 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/taxonomy/group_helper_spec.rb +21 -0
- data/spec/taxonomy/has_tagger_spec.rb +113 -0
- data/spec/taxonomy/has_taxonomy_spec.rb +226 -0
- data/spec/taxonomy/tag_list_spec.rb +70 -0
- data/spec/taxonomy/tag_spec.rb +462 -0
- data/spec/taxonomy/taggable_spec.rb +262 -0
- data/spec/taxonomy/tagger_spec.rb +40 -0
- data/spec/taxonomy/tagging_spec.rb +25 -0
- data/spec/taxonomy/tags_helper_spec.rb +29 -0
- metadata +225 -0
@@ -0,0 +1,262 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "Taggable" do
|
4
|
+
before(:each) do
|
5
|
+
# clean_database!
|
6
|
+
@taggable = TaggableModel.new(:name => "Bob Jones")
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should have tag types" do
|
10
|
+
for type in [:tags, :languages, :skills, :needs, :offerings]
|
11
|
+
TaggableModel.tag_types.should include type.to_s
|
12
|
+
end
|
13
|
+
@taggable.tag_types.should == TaggableModel.tag_types
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have tag_counts_on" do
|
17
|
+
TaggableModel.tag_counts_on(:tags).should be_empty
|
18
|
+
|
19
|
+
@taggable.tag_list = ["awesome", "epic"]
|
20
|
+
@taggable.save
|
21
|
+
|
22
|
+
TaggableModel.tag_counts_on(:tags).length.should == 2
|
23
|
+
@taggable.tag_counts_on(:tags).length.should == 2
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should be able to create tags" do
|
27
|
+
@taggable.skill_list = "ruby, rails, css"
|
28
|
+
@taggable.instance_variable_get("@skill_list").instance_of?(Hash).should be_true
|
29
|
+
@taggable.instance_variable_get("@skill_list")[nil].instance_of?(TagList).should be_true
|
30
|
+
@taggable.save
|
31
|
+
|
32
|
+
Tag.find(:all).size.should == 3
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should be able to create tags through the tag list directly" do
|
36
|
+
@taggable.tag_list_on(:test).add("hello")
|
37
|
+
@taggable.tag_list_cache_on(:test).should_not be_empty
|
38
|
+
@taggable.save
|
39
|
+
@taggable.save_tags
|
40
|
+
@taggable.reload
|
41
|
+
@taggable.tag_list_on(:test).should == ["hello"]
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should differentiate between contexts" do
|
45
|
+
@taggable.skill_list = "ruby, rails, css"
|
46
|
+
@taggable.tag_list = "ruby, bob, charlie"
|
47
|
+
@taggable.save
|
48
|
+
@taggable.reload
|
49
|
+
@taggable.skill_list.should include("ruby")
|
50
|
+
@taggable.skill_list.should_not include("bob")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should be able to remove tags through list alone" do
|
54
|
+
@taggable.skill_list = "ruby, rails, css"
|
55
|
+
@taggable.save
|
56
|
+
@taggable.reload
|
57
|
+
@taggable.should have(3).skills
|
58
|
+
@taggable.skill_list = "ruby, rails"
|
59
|
+
@taggable.save
|
60
|
+
@taggable.reload
|
61
|
+
@taggable.should have(2).skills
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should be able to find by tag" do
|
65
|
+
@taggable.skill_list = "ruby, rails, css"
|
66
|
+
@taggable.save
|
67
|
+
TaggableModel.find_tagged_with("skill", "ruby").first.should == @taggable
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should be able to find by tag with context" do
|
71
|
+
@taggable.skill_list = "ruby, rails, css"
|
72
|
+
@taggable.tag_list = "bob, charlie"
|
73
|
+
@taggable.save
|
74
|
+
|
75
|
+
TaggableModel.find_tagged_with("skill", "ruby").first.should == @taggable
|
76
|
+
TaggableModel.find_tagged_with("skills", "bob").first.should_not == @taggable
|
77
|
+
TaggableModel.find_tagged_with("tags", "bob").first.should == @taggable
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should be able to use the tagged_with named scope" do
|
81
|
+
@taggable.skill_list = "ruby, rails, css"
|
82
|
+
@taggable.tag_list = "bob, charlie"
|
83
|
+
@taggable.save
|
84
|
+
|
85
|
+
TaggableModel.tagged_with("ruby", :on => :skills).first.should == @taggable
|
86
|
+
TaggableModel.tagged_with("ruby, css", :on => :skills).first.should == @taggable
|
87
|
+
TaggableModel.tagged_with("ruby, nonexistingtag", :on => :skills).should be_empty
|
88
|
+
TaggableModel.tagged_with("bob", :on => :skills).first.should_not == @taggable
|
89
|
+
TaggableModel.tagged_with("bob", :on => :tags).first.should == @taggable
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should not care about case" do
|
93
|
+
bob = TaggableModel.create(:name => "Bob", :tag_list => "ruby")
|
94
|
+
frank = TaggableModel.create(:name => "Frank", :tag_list => "Ruby")
|
95
|
+
|
96
|
+
Tag.find(:all).size.should == 1
|
97
|
+
TaggableModel.find_tagged_with("tag", "ruby").should == TaggableModel.find_tagged_with("tag", "Ruby")
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should be able to get tag counts on model as a whole" do
|
101
|
+
bob = TaggableModel.create(:name => "Bob", :tag_list => "ruby, rails, css")
|
102
|
+
frank = TaggableModel.create(:name => "Frank", :tag_list => "ruby, rails")
|
103
|
+
charlie = TaggableModel.create(:name => "Charlie", :skill_list => "ruby")
|
104
|
+
TaggableModel.tag_counts.should_not be_empty
|
105
|
+
TaggableModel.skill_counts.should_not be_empty
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should be able to get all tag counts on model as whole" do
|
109
|
+
bob = TaggableModel.create(:name => "Bob", :tag_list => "ruby, rails, css")
|
110
|
+
frank = TaggableModel.create(:name => "Frank", :tag_list => "ruby, rails")
|
111
|
+
charlie = TaggableModel.create(:name => "Charlie", :skill_list => "ruby")
|
112
|
+
|
113
|
+
TaggableModel.all_tag_counts.should_not be_empty
|
114
|
+
TaggableModel.all_tag_counts[2].count.should == 3 # ruby
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should not return read-only records" do
|
118
|
+
TaggableModel.create(:name => "Bob", :tag_list => "ruby, rails, css")
|
119
|
+
|
120
|
+
TaggableModel.tagged_with("ruby", :on => :tags).first.should_not be_readonly
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should be able to get scoped tag counts" do
|
124
|
+
bob = TaggableModel.create(:name => "Bob", :tag_list => "ruby, rails, css")
|
125
|
+
frank = TaggableModel.create(:name => "Frank", :tag_list => "ruby, rails")
|
126
|
+
charlie = TaggableModel.create(:name => "Charlie", :skill_list => "ruby")
|
127
|
+
|
128
|
+
TaggableModel.tagged_with("ruby").tag_counts[2].count.should == 2 # ruby
|
129
|
+
TaggableModel.tagged_with("ruby").skill_counts.first.count.should == 1 # ruby
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should be able to get all scoped tag counts" do
|
133
|
+
bob = TaggableModel.create(:name => "Bob", :tag_list => "ruby, rails, css")
|
134
|
+
frank = TaggableModel.create(:name => "Frank", :tag_list => "ruby, rails")
|
135
|
+
charlie = TaggableModel.create(:name => "Charlie", :skill_list => "ruby")
|
136
|
+
|
137
|
+
TaggableModel.tagged_with("ruby").all_tag_counts[2].count.should == 3 # ruby
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should be able to set a custom tag context list" do
|
141
|
+
bob = TaggableModel.create(:name => "Bob")
|
142
|
+
bob.set_tag_list_on(:rotors, "spinning, jumping")
|
143
|
+
bob.tag_list_on(:rotors).should == ["spinning","jumping"]
|
144
|
+
bob.save
|
145
|
+
bob.reload
|
146
|
+
bob.tags_on(:rotors).should_not be_empty
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should be able to find tagged" do
|
150
|
+
bob = TaggableModel.create(:name => "Bob", :tag_list => "fitter, happier, more productive", :skill_list => "ruby, rails, css")
|
151
|
+
frank = TaggableModel.create(:name => "Frank", :tag_list => "weaker, depressed, inefficient", :skill_list => "ruby, rails, css")
|
152
|
+
steve = TaggableModel.create(:name => 'Steve', :tag_list => 'fitter, happier, more productive', :skill_list => 'c++, java, ruby')
|
153
|
+
|
154
|
+
TaggableModel.find_tagged_with("skill", "ruby", :order => 'taggable_models.name').should == [bob, frank, steve]
|
155
|
+
TaggableModel.find_tagged_with("skill", "ruby, rails", :order => 'taggable_models.name').should == [bob, frank]
|
156
|
+
TaggableModel.find_tagged_with("skill", ["ruby", "rails"], :order => 'taggable_models.name').should == [bob, frank]
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should be able to find tagged with any tag" do
|
160
|
+
bob = TaggableModel.create(:name => "Bob", :tag_list => "fitter, happier, more productive", :skill_list => "ruby, rails, css")
|
161
|
+
frank = TaggableModel.create(:name => "Frank", :tag_list => "weaker, depressed, inefficient", :skill_list => "ruby, rails, css")
|
162
|
+
steve = TaggableModel.create(:name => 'Steve', :tag_list => 'fitter, happier, more productive', :skill_list => 'c++, java, ruby')
|
163
|
+
|
164
|
+
TaggableModel.find_tagged_with("tag", ["ruby", "java"], :order => 'taggable_models.name', :any => true).should == [bob, frank, steve]
|
165
|
+
TaggableModel.find_tagged_with("tag", ["c++", "fitter"], :order => 'taggable_models.name', :any => true).should == [bob, steve]
|
166
|
+
TaggableModel.find_tagged_with("tag", ["depressed", "css"], :order => 'taggable_models.name', :any => true).should == [bob, frank]
|
167
|
+
end
|
168
|
+
|
169
|
+
it "should be able to find tagged on a custom tag context" do
|
170
|
+
bob = TaggableModel.create(:name => "Bob")
|
171
|
+
bob.set_tag_list_on(:rotors, "spinning, jumping")
|
172
|
+
bob.tag_list_on(:rotors).should == ["spinning","jumping"]
|
173
|
+
bob.save
|
174
|
+
TaggableModel.find_tagged_with("rotors", "spinning").should == [bob]
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should be able to use named scopes to chain tag finds" do
|
178
|
+
bob = TaggableModel.create(:name => "Bob", :tag_list => "fitter, happier, more productive", :skill_list => "ruby, rails, css")
|
179
|
+
frank = TaggableModel.create(:name => "Frank", :tag_list => "weaker, depressed, inefficient", :skill_list => "ruby, rails, css")
|
180
|
+
steve = TaggableModel.create(:name => 'Steve', :tag_list => 'fitter, happier, more productive', :skill_list => 'c++, java, python')
|
181
|
+
|
182
|
+
# Let's only find those productive Rails developers
|
183
|
+
TaggableModel.tagged_with('rails', :on => :skills, :order => 'taggable_models.name').all.should == [bob, frank]
|
184
|
+
TaggableModel.tagged_with('happier', :on => :tags, :order => 'taggable_models.name').all.should == [bob, steve]
|
185
|
+
TaggableModel.tagged_with('rails', :on => :skills).tagged_with('happier', :on => :tags).should == [bob]
|
186
|
+
TaggableModel.tagged_with('rails', :on => :skills).tagged_with('happier', :on => :tags).should == [bob]
|
187
|
+
end
|
188
|
+
|
189
|
+
it "should be able to find tagged with only the matching tags" do
|
190
|
+
bob = TaggableModel.create(:name => "Bob", :tag_list => "lazy, happier")
|
191
|
+
frank = TaggableModel.create(:name => "Frank", :tag_list => "fitter, happier, inefficient")
|
192
|
+
steve = TaggableModel.create(:name => 'Steve', :tag_list => "fitter, happier")
|
193
|
+
|
194
|
+
TaggableModel.find_tagged_with("tags", "fitter, happier", :match_all => true).should == [steve]
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should be able to find tagged with some excluded tags" do
|
198
|
+
bob = TaggableModel.create(:name => "Bob", :tag_list => "happier, lazy")
|
199
|
+
frank = TaggableModel.create(:name => "Frank", :tag_list => "happier")
|
200
|
+
steve = TaggableModel.create(:name => 'Steve', :tag_list => "happier")
|
201
|
+
|
202
|
+
TaggableModel.find_tagged_with("tags", "lazy", :exclude => true).should == [frank, steve]
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should not create duplicate taggings" do
|
206
|
+
bob = TaggableModel.create(:name => "Bob")
|
207
|
+
lambda {
|
208
|
+
bob.tag_list << "happier"
|
209
|
+
bob.tag_list << "happier"
|
210
|
+
bob.save
|
211
|
+
}.should change(Tagging, :count).by(1)
|
212
|
+
end
|
213
|
+
|
214
|
+
describe "Single Table Inheritance" do
|
215
|
+
before do
|
216
|
+
[TaggableModel, Tag, Tagging, TaggableUser].each(&:delete_all)
|
217
|
+
@taggable = TaggableModel.new(:name => "taggable")
|
218
|
+
@inherited_same = InheritingTaggableModel.new(:name => "inherited same")
|
219
|
+
@inherited_different = AlteredInheritingTaggableModel.new(:name => "inherited different")
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should be able to save tags for inherited models" do
|
223
|
+
@inherited_same.tag_list = "bob, kelso"
|
224
|
+
@inherited_same.save
|
225
|
+
InheritingTaggableModel.find_tagged_with("tag", "bob").first.should == @inherited_same
|
226
|
+
end
|
227
|
+
|
228
|
+
it "should find STI tagged models on the superclass" do
|
229
|
+
@inherited_same.tag_list = "bob, kelso"
|
230
|
+
@inherited_same.save
|
231
|
+
TaggableModel.find_tagged_with("tag", "bob").first.should == @inherited_same
|
232
|
+
end
|
233
|
+
|
234
|
+
it "should be able to add on contexts only to some subclasses" do
|
235
|
+
@inherited_different.part_list = "fork, spoon"
|
236
|
+
@inherited_different.save
|
237
|
+
InheritingTaggableModel.find_tagged_with("parts", "fork").should be_empty
|
238
|
+
AlteredInheritingTaggableModel.find_tagged_with("parts", "fork").first.should == @inherited_different
|
239
|
+
end
|
240
|
+
|
241
|
+
it "should have different tag_counts_on for inherited models" do
|
242
|
+
@inherited_same.tag_list = "bob, kelso"
|
243
|
+
@inherited_same.save!
|
244
|
+
@inherited_different.tag_list = "fork, spoon"
|
245
|
+
@inherited_different.save!
|
246
|
+
|
247
|
+
InheritingTaggableModel.tag_counts_on(:tags).map(&:name).should == %w(bob kelso)
|
248
|
+
AlteredInheritingTaggableModel.tag_counts_on(:tags).map(&:name).should == %w(fork spoon)
|
249
|
+
TaggableModel.tag_counts_on(:tags).map(&:name).should == %w(bob fork kelso spoon)
|
250
|
+
end
|
251
|
+
|
252
|
+
it 'should store same tag without validation conflict' do
|
253
|
+
@taggable.tag_list = 'one'
|
254
|
+
@taggable.save!
|
255
|
+
|
256
|
+
@inherited_same.tag_list = 'one'
|
257
|
+
@inherited_same.save!
|
258
|
+
|
259
|
+
@inherited_same.update_attributes! :name => 'foo'
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "Tagger" do
|
4
|
+
before(:each) do
|
5
|
+
# clean_database!
|
6
|
+
@user = TaggableUser.new
|
7
|
+
@taggable = TaggableModel.new(:name => "Bob Jones")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have taggings" do
|
11
|
+
@user.tag(@taggable, :with=>'ruby,scheme', :on=>:tags)
|
12
|
+
@user.owned_taggings.size == 2
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have tags" do
|
16
|
+
@user.tag(@taggable, :with=>'ruby,scheme', :on=>:tags)
|
17
|
+
@user.owned_tags.size == 2
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should not overlap or lose tags from different users" do
|
21
|
+
@user2 = TaggableUser.new
|
22
|
+
lambda{
|
23
|
+
@user.tag(@taggable, :with => 'ruby, scheme', :on => :tags)
|
24
|
+
@user2.tag(@taggable, :with => 'java, python, lisp, ruby', :on => :tags)
|
25
|
+
}.should change(Tagging, :count).by(6)
|
26
|
+
|
27
|
+
@user.owned_tags.map(&:name).sort.should == %w(ruby scheme).sort
|
28
|
+
@user2.owned_tags.map(&:name).sort.should == %w(java python lisp ruby).sort
|
29
|
+
|
30
|
+
@taggable.tags_from(@user).sort.should == %w(ruby scheme).sort
|
31
|
+
@taggable.tags_from(@user2).sort.should == %w(java lisp python ruby).sort
|
32
|
+
|
33
|
+
@taggable.all_tags_list_on(:tags).sort.should == %w(ruby scheme java python lisp).sort
|
34
|
+
@taggable.all_tags_on(:tags).size.should == 6
|
35
|
+
end
|
36
|
+
|
37
|
+
it "is tagger" do
|
38
|
+
@user.is_tagger?.should(be_true)
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Tagging do
|
4
|
+
before(:each) do
|
5
|
+
# clean_database!
|
6
|
+
@tagging = Tagging.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should not be valid with a invalid tag" do
|
10
|
+
@tagging.taggable = TaggableModel.create(:name => "Bob Jones")
|
11
|
+
@tagging.tag = Tag.new(:context => "languages", :name => "")
|
12
|
+
|
13
|
+
@tagging.should_not be_valid
|
14
|
+
@tagging.errors[:tag_id].should == ["can't be blank"]
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should not create duplicate taggings" do
|
18
|
+
@taggable = TaggableModel.create(:name => "Bob Jones")
|
19
|
+
@tag = Tag.create(:context => "lanugages", :name => "awesome")
|
20
|
+
|
21
|
+
lambda {
|
22
|
+
2.times { Tagging.create(:taggable => @taggable, :tag => @tag) }
|
23
|
+
}.should change(Tagging, :count).by(1)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe TagsHelper do
|
4
|
+
before(:each) do
|
5
|
+
# clean_database!
|
6
|
+
|
7
|
+
@bob = TaggableModel.create(:name => "Bob Jones", :language_list => "ruby, php")
|
8
|
+
@tom = TaggableModel.create(:name => "Tom Marley", :language_list => "ruby, java")
|
9
|
+
@eve = TaggableModel.create(:name => "Eve Nodd", :language_list => "ruby, c++")
|
10
|
+
|
11
|
+
@helper = class Helper
|
12
|
+
include TagsHelper
|
13
|
+
end.new
|
14
|
+
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should yield the proper css classes" do
|
19
|
+
tags = { }
|
20
|
+
@helper.tag_cloud(TaggableModel.tag_counts_on(:languages), ["sucky", "awesome"]) do |tag, css_class|
|
21
|
+
tags[tag.name] = css_class
|
22
|
+
end
|
23
|
+
|
24
|
+
tags["ruby"].should == "awesome"
|
25
|
+
tags["java"].should == "sucky"
|
26
|
+
tags["c++"].should == "sucky"
|
27
|
+
tags["php"].should == "sucky"
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,225 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: taxonomy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Seth Faxon
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-02 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: &70337632109920 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70337632109920
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: sqlite3
|
27
|
+
requirement: &70337632109080 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.3.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70337632109080
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec-rails
|
38
|
+
requirement: &70337632108340 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.7.0
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70337632108340
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: ammeter
|
49
|
+
requirement: &70337632107260 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.2.1
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70337632107260
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: factory_girl_rails
|
60
|
+
requirement: &70337632106240 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.4.0
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70337632106240
|
69
|
+
description: tagging with namespace and tree.
|
70
|
+
email:
|
71
|
+
- seth.faxon@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- lib/generators/taxonomy/migration/migration_generator.rb
|
77
|
+
- lib/generators/taxonomy/migration/templates/active_record/migration.rb
|
78
|
+
- lib/tasks/taxonomy_tasks.rake
|
79
|
+
- lib/taxonomy/group_helper.rb
|
80
|
+
- lib/taxonomy/has_tagger.rb
|
81
|
+
- lib/taxonomy/has_taxonomy.rb
|
82
|
+
- lib/taxonomy/tag.rb
|
83
|
+
- lib/taxonomy/tag_list.rb
|
84
|
+
- lib/taxonomy/tagging.rb
|
85
|
+
- lib/taxonomy/tags_helper.rb
|
86
|
+
- lib/taxonomy/version.rb
|
87
|
+
- lib/taxonomy.rb
|
88
|
+
- MIT-LICENSE
|
89
|
+
- Rakefile
|
90
|
+
- README.rdoc
|
91
|
+
- spec/dummy/app/controllers/application_controller.rb
|
92
|
+
- spec/dummy/app/helpers/application_helper.rb
|
93
|
+
- spec/dummy/app/models/altered_inheriting_taggable_model.rb
|
94
|
+
- spec/dummy/app/models/inheriting_taggable_model.rb
|
95
|
+
- spec/dummy/app/models/other_taggable_model.rb
|
96
|
+
- spec/dummy/app/models/post.rb
|
97
|
+
- spec/dummy/app/models/taggable_model.rb
|
98
|
+
- spec/dummy/app/models/taggable_user.rb
|
99
|
+
- spec/dummy/app/models/treed_model.rb
|
100
|
+
- spec/dummy/app/models/untaggable_model.rb
|
101
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
102
|
+
- spec/dummy/config/application.rb
|
103
|
+
- spec/dummy/config/boot.rb
|
104
|
+
- spec/dummy/config/database.yml
|
105
|
+
- spec/dummy/config/environment.rb
|
106
|
+
- spec/dummy/config/environments/development.rb
|
107
|
+
- spec/dummy/config/environments/production.rb
|
108
|
+
- spec/dummy/config/environments/test.rb
|
109
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
110
|
+
- spec/dummy/config/initializers/inflections.rb
|
111
|
+
- spec/dummy/config/initializers/mime_types.rb
|
112
|
+
- spec/dummy/config/initializers/secret_token.rb
|
113
|
+
- spec/dummy/config/initializers/session_store.rb
|
114
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
115
|
+
- spec/dummy/config/locales/en.yml
|
116
|
+
- spec/dummy/config/routes.rb
|
117
|
+
- spec/dummy/config.ru
|
118
|
+
- spec/dummy/db/migrate/20111221004133_create_posts.rb
|
119
|
+
- spec/dummy/db/migrate/20111221023928_taxonomy_migration.rb
|
120
|
+
- spec/dummy/db/migrate/20111221024100_create_bulk.rb
|
121
|
+
- spec/dummy/db/schema.rb
|
122
|
+
- spec/dummy/db/test.sqlite3
|
123
|
+
- spec/dummy/log/test.log
|
124
|
+
- spec/dummy/public/404.html
|
125
|
+
- spec/dummy/public/422.html
|
126
|
+
- spec/dummy/public/500.html
|
127
|
+
- spec/dummy/public/favicon.ico
|
128
|
+
- spec/dummy/Rakefile
|
129
|
+
- spec/dummy/script/rails
|
130
|
+
- spec/factories/posts.rb
|
131
|
+
- spec/generators/taxonomy/migration/migration_generator_spec.rb
|
132
|
+
- spec/models/post_spec.rb
|
133
|
+
- spec/spec_helper.rb
|
134
|
+
- spec/taxonomy/group_helper_spec.rb
|
135
|
+
- spec/taxonomy/has_tagger_spec.rb
|
136
|
+
- spec/taxonomy/has_taxonomy_spec.rb
|
137
|
+
- spec/taxonomy/tag_list_spec.rb
|
138
|
+
- spec/taxonomy/tag_spec.rb
|
139
|
+
- spec/taxonomy/taggable_spec.rb
|
140
|
+
- spec/taxonomy/tagger_spec.rb
|
141
|
+
- spec/taxonomy/tagging_spec.rb
|
142
|
+
- spec/taxonomy/tags_helper_spec.rb
|
143
|
+
homepage: https://github.com/marshill/taxonomy
|
144
|
+
licenses: []
|
145
|
+
post_install_message:
|
146
|
+
rdoc_options: []
|
147
|
+
require_paths:
|
148
|
+
- lib
|
149
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
151
|
+
requirements:
|
152
|
+
- - ! '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
segments:
|
156
|
+
- 0
|
157
|
+
hash: 1664297091458026064
|
158
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
160
|
+
requirements:
|
161
|
+
- - ! '>='
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
segments:
|
165
|
+
- 0
|
166
|
+
hash: 1664297091458026064
|
167
|
+
requirements: []
|
168
|
+
rubyforge_project:
|
169
|
+
rubygems_version: 1.8.8
|
170
|
+
signing_key:
|
171
|
+
specification_version: 3
|
172
|
+
summary: tagging with namespace and tree.
|
173
|
+
test_files:
|
174
|
+
- spec/dummy/app/controllers/application_controller.rb
|
175
|
+
- spec/dummy/app/helpers/application_helper.rb
|
176
|
+
- spec/dummy/app/models/altered_inheriting_taggable_model.rb
|
177
|
+
- spec/dummy/app/models/inheriting_taggable_model.rb
|
178
|
+
- spec/dummy/app/models/other_taggable_model.rb
|
179
|
+
- spec/dummy/app/models/post.rb
|
180
|
+
- spec/dummy/app/models/taggable_model.rb
|
181
|
+
- spec/dummy/app/models/taggable_user.rb
|
182
|
+
- spec/dummy/app/models/treed_model.rb
|
183
|
+
- spec/dummy/app/models/untaggable_model.rb
|
184
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
185
|
+
- spec/dummy/config/application.rb
|
186
|
+
- spec/dummy/config/boot.rb
|
187
|
+
- spec/dummy/config/database.yml
|
188
|
+
- spec/dummy/config/environment.rb
|
189
|
+
- spec/dummy/config/environments/development.rb
|
190
|
+
- spec/dummy/config/environments/production.rb
|
191
|
+
- spec/dummy/config/environments/test.rb
|
192
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
193
|
+
- spec/dummy/config/initializers/inflections.rb
|
194
|
+
- spec/dummy/config/initializers/mime_types.rb
|
195
|
+
- spec/dummy/config/initializers/secret_token.rb
|
196
|
+
- spec/dummy/config/initializers/session_store.rb
|
197
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
198
|
+
- spec/dummy/config/locales/en.yml
|
199
|
+
- spec/dummy/config/routes.rb
|
200
|
+
- spec/dummy/config.ru
|
201
|
+
- spec/dummy/db/migrate/20111221004133_create_posts.rb
|
202
|
+
- spec/dummy/db/migrate/20111221023928_taxonomy_migration.rb
|
203
|
+
- spec/dummy/db/migrate/20111221024100_create_bulk.rb
|
204
|
+
- spec/dummy/db/schema.rb
|
205
|
+
- spec/dummy/db/test.sqlite3
|
206
|
+
- spec/dummy/log/test.log
|
207
|
+
- spec/dummy/public/404.html
|
208
|
+
- spec/dummy/public/422.html
|
209
|
+
- spec/dummy/public/500.html
|
210
|
+
- spec/dummy/public/favicon.ico
|
211
|
+
- spec/dummy/Rakefile
|
212
|
+
- spec/dummy/script/rails
|
213
|
+
- spec/factories/posts.rb
|
214
|
+
- spec/generators/taxonomy/migration/migration_generator_spec.rb
|
215
|
+
- spec/models/post_spec.rb
|
216
|
+
- spec/spec_helper.rb
|
217
|
+
- spec/taxonomy/group_helper_spec.rb
|
218
|
+
- spec/taxonomy/has_tagger_spec.rb
|
219
|
+
- spec/taxonomy/has_taxonomy_spec.rb
|
220
|
+
- spec/taxonomy/tag_list_spec.rb
|
221
|
+
- spec/taxonomy/tag_spec.rb
|
222
|
+
- spec/taxonomy/taggable_spec.rb
|
223
|
+
- spec/taxonomy/tagger_spec.rb
|
224
|
+
- spec/taxonomy/tagging_spec.rb
|
225
|
+
- spec/taxonomy/tags_helper_spec.rb
|