wideopenspaces-acts-as-taggable-on 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :minor: 0
3
+ :patch: 4
4
+ :major: 1
@@ -0,0 +1,72 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "acts_as_tagger" do
4
+ context "Tagger Method Generation" do
5
+
6
+ before(:each) do
7
+ @tagger = TaggableUser.new()
8
+ end
9
+
10
+ it "should add #is_tagger? query method to the class-side" do
11
+ TaggableUser.should respond_to(:is_tagger?)
12
+ end
13
+
14
+ it "should return true from the class-side #is_tagger?" do
15
+ TaggableUser.is_tagger?.should be_true
16
+ end
17
+
18
+ it "should return false from the base #is_tagger?" do
19
+ ActiveRecord::Base.is_tagger?.should be_false
20
+ end
21
+
22
+ it "should add #is_tagger? query method to the singleton" do
23
+ @tagger.should respond_to(:is_tagger?)
24
+ end
25
+
26
+ it "should add #tag method on the instance-side" do
27
+ @tagger.should respond_to(:tag)
28
+ end
29
+
30
+ it "should generate an association for #owned_taggings and #owned_tags" do
31
+ @tagger.should respond_to(:owned_taggings, :owned_tags)
32
+ end
33
+ end
34
+
35
+ describe "#tag" do
36
+ context 'when called with a non-existent tag context' do
37
+ before(:each) do
38
+ @tagger = TaggableUser.new()
39
+ @taggable = TaggableModel.new(:name=>"Richard Prior")
40
+ end
41
+
42
+ it "should by default not throw an exception " do
43
+ @taggable.tag_list_on(:foo).should be_empty
44
+ lambda {
45
+ @tagger.tag(@taggable, :with=>'this, and, that', :on=>:foo)
46
+ }.should_not raise_error
47
+ end
48
+
49
+ it 'should by default create the tag context on-the-fly' do
50
+ @taggable.tag_list_on(:here_ond_now).should be_empty
51
+ @tagger.tag(@taggable, :with=>'that', :on=>:here_ond_now)
52
+ @taggable.tag_list_on(:here_ond_now).should include('that')
53
+ end
54
+
55
+ it "should throw an exception when the default is over-ridden" do
56
+ @taggable.tag_list_on(:foo_boo).should be_empty
57
+ lambda {
58
+ @tagger.tag(@taggable, :with=>'this, and, that', :on=>:foo_boo, :force=>false)
59
+ }.should raise_error
60
+ end
61
+
62
+ it "should not create the tag context on-the-fly when the default is over-ridden" do
63
+ @taggable.tag_list_on(:foo_boo).should be_empty
64
+ @tagger.tag(@taggable, :with=>'this, and, that', :on=>:foo_boo, :force=>false) rescue
65
+ @taggable.tag_list_on(:foo_boo).should be_empty
66
+ end
67
+
68
+ end
69
+
70
+ end
71
+
72
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,7 @@
1
+ --colour
2
+ --format
3
+ specdoc
4
+ --loadby
5
+ mtime
6
+ --reverse
7
+ --backtrace
metadata CHANGED
@@ -1,16 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wideopenspaces-acts-as-taggable-on
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ hash: 31
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 4
10
+ version: 1.0.4
5
11
  platform: ruby
6
12
  authors:
7
13
  - Michael Bleigh
14
+ - Jacob Stetser
8
15
  autorequire:
9
16
  bindir: bin
10
17
  cert_chain: []
11
18
 
12
- date: 2009-01-21 00:00:00 -08:00
13
- default_executable:
19
+ date: 2009-01-24 00:00:00 Z
14
20
  dependencies: []
15
21
 
16
22
  description: Acts As Taggable On provides the ability to have multiple tag contexts on a single model in ActiveRecord. It also has support for tag clouds, related items, taggers, and more.
@@ -22,14 +28,9 @@ extensions: []
22
28
  extra_rdoc_files: []
23
29
 
24
30
  files:
25
- - CHANGELOG
26
- - MIT-LICENSE
27
- - README
28
- - generators/acts_as_taggable_on_migration
31
+ - VERSION.yml
29
32
  - generators/acts_as_taggable_on_migration/acts_as_taggable_on_migration_generator.rb
30
- - generators/acts_as_taggable_on_migration/templates
31
33
  - generators/acts_as_taggable_on_migration/templates/migration.rb
32
- - init.rb
33
34
  - lib/acts-as-taggable-on.rb
34
35
  - lib/acts_as_taggable_on/acts_as_taggable_on.rb
35
36
  - lib/acts_as_taggable_on/acts_as_tagger.rb
@@ -37,41 +38,47 @@ files:
37
38
  - lib/acts_as_taggable_on/tag_list.rb
38
39
  - lib/acts_as_taggable_on/tagging.rb
39
40
  - lib/acts_as_taggable_on/tags_helper.rb
40
- - lib/autotest/discover.rb
41
- - rails/init.rb
42
- - spec/acts_as_taggable_on
43
41
  - spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb
42
+ - spec/acts_as_taggable_on/acts_as_tagger_spec.rb
44
43
  - spec/acts_as_taggable_on/tag_list_spec.rb
45
44
  - spec/acts_as_taggable_on/tag_spec.rb
46
45
  - spec/acts_as_taggable_on/taggable_spec.rb
47
46
  - spec/acts_as_taggable_on/tagger_spec.rb
48
47
  - spec/acts_as_taggable_on/tagging_spec.rb
49
48
  - spec/schema.rb
49
+ - spec/spec.opts
50
50
  - spec/spec_helper.rb
51
- - uninstall.rb
52
- has_rdoc: false
53
- homepage: http://www.actsascommunity.com/projects/acts-as-taggable-on
54
- post_install_message:
55
- rdoc_options: []
51
+ homepage: http://github.com/wideopenspaces/acts-as-taggable-on
52
+ licenses: []
56
53
 
54
+ post_install_message:
55
+ rdoc_options:
56
+ - --inline-source
57
+ - --charset=UTF-8
57
58
  require_paths:
58
59
  - lib
59
60
  required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
60
62
  requirements:
61
63
  - - ">="
62
64
  - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
63
68
  version: "0"
64
- version:
65
69
  required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
66
71
  requirements:
67
72
  - - ">="
68
73
  - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
69
77
  version: "0"
70
- version:
71
78
  requirements: []
72
79
 
73
80
  rubyforge_project:
74
- rubygems_version: 1.2.0
81
+ rubygems_version: 1.7.2
75
82
  signing_key:
76
83
  specification_version: 2
77
84
  summary: Tagging for ActiveRecord with custom contexts and advanced features.
data/CHANGELOG DELETED
@@ -1,22 +0,0 @@
1
- == 2009-01-21
2
-
3
- * Added counter cache for taggings on tag (Tag#tag_count) (wideopenspaces)
4
-
5
- == 2008-07-17
6
-
7
- * Can now use a named_scope to find tags!
8
-
9
- == 2008-06-23
10
-
11
- * Can now find related objects of another class (tristanzdunn)
12
- * Removed extraneous down migration cruft (azabaj)
13
-
14
- == 2008-06-09
15
-
16
- * Added support for Single Table Inheritance
17
- * Adding gemspec and rails/init.rb for gemified plugin
18
-
19
- == 2007-12-12
20
-
21
- * Added ability to use dynamic tag contexts
22
- * Fixed missing migration generator
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2007 Michael Bleigh and Intridea Inc.
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README DELETED
@@ -1,190 +0,0 @@
1
- ActsAsTaggableOn
2
- ================
3
-
4
- This plugin was originally based on Acts as Taggable on Steroids by Jonathan Viney.
5
- It has evolved substantially since that point, but all credit goes to him for the
6
- initial tagging functionality that so many people have used.
7
-
8
- For instance, in a social network, a user might have tags that are called skills,
9
- interests, sports, and more. There is no real way to differentiate between tags and
10
- so an implementation of this type is not possible with acts as taggable on steroids.
11
-
12
- Enter Acts as Taggable On. Rather than tying functionality to a specific keyword
13
- (namely "tags"), acts as taggable on allows you to specify an arbitrary number of
14
- tag "contexts" that can be used locally or in combination in the same way steroids
15
- was used.
16
-
17
- Installation
18
- ============
19
-
20
- Plugin
21
- ------
22
-
23
- Acts As Taggable On is available both as a gem and as a traditional plugin. For the
24
- traditional plugin you can install like so (Rails 2.1 or later):
25
-
26
- script/plugin install git://github.com/mbleigh/acts-as-taggable-on.git
27
-
28
- For earlier versions:
29
-
30
- git clone git://github.com/mbleigh/acts-as-taggable-on.git vendor/plugins/acts-as-taggable-on
31
-
32
- GemPlugin
33
- ---------
34
-
35
- Acts As Taggable On is also available as a gem plugin using Rails 2.1's gem dependencies.
36
- To install the gem, add this to your config/environment.rb:
37
-
38
- config.gem "mbleigh-acts-as-taggable-on", :source => "http://gems.github.com", :lib => "acts-as-taggable-on"
39
-
40
- After that, you can run "rake gems:install" to install the gem if you don't already have it.
41
- See http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies for
42
- additional details about gem dependencies in Rails.
43
-
44
- ** NOTE **
45
- Some issues have been experienced with "rake gems:install". If that doesn't work to install the gem,
46
- try just installing it as a normal gem:
47
-
48
- gem install mbleigh-acts-as-taggable-on --source http://gems.github.com
49
-
50
- Post Installation (Rails)
51
- -------------------------
52
- 1. script/generate acts_as_taggable_on_migration
53
- 2. rake db/migrate
54
-
55
- Testing
56
- =======
57
-
58
- Acts As Taggable On uses RSpec for its test coverage. If you already have RSpec on your
59
- application, the specs will run while using:
60
-
61
- rake spec:plugins
62
-
63
- Example
64
- =======
65
-
66
- class User < ActiveRecord::Base
67
- acts_as_taggable_on :tags, :skills, :interests
68
- end
69
-
70
- @user = User.new(:name => "Bobby")
71
- @user.tag_list = "awesome, slick, hefty" # this should be familiar
72
- @user.skill_list = "joking, clowning, boxing" # but you can do it for any context!
73
- @user.skill_list # => ["joking","clowning","boxing"] as TagList
74
- @user.save
75
-
76
- @user.tags # => [<Tag name:"awesome">,<Tag name:"slick">,<Tag name:"hefty">]
77
- @user.skills # => [<Tag name:"joking">,<Tag name:"clowning">,<Tag name:"boxing">]
78
-
79
- # The old way
80
- User.find_tagged_with("awesome", :on => :tags) # => [@user]
81
- User.find_tagged_with("awesome", :on => :skills) # => []
82
-
83
- # The better way (utilizes named_scope)
84
- User.tagged_with("awesome", :on => :tags) # => [@user]
85
- User.tagged_with("awesome", :on => :skills) # => []
86
-
87
- @frankie = User.create(:name => "Frankie", :skill_list => "joking, flying, eating")
88
- User.skill_counts # => [<Tag name="joking" count=2>,<Tag name="clowning" count=1>...]
89
- @frankie.skill_counts
90
-
91
- Finding Tagged Objects
92
- ======================
93
-
94
- Acts As Taggable On utilizes Rails 2.1's named_scope to create an association
95
- for tags. This way you can mix and match to filter down your results, and it
96
- also improves compatibility with the will_paginate gem:
97
-
98
- class User < ActiveRecord::Base
99
- acts_as_taggable_on :tags
100
- named_scope :by_join_date, :order => "created_at DESC"
101
- end
102
-
103
- User.tagged_with("awesome").by_date
104
- User.tagged_with("awesome").by_date.paginate(:page => params[:page], :per_page => 20)
105
-
106
- Relationships
107
- =============
108
-
109
- You can find objects of the same type based on similar tags on certain contexts.
110
- Also, objects will be returned in descending order based on the total number of
111
- matched tags.
112
-
113
- @bobby = User.find_by_name("Bobby")
114
- @bobby.skill_list # => ["jogging", "diving"]
115
-
116
- @frankie = User.find_by_name("Frankie")
117
- @frankie.skill_list # => ["hacking"]
118
-
119
- @tom = User.find_by_name("Tom")
120
- @tom.skill_list # => ["hacking", "jogging", "diving"]
121
-
122
- @tom.find_related_skills # => [<User name="Bobby">,<User name="Frankie">]
123
- @bobby.find_related_skills # => [<User name="Tom">]
124
- @frankie.find_related_skills # => [<User name="Tom">]
125
-
126
-
127
- Dynamic Tag Contexts
128
- ====================
129
-
130
- In addition to the generated tag contexts in the definition, it is also possible
131
- to allow for dynamic tag contexts (this could be user generated tag contexts!)
132
-
133
- @user = User.new(:name => "Bobby")
134
- @user.set_tag_list_on(:customs, "same, as, tag, list")
135
- @user.tag_list_on(:customs) # => ["same","as","tag","list"]
136
- @user.save
137
- @user.tags_on(:customs) # => [<Tag name='same'>,...]
138
- @user.tag_counts_on(:customs)
139
- User.find_tagged_with("same", :on => :customs) # => [@user]
140
-
141
- Tag Ownership
142
- =============
143
-
144
- Tags can have owners:
145
-
146
- class User < ActiveRecord::Base
147
- acts_as_tagger
148
- end
149
-
150
- class Photo < ActiveRecord::Base
151
- acts_as_taggable_on :locations
152
- end
153
-
154
- @some_user.tag(@some_photo, :with => "paris, normandy", :on => :locations)
155
- @some_user.owned_taggings
156
- @some_user.owned_tags
157
- @some_photo.locations_from(@some_user)
158
-
159
- Caveats, Uncharted Waters
160
- =========================
161
-
162
- This plugin is still under active development. Tag caching has not
163
- been thoroughly (or even casually) tested and may not work as expected.
164
-
165
- Contributors
166
- ============
167
-
168
- * Michael Bleigh - Original Author
169
- * Brendan Lim - Related Objects
170
- * Pradeep Elankumaran - Taggers
171
- * Sinclair Bain - Patch King
172
-
173
- Patch Contributors
174
- ------------------
175
-
176
- * tristanzdunn - Related objects of other classes
177
- * azabaj - Fixed migrate down
178
- * Peter Cooper - named_scope fix
179
- * slainer68 - STI fix
180
- * harrylove - migration instructions and fix-ups
181
- * lawrencepit - cached tag work
182
-
183
- Resources
184
- =========
185
-
186
- * Acts As Community - http://www.actsascommunity.com/projects/acts-as-taggable-on
187
- * GitHub - http://github.com/mbleigh/acts-as-taggable-on
188
- * Lighthouse - http://mbleigh.lighthouseapp.com/projects/10116-acts-as-taggable-on
189
-
190
- Copyright (c) 2007 Michael Bleigh (http://mbleigh.com/) and Intridea Inc. (http://intridea.com/), released under the MIT license
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require File.dirname(__FILE__) + "/rails/init"
@@ -1,6 +0,0 @@
1
- # Need this to get picked up by autotest?
2
- $:.push(File.join(File.dirname(__FILE__), %w[.. .. rspec]))
3
-
4
- Autotest.add_discovery do
5
- "rspec"
6
- end
data/rails/init.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'acts-as-taggable-on'
2
-
3
- ActiveRecord::Base.send :include, ActiveRecord::Acts::TaggableOn
4
- ActiveRecord::Base.send :include, ActiveRecord::Acts::Tagger
5
-
6
- RAILS_DEFAULT_LOGGER.info "** acts_as_taggable_on: initialized properly."
data/uninstall.rb DELETED
@@ -1 +0,0 @@
1
- # Uninstall hook code here