acts-as-taggable-hstore 0.0.1 → 0.0.2
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/.gitignore +1 -0
- data/LICENSE +2 -2
- data/README.rdoc +3 -3
- data/acts-as-taggable-hstore.gemspec +2 -2
- data/lib/acts-as-taggable-hstore/version.rb +1 -1
- data/lib/acts_as_taggable_hstore/acts_as_taggable_hstore/core.rb +4 -1
- data/spec/acts_as_taggable_hstore/taggable_spec.rb +42 -11
- metadata +6 -6
data/.gitignore
CHANGED
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2009 Jt Gleason
|
1
|
+
Copyright (c) 2009 Jt Gleason, Justin.tv
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
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.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -10,7 +10,7 @@ everything is added as you would expect.
|
|
10
10
|
=== Rails 3.x
|
11
11
|
|
12
12
|
To use it, add it to your Gemfile:
|
13
|
-
gem 'acts-as-taggable-hstore' , '~> 0.
|
13
|
+
gem 'acts-as-taggable-hstore' , '~> 0.0.2'
|
14
14
|
|
15
15
|
==== Post Installation
|
16
16
|
|
@@ -34,10 +34,10 @@ First, run the migration for the particular table you want to be taggable. Then
|
|
34
34
|
end
|
35
35
|
|
36
36
|
@video = Video.new()
|
37
|
-
@video.tag_list = "starcraft 2,gameplay,mlg"
|
37
|
+
@video.tag_list = "starcraft 2, gameplay, mlg"
|
38
38
|
@video.save
|
39
39
|
|
40
|
-
@video.tags # => [
|
40
|
+
@video.tags # => ["starcraft 2", "gameplay", "mlg"]
|
41
41
|
|
42
42
|
=== Finding Tagged Objects
|
43
43
|
|
@@ -4,11 +4,11 @@ require 'acts-as-taggable-hstore/version'
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = %q{acts-as-taggable-hstore}
|
6
6
|
gem.authors = ["Jt Gleason"]
|
7
|
-
gem.date = %q{2012-
|
7
|
+
gem.date = %q{2012-06-29}
|
8
8
|
gem.description = %q{With ActsAsTaggableHstore, you can tag a single model that uses postgres hstore type}
|
9
9
|
gem.summary = "Basic postgres hstore tagging for Rails."
|
10
10
|
gem.email = %q{jt@twitch.tv}
|
11
|
-
gem.homepage = ''
|
11
|
+
gem.homepage = 'https://github.com/jtvjt/acts-as-taggable-hstore'
|
12
12
|
|
13
13
|
gem.add_runtime_dependency 'rails', '~> 3.0'
|
14
14
|
gem.add_runtime_dependency 'activerecord-postgres-hstore-core', "~> 0.0.4"
|
@@ -45,7 +45,7 @@ module ActsAsTaggableHstore::Taggable
|
|
45
45
|
hstore_result = self.send(self.class.tag_hstore_column)
|
46
46
|
|
47
47
|
if hstore_result.nil?
|
48
|
-
return
|
48
|
+
return ""
|
49
49
|
end
|
50
50
|
|
51
51
|
return hstore_result.keys.join(ActsAsTaggableHstore.glue)
|
@@ -57,6 +57,9 @@ module ActsAsTaggableHstore::Taggable
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def tags
|
60
|
+
if tag_hstore.nil?
|
61
|
+
return []
|
62
|
+
end
|
60
63
|
tag_hstore.keys
|
61
64
|
end
|
62
65
|
|
@@ -7,16 +7,22 @@ describe "Taggable" do
|
|
7
7
|
@taggables = [@taggable, TaggableModel.new(:name => "John Doe")]
|
8
8
|
end
|
9
9
|
|
10
|
-
it "should return
|
10
|
+
it "should return tag_list of blank right after new" do
|
11
11
|
blank_taggable = TaggableModel.new(:name => "Bob Jones")
|
12
|
-
blank_taggable.tag_list.should ==
|
12
|
+
blank_taggable.tag_list.should == ""
|
13
13
|
end
|
14
14
|
|
15
|
-
it "should return
|
15
|
+
it "should return tag_list of blank right after create" do
|
16
16
|
blank_taggable = TaggableModel.create(:name => "Bob Jones")
|
17
|
-
blank_taggable.tag_list.should ==
|
17
|
+
blank_taggable.tag_list.should == ""
|
18
18
|
end
|
19
19
|
|
20
|
+
it "should have tags of [] right after create" do
|
21
|
+
blank_taggable = TaggableModel.create(:name => "Bob Jones")
|
22
|
+
blank_taggable.tags.should == []
|
23
|
+
end
|
24
|
+
|
25
|
+
|
20
26
|
it "should be able to remove tags through list alone" do
|
21
27
|
@taggable.tag_list = "ruby, rails, css"
|
22
28
|
@taggable.save
|
@@ -41,7 +47,31 @@ describe "Taggable" do
|
|
41
47
|
TaggableModel.tagged_with("ruby").first.should_not be_readonly
|
42
48
|
end
|
43
49
|
|
44
|
-
it "should
|
50
|
+
it "should find all rows by matching tag" do
|
51
|
+
bob = TaggableModel.create(:name => "Bob", :tag_list => "lazy, happier")
|
52
|
+
frank = TaggableModel.create(:name => "Frank", :tag_list => "fitter, happier, inefficient")
|
53
|
+
steve = TaggableModel.create(:name => 'Steve', :tag_list => "fitter, happier")
|
54
|
+
|
55
|
+
TaggableModel.tagged_with(["happier"]).count.should == 3
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should find a single single row by a unique" do
|
59
|
+
bob = TaggableModel.create(:name => "Bob", :tag_list => "lazy, happier")
|
60
|
+
frank = TaggableModel.create(:name => "Frank", :tag_list => "fitter, happier, inefficient")
|
61
|
+
steve = TaggableModel.create(:name => 'Steve', :tag_list => "fitter, happier")
|
62
|
+
jane = TaggableModel.create(:name => 'Jane', :tag_list => "cooler")
|
63
|
+
TaggableModel.tagged_with(["cooler"]).count.should == 1
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should not find non-existant tag" do
|
67
|
+
bob = TaggableModel.create(:name => "Bob", :tag_list => "lazy, happier")
|
68
|
+
frank = TaggableModel.create(:name => "Frank", :tag_list => "fitter, happier, inefficient")
|
69
|
+
steve = TaggableModel.create(:name => 'Steve', :tag_list => "fitter, happier")
|
70
|
+
jane = TaggableModel.create(:name => 'Jane', :tag_list => "cooler")
|
71
|
+
TaggableModel.tagged_with(["evil"]).count.should == 0
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should be able to find tagged with all of the matching tags" do
|
45
75
|
bob = TaggableModel.create(:name => "Bob", :tag_list => "lazy, happier")
|
46
76
|
frank = TaggableModel.create(:name => "Frank", :tag_list => "fitter, happier, inefficient")
|
47
77
|
steve = TaggableModel.create(:name => 'Steve', :tag_list => "fitter, happier")
|
@@ -49,13 +79,14 @@ describe "Taggable" do
|
|
49
79
|
TaggableModel.tagged_with(["fitter", "happier"]).to_a.sort.should == [steve,frank].sort
|
50
80
|
end
|
51
81
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
82
|
+
it "should be able to find rows by any tag" do
|
83
|
+
bob = TaggableModel.create(:name => "Bob", :tag_list => "lazy, happier")
|
84
|
+
frank = TaggableModel.create(:name => "Frank", :tag_list => "fitter, happier, inefficient")
|
85
|
+
steve = TaggableModel.create(:name => 'Steve', :tag_list => "fitter, happier")
|
86
|
+
jane = TaggableModel.create(:name => 'Jane', :tag_list => "cooler")
|
56
87
|
|
57
|
-
|
58
|
-
|
88
|
+
TaggableModel.tagged_with(["lazy", "cooler"], :any => true).to_a.sort.should == [bob,jane].sort
|
89
|
+
end
|
59
90
|
|
60
91
|
it "should return an empty scope for empty tags" do
|
61
92
|
TaggableModel.tagged_with('').should == []
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts-as-taggable-hstore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jt Gleason
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-06-29 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rails
|
@@ -148,7 +148,7 @@ files:
|
|
148
148
|
- spec/models.rb
|
149
149
|
- spec/schema.rb
|
150
150
|
- spec/spec_helper.rb
|
151
|
-
homepage:
|
151
|
+
homepage: https://github.com/jtvjt/acts-as-taggable-hstore
|
152
152
|
licenses: []
|
153
153
|
|
154
154
|
post_install_message:
|
@@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
177
|
requirements: []
|
178
178
|
|
179
179
|
rubyforge_project:
|
180
|
-
rubygems_version: 1.8.
|
180
|
+
rubygems_version: 1.8.17
|
181
181
|
signing_key:
|
182
182
|
specification_version: 3
|
183
183
|
summary: Basic postgres hstore tagging for Rails.
|