mongoid-simple-tags 0.1.2 → 0.1.3
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/.travis.yml +5 -1
- data/Gemfile +1 -0
- data/README.rdoc +10 -2
- data/VERSION +1 -1
- data/donate.png +0 -0
- data/gemfiles/mongoid-3.1.gemfile +5 -0
- data/gemfiles/mongoid-3.1.gemfile.lock +45 -0
- data/lib/mongoid-simple-tags.rb +4 -4
- data/mongoid-simple-tags.gemspec +4 -2
- data/spec/mongoid-simple-tags_spec.rb +6 -4
- metadata +23 -4
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= mongoid-simple-tags {<img src="https://secure.travis-ci.org/chebyte/mongoid-simple-tags.png"/>}[http://travis-ci.org/chebyte/mongoid-simple-tags] {<img src="https://codeclimate.com/github/chebyte/mongoid-simple-tags.png" />}[https://codeclimate.com/github/chebyte/mongoid-simple-tags]
|
1
|
+
= mongoid-simple-tags {<img src="https://secure.travis-ci.org/chebyte/mongoid-simple-tags.png"/>}[http://travis-ci.org/chebyte/mongoid-simple-tags] {<img src="https://codeclimate.com/github/chebyte/mongoid-simple-tags.png" />}[https://codeclimate.com/github/chebyte/mongoid-simple-tags] {<img src="https://badge.fury.io/rb/mongoid-simple-tags.png" alt="Gem Version" />}[http://badge.fury.io/rb/mongoid-simple-tags]
|
2
2
|
|
3
3
|
mongoid-simple-tags is a basic and simple tagging system for mongoid using map-reduce function
|
4
4
|
(no backwards compatibility with mongoid v2!)
|
@@ -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.1.
|
10
|
+
gem "mongoid-simple-tags", "0.1.2"
|
11
11
|
|
12
12
|
== Usage
|
13
13
|
|
@@ -46,6 +46,14 @@ mongoid-simple-tags is a basic and simple tagging system for mongoid using map-r
|
|
46
46
|
|
47
47
|
User.tag_list #=>["free software", "linux", "tucuman"]
|
48
48
|
|
49
|
+
== Give back
|
50
|
+
|
51
|
+
If you're using mongoig-simple-tags and you or your company is making money from it, then please consider
|
52
|
+
donating via {Gittip}[https://www.gittip.com/chebyte/] so that I can continue to improve it.
|
53
|
+
|
54
|
+
{<img src="donate.png">}[https://www.gittip.com/chebyte/]
|
55
|
+
|
56
|
+
|
49
57
|
== Copyright
|
50
58
|
|
51
59
|
Copyright (c) 2011 chebyte(mauro torres). See LICENSE.txt for
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/donate.png
ADDED
Binary file
|
@@ -0,0 +1,45 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/lucasrenan/Gems/mongoid-simple-tags
|
3
|
+
specs:
|
4
|
+
mongoid-simple-tags (0.1.2)
|
5
|
+
json (~> 1.7.7)
|
6
|
+
mongoid (>= 3.0.3)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (3.2.13)
|
12
|
+
activesupport (= 3.2.13)
|
13
|
+
builder (~> 3.0.0)
|
14
|
+
activesupport (3.2.13)
|
15
|
+
i18n (= 0.6.1)
|
16
|
+
multi_json (~> 1.0)
|
17
|
+
builder (3.0.4)
|
18
|
+
diff-lcs (1.1.3)
|
19
|
+
i18n (0.6.1)
|
20
|
+
json (1.7.7)
|
21
|
+
mongoid (3.1.4)
|
22
|
+
activemodel (~> 3.2)
|
23
|
+
moped (~> 1.4)
|
24
|
+
origin (~> 1.0)
|
25
|
+
tzinfo (~> 0.3.22)
|
26
|
+
moped (1.5.0)
|
27
|
+
multi_json (1.7.3)
|
28
|
+
origin (1.1.0)
|
29
|
+
rspec (2.10.0)
|
30
|
+
rspec-core (~> 2.10.0)
|
31
|
+
rspec-expectations (~> 2.10.0)
|
32
|
+
rspec-mocks (~> 2.10.0)
|
33
|
+
rspec-core (2.10.1)
|
34
|
+
rspec-expectations (2.10.0)
|
35
|
+
diff-lcs (~> 1.1.3)
|
36
|
+
rspec-mocks (2.10.1)
|
37
|
+
tzinfo (0.3.37)
|
38
|
+
|
39
|
+
PLATFORMS
|
40
|
+
ruby
|
41
|
+
|
42
|
+
DEPENDENCIES
|
43
|
+
mongoid (~> 3.1.4)
|
44
|
+
mongoid-simple-tags!
|
45
|
+
rspec (~> 2.10.0)
|
data/lib/mongoid-simple-tags.rb
CHANGED
@@ -3,7 +3,7 @@ module Mongoid
|
|
3
3
|
module Taggable
|
4
4
|
def self.included(base)
|
5
5
|
base.class_eval do |klass|
|
6
|
-
klass.field :tags, :type => Array, :default => []
|
6
|
+
klass.field :tags, :type => Array, :default => []
|
7
7
|
klass.index({ tags: 1 }, { background: true })
|
8
8
|
|
9
9
|
include InstanceMethods
|
@@ -29,11 +29,11 @@ module Mongoid
|
|
29
29
|
|
30
30
|
module ClassMethods
|
31
31
|
|
32
|
-
def all_tags(
|
32
|
+
def all_tags(scope = {})
|
33
33
|
map = %Q{
|
34
34
|
function() {
|
35
|
-
if(this.tags
|
36
|
-
this.tags
|
35
|
+
if(this.tags){
|
36
|
+
this.tags.forEach(function(tag){
|
37
37
|
emit(tag, 1)
|
38
38
|
});
|
39
39
|
}
|
data/mongoid-simple-tags.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "mongoid-simple-tags"
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.3"
|
6
6
|
s.platform = Gem::Platform::RUBY
|
7
7
|
s.authors = ["chebyte"]
|
8
8
|
s.email = ["maurotorres@gmail.com"]
|
@@ -16,6 +16,8 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
s.require_paths = ["lib"]
|
19
|
-
s.add_development_dependency "rspec", "~> 2.
|
19
|
+
s.add_development_dependency "rspec", "~> 2.13.0"
|
20
20
|
s.add_dependency "mongoid", ">= 3.0.3"
|
21
|
+
s.add_dependency "json", "~> 1.8"
|
22
|
+
|
21
23
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
puts Mongoid::VERSION
|
4
|
+
|
3
5
|
class User
|
4
6
|
include Mongoid::Document
|
5
7
|
include Mongoid::Document::Taggable
|
@@ -106,14 +108,14 @@ describe "A Taggable model with scope" do
|
|
106
108
|
end
|
107
109
|
|
108
110
|
it "should return scoped tags when passing one option" do
|
109
|
-
results = User.all_tags(
|
111
|
+
results = User.all_tags(organization_id: @organization_1.id)
|
110
112
|
results.empty?.should be_false
|
111
113
|
|
112
114
|
results.include?( {:name => "linux", :count => 2 } ).should be_true
|
113
115
|
results.include?( {:name => "ubuntu", :count => 2 } ).should be_true
|
114
116
|
results.include?( {:name => "tucuman", :count => 2 } ).should be_true
|
115
117
|
|
116
|
-
results = User.all_tags(
|
118
|
+
results = User.all_tags(organization_id: @organization_2.id)
|
117
119
|
results.empty?.should be_false
|
118
120
|
results.include?( {:name =>"linux", :count => 1 } ).should be_true
|
119
121
|
results.include?( {:name => "microsoft", :count => 1 } ).should be_true
|
@@ -122,7 +124,7 @@ describe "A Taggable model with scope" do
|
|
122
124
|
end
|
123
125
|
|
124
126
|
it "should return scoped tags when passing more than one option" do
|
125
|
-
results = User.all_tags(
|
127
|
+
results = User.all_tags(organization_id: @organization_1.id, name: @user_1.name)
|
126
128
|
|
127
129
|
results.empty?.should be_false
|
128
130
|
results.include?( {:name => "linux", :count => 1 } ).should be_true
|
@@ -131,7 +133,7 @@ describe "A Taggable model with scope" do
|
|
131
133
|
end
|
132
134
|
|
133
135
|
it "should return scoped tags when calling deprecated scoped_tags method" do
|
134
|
-
results = User.all_tags(
|
136
|
+
results = User.all_tags(organization_id: @organization_1.id)
|
135
137
|
|
136
138
|
results.empty?.should be_false
|
137
139
|
results.include?( {:name => "linux", :count => 2 } ).should be_true
|
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.1.
|
4
|
+
version: 0.1.3
|
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: 2013-05-
|
12
|
+
date: 2013-05-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.
|
21
|
+
version: 2.13.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.
|
29
|
+
version: 2.13.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: mongoid
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 3.0.3
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: json
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.8'
|
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.8'
|
46
62
|
description: basic and simple tagging system for mongoid using map-reduce function
|
47
63
|
email:
|
48
64
|
- maurotorres@gmail.com
|
@@ -59,6 +75,9 @@ files:
|
|
59
75
|
- README.rdoc
|
60
76
|
- Rakefile
|
61
77
|
- VERSION
|
78
|
+
- donate.png
|
79
|
+
- gemfiles/mongoid-3.1.gemfile
|
80
|
+
- gemfiles/mongoid-3.1.gemfile.lock
|
62
81
|
- lib/mongoid-simple-tags.rb
|
63
82
|
- mongoid-simple-tags.gemspec
|
64
83
|
- mongoid.yml
|