mongoid-simple-tags 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ mongoid-simple-tags is a basic and simple tagging system for mongoid using map-r
7
7
 
8
8
  Add the following to Gemfile:
9
9
 
10
- gem "mongoid-simple-tags", "0.0.7"
10
+ gem "mongoid-simple-tags", "0.0.9"
11
11
 
12
12
  == Usage
13
13
 
@@ -24,14 +24,21 @@ mongoid-simple-tags is a basic and simple tagging system for mongoid using map-r
24
24
 
25
25
  u.tags # => ["linux","tucuman","free software"]
26
26
 
27
- User.tagged_with("linux") # => u
28
- User.tagged_with(["tucuman", "free software"]) # => u
27
+ User.tagged_with("linux") # => [u]
28
+ User.tagged_with(["tucuman", "free software"]) # => [u]
29
+ User.tagged_with(["linux", "foo"]) # => [u]
30
+
31
+ User.tagged_with_all(["linux"]) # => [u]
32
+ User.tagged_with_all(["linux", "foo"]) # => []
29
33
 
30
34
  u2 = User.new(:name => "ubuntu")
31
35
  u2.tag_list = "linux"
32
36
  u2.save
33
37
 
34
38
  User.tagged_with("linux") # => [u, u2]
39
+ User.tagged_with(["linux", "tucuman"]) # => [u, u2]
40
+
41
+ User.tagged_with_all(["linux", "tucuman"]) # => [u]
35
42
 
36
43
  # using map-reduce function
37
44
 
@@ -67,11 +67,17 @@ module Mongoid
67
67
  criteria.in(:tags => tags)
68
68
  end
69
69
 
70
+ def tagged_with_all(tags)
71
+ tags = [tags] unless tags.is_a? Array
72
+ criteria.all(:tags => tags)
73
+ end
74
+
70
75
  def tag_list
71
76
  self.all_tags.collect{|tag| tag[:name]}
72
77
  end
78
+
73
79
  end
74
80
 
75
81
  end
76
82
  end
77
- end
83
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "mongoid-simple-tags"
5
- s.version = "0.0.8"
5
+ s.version = "0.0.9"
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["chebyte"]
8
8
  s.email = ["maurotorres@gmail.com"]
@@ -18,5 +18,4 @@ Gem::Specification.new do |s|
18
18
  s.require_paths = ["lib"]
19
19
  s.add_development_dependency "rspec", "~> 2.10.0"
20
20
  s.add_dependency "mongoid", "~> 3.0.3"
21
- s.add_dependency "bson_ext", "~> 1.6"
22
21
  end
@@ -13,7 +13,6 @@ class Organization
13
13
  has_many :users
14
14
  end
15
15
 
16
-
17
16
  describe "A Taggable model" do
18
17
 
19
18
  let(:user) { User.new(name: 'Tuquito') }
@@ -39,9 +38,6 @@ describe "A Taggable model" do
39
38
  user.tags.should_not be_nil
40
39
  user.tags.should eql([])
41
40
  end
42
-
43
-
44
-
45
41
  end
46
42
 
47
43
 
@@ -80,6 +76,15 @@ describe "A Taggable model with tags assigned" do
80
76
  User.tag_list.sort.should == ["linux", "tucuman", "free software"].sort
81
77
  end
82
78
 
79
+ it 'should be able to find tagged_with_all objects' do
80
+ user_2 = User.create! name: 'Jane Doe', tag_list: 'linux, foo, bar'
81
+
82
+ User.tagged_with_all(%w[foo linux]).should == [user_2]
83
+ User.tagged_with_all('linux').to_a.should =~ ([@user, user_2])
84
+ User.tagged_with_all(%w[linux]).to_a.should =~ [@user, user_2]
85
+ User.tagged_with_all([]).should == []
86
+ User.tagged_with_all(%w[foo tucuman]).should == []
87
+ end
83
88
  end
84
89
 
85
90
  describe "A Taggable model with scope" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-simple-tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-07 00:00:00.000000000 Z
12
+ date: 2013-02-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -43,22 +43,6 @@ dependencies:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
45
  version: 3.0.3
46
- - !ruby/object:Gem::Dependency
47
- name: bson_ext
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: '1.6'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: '1.6'
62
46
  description: basic and simple tagging system for mongoid using map-reduce function
63
47
  email:
64
48
  - maurotorres@gmail.com
@@ -104,6 +88,4 @@ rubygems_version: 1.8.23
104
88
  signing_key:
105
89
  specification_version: 3
106
90
  summary: MongoID simple tags for RAILS
107
- test_files:
108
- - spec/mongoid-simple-tags_spec.rb
109
- - spec/spec_helper.rb
91
+ test_files: []