edwardsa-acts-as-taggable-on 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG ADDED
@@ -0,0 +1,18 @@
1
+ == 2008-07-17
2
+
3
+ * Can now use a named_scope to find tags!
4
+
5
+ == 2008-06-23
6
+
7
+ * Can now find related objects of another class (tristanzdunn)
8
+ * Removed extraneous down migration cruft (azabaj)
9
+
10
+ == 2008-06-09
11
+
12
+ * Added support for Single Table Inheritance
13
+ * Adding gemspec and rails/init.rb for gemified plugin
14
+
15
+ == 2007-12-12
16
+
17
+ * Added ability to use dynamic tag contexts
18
+ * Fixed missing migration generator
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
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 ADDED
@@ -0,0 +1,194 @@
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 "acts-as-taggable-on", :source => "http://gemcutter.org"
39
+
40
+ After that, you can run "rake gems:install" to install the gem if you don't already have it.
41
+
42
+ ** NOTE **
43
+ Some issues have been experienced with "rake gems:install". If that doesn't work to install the gem,
44
+ try just installing it as a normal gem:
45
+
46
+ gem install acts-as-taggable-on --source http://gemcutter.org
47
+
48
+ Post Installation (Rails)
49
+ -------------------------
50
+ 1. script/generate acts_as_taggable_on_migration
51
+ 2. rake db:migrate
52
+
53
+ Testing
54
+ =======
55
+
56
+ Acts As Taggable On uses RSpec for its test coverage. Inside the plugin
57
+ directory, you can run the specs with:
58
+
59
+ rake spec
60
+
61
+
62
+ If you already have RSpec on your application, the specs will run while using:
63
+
64
+ rake spec:plugins
65
+
66
+
67
+ Example
68
+ =======
69
+
70
+ class User < ActiveRecord::Base
71
+ acts_as_taggable_on :tags, :skills, :interests
72
+ end
73
+
74
+ @user = User.new(:name => "Bobby")
75
+ @user.tag_list = "awesome, slick, hefty" # this should be familiar
76
+ @user.skill_list = "joking, clowning, boxing" # but you can do it for any context!
77
+ @user.skill_list # => ["joking","clowning","boxing"] as TagList
78
+ @user.save
79
+
80
+ @user.tags # => [<Tag name:"awesome">,<Tag name:"slick">,<Tag name:"hefty">]
81
+ @user.skills # => [<Tag name:"joking">,<Tag name:"clowning">,<Tag name:"boxing">]
82
+
83
+ # The old way
84
+ User.find_tagged_with("awesome", :on => :tags) # => [@user]
85
+ User.find_tagged_with("awesome", :on => :skills) # => []
86
+
87
+ # The better way (utilizes named_scope)
88
+ User.tagged_with("awesome", :on => :tags) # => [@user]
89
+ User.tagged_with("awesome", :on => :skills) # => []
90
+
91
+ @frankie = User.create(:name => "Frankie", :skill_list => "joking, flying, eating")
92
+ User.skill_counts # => [<Tag name="joking" count=2>,<Tag name="clowning" count=1>...]
93
+ @frankie.skill_counts
94
+
95
+ Finding Tagged Objects
96
+ ======================
97
+
98
+ Acts As Taggable On utilizes Rails 2.1's named_scope to create an association
99
+ for tags. This way you can mix and match to filter down your results, and it
100
+ also improves compatibility with the will_paginate gem:
101
+
102
+ class User < ActiveRecord::Base
103
+ acts_as_taggable_on :tags
104
+ named_scope :by_join_date, :order => "created_at DESC"
105
+ end
106
+
107
+ User.tagged_with("awesome").by_date
108
+ User.tagged_with("awesome").by_date.paginate(:page => params[:page], :per_page => 20)
109
+
110
+ Relationships
111
+ =============
112
+
113
+ You can find objects of the same type based on similar tags on certain contexts.
114
+ Also, objects will be returned in descending order based on the total number of
115
+ matched tags.
116
+
117
+ @bobby = User.find_by_name("Bobby")
118
+ @bobby.skill_list # => ["jogging", "diving"]
119
+
120
+ @frankie = User.find_by_name("Frankie")
121
+ @frankie.skill_list # => ["hacking"]
122
+
123
+ @tom = User.find_by_name("Tom")
124
+ @tom.skill_list # => ["hacking", "jogging", "diving"]
125
+
126
+ @tom.find_related_skills # => [<User name="Bobby">,<User name="Frankie">]
127
+ @bobby.find_related_skills # => [<User name="Tom">]
128
+ @frankie.find_related_skills # => [<User name="Tom">]
129
+
130
+
131
+ Dynamic Tag Contexts
132
+ ====================
133
+
134
+ In addition to the generated tag contexts in the definition, it is also possible
135
+ to allow for dynamic tag contexts (this could be user generated tag contexts!)
136
+
137
+ @user = User.new(:name => "Bobby")
138
+ @user.set_tag_list_on(:customs, "same, as, tag, list")
139
+ @user.tag_list_on(:customs) # => ["same","as","tag","list"]
140
+ @user.save
141
+ @user.tags_on(:customs) # => [<Tag name='same'>,...]
142
+ @user.tag_counts_on(:customs)
143
+ User.find_tagged_with("same", :on => :customs) # => [@user]
144
+
145
+ Tag Ownership
146
+ =============
147
+
148
+ Tags can have owners:
149
+
150
+ class User < ActiveRecord::Base
151
+ acts_as_tagger
152
+ end
153
+
154
+ class Photo < ActiveRecord::Base
155
+ acts_as_taggable_on :locations
156
+ end
157
+
158
+ @some_user.tag(@some_photo, :with => "paris, normandy", :on => :locations)
159
+ @some_user.owned_taggings
160
+ @some_user.owned_tags
161
+ @some_photo.locations_from(@some_user)
162
+
163
+ Caveats, Uncharted Waters
164
+ =========================
165
+
166
+ This plugin is still under active development. Tag caching has not
167
+ been thoroughly (or even casually) tested and may not work as expected.
168
+
169
+ Contributors
170
+ ============
171
+
172
+ * Michael Bleigh - Original Author
173
+ * Brendan Lim - Related Objects
174
+ * Pradeep Elankumaran - Taggers
175
+ * Sinclair Bain - Patch King
176
+
177
+ Patch Contributors
178
+ ------------------
179
+
180
+ * tristanzdunn - Related objects of other classes
181
+ * azabaj - Fixed migrate down
182
+ * Peter Cooper - named_scope fix
183
+ * slainer68 - STI fix
184
+ * harrylove - migration instructions and fix-ups
185
+ * lawrencepit - cached tag work
186
+
187
+ Resources
188
+ =========
189
+
190
+ * Acts As Community - http://www.actsascommunity.com/projects/acts-as-taggable-on
191
+ * GitHub - http://github.com/mbleigh/acts-as-taggable-on
192
+ * Lighthouse - http://mbleigh.lighthouseapp.com/projects/10116-acts-as-taggable-on
193
+
194
+ Copyright (c) 2007 Michael Bleigh (http://mbleigh.com/) and Intridea Inc. (http://intridea.com/), released under the MIT license
data/README.rdoc ADDED
@@ -0,0 +1,158 @@
1
+ = ActsAsTaggableOn
2
+
3
+ This plugin was originally based on Acts as Taggable on Steroids by Jonathan Viney.
4
+ It has evolved substantially since that point, but all credit goes to him for the
5
+ initial tagging functionality that so many people have used.
6
+
7
+ For instance, in a social network, a user might have tags that are called skills,
8
+ interests, sports, and more. There is no real way to differentiate between tags and
9
+ so an implementation of this type is not possible with acts as taggable on steroids.
10
+
11
+ Enter Acts as Taggable On. Rather than tying functionality to a specific keyword
12
+ (namely "tags"), acts as taggable on allows you to specify an arbitrary number of
13
+ tag "contexts" that can be used locally or in combination in the same way steroids
14
+ was used.
15
+
16
+ == Installation
17
+
18
+ === Plugin
19
+
20
+ Acts As Taggable On is available both as a gem and as a traditional plugin. For the
21
+ traditional plugin you can install like so (Rails 2.1 or later):
22
+
23
+ script/plugin install git://github.com/mbleigh/acts-as-taggable-on.git
24
+
25
+ === GemPlugin
26
+
27
+ Acts As Taggable On is also available as a gem plugin using Rails 2.1's gem dependencies.
28
+ To install the gem, add this to your config/environment.rb:
29
+
30
+ config.gem "acts-as-taggable-on", :source => "http://gemcutter.org"
31
+
32
+ After that, you can run "rake gems:install" to install the gem if you don't already have it.
33
+
34
+ === Post Installation (Rails)
35
+
36
+ 1. script/generate acts_as_taggable_on_migration
37
+ 2. rake db:migrate
38
+
39
+ === Testing
40
+
41
+ Acts As Taggable On uses RSpec for its test coverage. Inside the plugin
42
+ directory, you can run the specs with:
43
+
44
+ rake spec
45
+
46
+ If you already have RSpec on your application, the specs will run while using:
47
+
48
+ rake spec:plugins
49
+
50
+
51
+ == Usage
52
+
53
+ class User < ActiveRecord::Base
54
+ acts_as_taggable_on :tags, :skills, :interests
55
+ end
56
+
57
+ @user = User.new(:name => "Bobby")
58
+ @user.tag_list = "awesome, slick, hefty" # this should be familiar
59
+ @user.skill_list = "joking, clowning, boxing" # but you can do it for any context!
60
+ @user.skill_list # => ["joking","clowning","boxing"] as TagList
61
+ @user.save
62
+
63
+ @user.tags # => [<Tag name:"awesome">,<Tag name:"slick">,<Tag name:"hefty">]
64
+ @user.skills # => [<Tag name:"joking">,<Tag name:"clowning">,<Tag name:"boxing">]
65
+
66
+ # The old way
67
+ User.find_tagged_with("awesome", :on => :tags) # => [@user]
68
+ User.find_tagged_with("awesome", :on => :skills) # => []
69
+
70
+ # The better way (utilizes named_scope)
71
+ User.tagged_with("awesome", :on => :tags) # => [@user]
72
+ User.tagged_with("awesome", :on => :skills) # => []
73
+
74
+ @frankie = User.create(:name => "Frankie", :skill_list => "joking, flying, eating")
75
+ User.skill_counts # => [<Tag name="joking" count=2>,<Tag name="clowning" count=1>...]
76
+ @frankie.skill_counts
77
+
78
+ === Finding Tagged Objects
79
+
80
+ Acts As Taggable On utilizes Rails 2.1's named_scope to create an association
81
+ for tags. This way you can mix and match to filter down your results, and it
82
+ also improves compatibility with the will_paginate gem:
83
+
84
+ class User < ActiveRecord::Base
85
+ acts_as_taggable_on :tags
86
+ named_scope :by_join_date, :order => "created_at DESC"
87
+ end
88
+
89
+ User.tagged_with("awesome").by_date
90
+ User.tagged_with("awesome").by_date.paginate(:page => params[:page], :per_page => 20)
91
+
92
+ === Relationships
93
+
94
+ You can find objects of the same type based on similar tags on certain contexts.
95
+ Also, objects will be returned in descending order based on the total number of
96
+ matched tags.
97
+
98
+ @bobby = User.find_by_name("Bobby")
99
+ @bobby.skill_list # => ["jogging", "diving"]
100
+
101
+ @frankie = User.find_by_name("Frankie")
102
+ @frankie.skill_list # => ["hacking"]
103
+
104
+ @tom = User.find_by_name("Tom")
105
+ @tom.skill_list # => ["hacking", "jogging", "diving"]
106
+
107
+ @tom.find_related_skills # => [<User name="Bobby">,<User name="Frankie">]
108
+ @bobby.find_related_skills # => [<User name="Tom">]
109
+ @frankie.find_related_skills # => [<User name="Tom">]
110
+
111
+ === Dynamic Tag Contexts
112
+
113
+ In addition to the generated tag contexts in the definition, it is also possible
114
+ to allow for dynamic tag contexts (this could be user generated tag contexts!)
115
+
116
+ @user = User.new(:name => "Bobby")
117
+ @user.set_tag_list_on(:customs, "same, as, tag, list")
118
+ @user.tag_list_on(:customs) # => ["same","as","tag","list"]
119
+ @user.save
120
+ @user.tags_on(:customs) # => [<Tag name='same'>,...]
121
+ @user.tag_counts_on(:customs)
122
+ User.find_tagged_with("same", :on => :customs) # => [@user]
123
+
124
+ === Tag Ownership
125
+
126
+ Tags can have owners:
127
+
128
+ class User < ActiveRecord::Base
129
+ acts_as_tagger
130
+ end
131
+
132
+ class Photo < ActiveRecord::Base
133
+ acts_as_taggable_on :locations
134
+ end
135
+
136
+ @some_user.tag(@some_photo, :with => "paris, normandy", :on => :locations)
137
+ @some_user.owned_taggings
138
+ @some_user.owned_tags
139
+ @some_photo.locations_from(@some_user)
140
+
141
+ == Contributors
142
+
143
+ * TomEric (i76) - Maintainer
144
+ * Michael Bleigh - Original Author
145
+ * Brendan Lim - Related Objects
146
+ * Pradeep Elankumaran - Taggers
147
+ * Sinclair Bain - Patch King
148
+
149
+ == Patch Contributors
150
+
151
+ * tristanzdunn - Related objects of other classes
152
+ * azabaj - Fixed migrate down
153
+ * Peter Cooper - named_scope fix
154
+ * slainer68 - STI fix
155
+ * harrylove - migration instructions and fix-ups
156
+ * lawrencepit - cached tag work
157
+
158
+ Copyright (c) 2007-2009 Michael Bleigh (http://mbleigh.com/) and Intridea Inc. (http://intridea.com/), released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'spec/rake/spectask'
2
+
3
+ begin
4
+ require 'jeweler'
5
+ Jeweler::Tasks.new do |gemspec|
6
+ gemspec.name = "edwardsa-acts-as-taggable-on"
7
+ gemspec.summary = "ActsAsTaggableOn is a tagging plugin for Rails that provides multiple tagging contexts on a single model."
8
+ gemspec.description = "With ActsAsTaggableOn, you could tag a single model on several contexts, such as skills, interests, and awards. It also provides other advanced functionality."
9
+ gemspec.email = "michael@intridea.com"
10
+ gemspec.homepage = "http://github.com/mbleigh/acts-as-taggable-on"
11
+ gemspec.authors = ["Michael Bleigh"]
12
+ gemspec.files = FileList["[A-Z]*", "{lib,spec,rails}/**/*"] - FileList["**/*.log"]
13
+ end
14
+ Jeweler::GemcutterTasks.new
15
+ rescue LoadError
16
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
17
+ end
18
+
19
+ desc 'Default: run specs'
20
+ task :default => :spec
21
+ Spec::Rake::SpecTask.new do |t|
22
+ t.spec_files = FileList["spec/**/*_spec.rb"]
23
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.12
@@ -0,0 +1,75 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{acts-as-taggable-on}
8
+ s.version = "1.0.12"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Michael Bleigh"]
12
+ s.date = %q{2009-11-25}
13
+ s.description = %q{With ActsAsTaggableOn, you could tag a single model on several contexts, such as skills, interests, and awards. It also provides other advanced functionality.}
14
+ s.email = %q{michael@intridea.com}
15
+ s.extra_rdoc_files = [
16
+ "CHANGELOG",
17
+ "README",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ "CHANGELOG",
22
+ "MIT-LICENSE",
23
+ "README",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "acts-as-taggable-on.gemspec",
28
+ "init.rb",
29
+ "lib/acts-as-taggable-on.rb",
30
+ "lib/acts_as_taggable_on/acts_as_taggable_on.rb",
31
+ "lib/acts_as_taggable_on/acts_as_tagger.rb",
32
+ "lib/acts_as_taggable_on/tag.rb",
33
+ "lib/acts_as_taggable_on/tag_list.rb",
34
+ "lib/acts_as_taggable_on/tagging.rb",
35
+ "lib/acts_as_taggable_on/tags_helper.rb",
36
+ "rails/init.rb",
37
+ "spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb",
38
+ "spec/acts_as_taggable_on/acts_as_tagger_spec.rb",
39
+ "spec/acts_as_taggable_on/tag_list_spec.rb",
40
+ "spec/acts_as_taggable_on/tag_spec.rb",
41
+ "spec/acts_as_taggable_on/taggable_spec.rb",
42
+ "spec/acts_as_taggable_on/tagger_spec.rb",
43
+ "spec/acts_as_taggable_on/tagging_spec.rb",
44
+ "spec/schema.rb",
45
+ "spec/spec.opts",
46
+ "spec/spec_helper.rb",
47
+ "uninstall.rb"
48
+ ]
49
+ s.homepage = %q{http://github.com/mbleigh/acts-as-taggable-on}
50
+ s.rdoc_options = ["--charset=UTF-8"]
51
+ s.require_paths = ["lib"]
52
+ s.rubygems_version = %q{1.3.5}
53
+ s.summary = %q{ActsAsTaggableOn is a tagging plugin for Rails that provides multiple tagging contexts on a single model.}
54
+ s.test_files = [
55
+ "spec/acts_as_taggable_on/acts_as_taggable_on_spec.rb",
56
+ "spec/acts_as_taggable_on/acts_as_tagger_spec.rb",
57
+ "spec/acts_as_taggable_on/taggable_spec.rb",
58
+ "spec/acts_as_taggable_on/tagger_spec.rb",
59
+ "spec/acts_as_taggable_on/tagging_spec.rb",
60
+ "spec/acts_as_taggable_on/tag_list_spec.rb",
61
+ "spec/acts_as_taggable_on/tag_spec.rb",
62
+ "spec/schema.rb",
63
+ "spec/spec_helper.rb"
64
+ ]
65
+
66
+ if s.respond_to? :specification_version then
67
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
68
+ s.specification_version = 3
69
+
70
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
71
+ else
72
+ end
73
+ else
74
+ end
75
+ end