mongoid_tag 0.0.1
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/Gemfile +21 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +34 -0
- data/Rakefile +2 -0
- data/VERSION +1 -0
- data/init.rb +1 -0
- data/lib/mongoid_tag.rb +3 -0
- data/lib/mongoid_tag/meta.rb +75 -0
- data/lib/mongoid_tag/meta_tag.rb +12 -0
- data/lib/mongoid_tag/tag.rb +121 -0
- data/mongoid_tag.gemspec +60 -0
- data/spec/mongoid_tag_spec.rb +139 -0
- data/spec/spec_helper.rb +24 -0
- metadata +195 -0
data/Gemfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'mongoid', '~> 2.1.0'
|
4
|
+
|
5
|
+
# Add dependencies to develop your gem here.
|
6
|
+
# Include everything needed to run rake, tests, features, etc.
|
7
|
+
|
8
|
+
group :development do
|
9
|
+
|
10
|
+
gem 'database_cleaner'
|
11
|
+
gem 'bson', '~> 1.3.0'
|
12
|
+
gem 'bson_ext', '~> 1.3.0'
|
13
|
+
gem 'rspec', '~> 2.3.0'
|
14
|
+
gem 'yard', '~> 0.6.0'
|
15
|
+
gem 'bundler', '~> 1.0.0'
|
16
|
+
gem 'jeweler', '~> 1.5.2'
|
17
|
+
gem 'rcov', '>= 0'
|
18
|
+
gem 'reek', '~> 1.2.8'
|
19
|
+
gem 'roodi', '~> 2.1.0'
|
20
|
+
|
21
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Christian Hager
|
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.rdoc
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
= Mongoid Tag
|
2
|
+
|
3
|
+
This gem is heaviliy influenced by Aaron Qians mongoid_taggable_with_context gem. I needed a way to tag a model and let a contextual scope of that model hold meta-data about the tags.
|
4
|
+
|
5
|
+
In example: when I tag a product with "nice", I wanted the products category to know how many products was tagged with "nice". I also wanted to store additional data about this tag such as color (i.e colored labels on gmail.)
|
6
|
+
|
7
|
+
Since I have never written a gem before, this is also an attempt to do so and learn from it.
|
8
|
+
|
9
|
+
== Usage
|
10
|
+
|
11
|
+
class Product
|
12
|
+
include Mongoid::Document
|
13
|
+
include Mongoid::Tag
|
14
|
+
belongs_to :category
|
15
|
+
tag :tags, :meta_in => :category
|
16
|
+
end
|
17
|
+
|
18
|
+
class Category
|
19
|
+
include Mongoid::Document
|
20
|
+
include Mongoid::Tag::Meta
|
21
|
+
tag_meta_for :tags
|
22
|
+
end
|
23
|
+
|
24
|
+
@c = Category.create
|
25
|
+
@product = Product.create(:tags => "new, expensive", :category => @c)
|
26
|
+
|
27
|
+
@product.tags => ["new", "expensive"]
|
28
|
+
|
29
|
+
@category.tags_with_weight => [["new", 1], ["expensive", 1]]
|
30
|
+
|
31
|
+
@category.add_tag("on sale", {:color => "#a2a2a2"}) #add any meta you want
|
32
|
+
|
33
|
+
@category.tags_with_meta => [["new", {:count => 1}], ["expensive", {:count => 1}], ["on sale", {:count => 0, :color => "#a2a2a2"}]]
|
34
|
+
|
data/Rakefile
ADDED
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'mongoid_tag'
|
data/lib/mongoid_tag.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
module Mongoid
|
2
|
+
module Tag
|
3
|
+
module Meta
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
embeds_many :meta_tags, :as => :meta_tagable, :class_name => "Mongoid::Tag::MetaTag"
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
|
12
|
+
def tagmeta_for(*args)
|
13
|
+
field_name = (args.blank? ? :tags : args.shift).to_sym
|
14
|
+
|
15
|
+
class_eval %(
|
16
|
+
def #{field_name}_with_weight
|
17
|
+
get_weights_for(:#{field_name})
|
18
|
+
end
|
19
|
+
|
20
|
+
def #{field_name}_with_meta
|
21
|
+
get_meta_for(:#{field_name})
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_#{field_name.to_s.chop.to_sym}(tag, meta={})
|
25
|
+
add_meta_tag(:#{field_name}, tag, meta)
|
26
|
+
end
|
27
|
+
)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
module InstanceMethods
|
32
|
+
def get_weights_for(context)
|
33
|
+
meta_tags.where(:context => context).map{|tag| [tag.name, tag.count]}
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_meta_for(context)
|
37
|
+
meta_tags.where(:context => context).map{|tag| [tag.name, tag.meta.merge(:count => tag.count)]}
|
38
|
+
end
|
39
|
+
|
40
|
+
def update_meta_tags(context, added=nil, removed=nil)
|
41
|
+
add_meta_tags(context, added) if added
|
42
|
+
remove_meta_tags(context, removed) if removed
|
43
|
+
save
|
44
|
+
end
|
45
|
+
|
46
|
+
def add_meta_tag(context, tag, meta)
|
47
|
+
old_tag = self.meta_tags.where(:name => tag, :context => context).first
|
48
|
+
if old_tag
|
49
|
+
old_tag.meta.merge!(meta)
|
50
|
+
else
|
51
|
+
self.meta_tags << MetaTag.new(:name => tag, :count => 1, :context => context, :meta => meta)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def add_meta_tags(context, tags)
|
56
|
+
tags.each do |tag|
|
57
|
+
old_tag = self.meta_tags.where(:name => tag, :context => context).first
|
58
|
+
if old_tag
|
59
|
+
old_tag.count += 1
|
60
|
+
else
|
61
|
+
self.meta_tags << MetaTag.new(:name => tag, :count => 1, :context => context)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def remove_meta_tags(context, tags)
|
67
|
+
tags.each do |tag|
|
68
|
+
old_tag = self.meta_tags.where(:name => tag, :context => context).first
|
69
|
+
old_tag.count -= 1 if old_tag
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Mongoid
|
2
|
+
module Tag
|
3
|
+
class MetaTag
|
4
|
+
include Mongoid::Document
|
5
|
+
field :name, :type => String
|
6
|
+
field :count, :type => Integer, :default => 0
|
7
|
+
field :context
|
8
|
+
field :meta, :type => Hash, :default => {}
|
9
|
+
embedded_in :meta_tagable, :polymorphic => true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
module Mongoid
|
2
|
+
module Tag
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
class_attribute :tagify_options
|
7
|
+
self.tagify_options = {}
|
8
|
+
after_save :update_meta_model
|
9
|
+
after_destroy :decrement_all_in_meta_model
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
def tag(*args)
|
14
|
+
options = args.extract_options!
|
15
|
+
field_name = (options.empty? ? :tags : args.shift).to_sym
|
16
|
+
array_field = "#{field_name}_array".to_sym
|
17
|
+
|
18
|
+
#set default options
|
19
|
+
options.reverse_merge!({
|
20
|
+
:array_field => array_field
|
21
|
+
})
|
22
|
+
|
23
|
+
# register / update settings
|
24
|
+
class_options = tagify_options || {}
|
25
|
+
class_options[field_name] = options
|
26
|
+
self.tagify_options = class_options
|
27
|
+
|
28
|
+
#create fields
|
29
|
+
field field_name, :type => String, :default => ""
|
30
|
+
field array_field, :type => Array, :default => []
|
31
|
+
|
32
|
+
#class methods
|
33
|
+
class_eval %(
|
34
|
+
class << self
|
35
|
+
def with_any_#{field_name}(tags)
|
36
|
+
any_in(:#{array_field} => tags.to_a)
|
37
|
+
end
|
38
|
+
|
39
|
+
def with_all_#{field_name}(tags)
|
40
|
+
all_in(:#{array_field} => tags.to_a)
|
41
|
+
end
|
42
|
+
|
43
|
+
def without_#{field_name}(tags)
|
44
|
+
not_in(:#{array_field} => tags.to_a)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
)
|
48
|
+
|
49
|
+
#instance methods
|
50
|
+
class_eval %(
|
51
|
+
def #{field_name}=(s)
|
52
|
+
super
|
53
|
+
write_attribute(:#{array_field}, convert_string_to_array(s))
|
54
|
+
end
|
55
|
+
|
56
|
+
def #{array_field}=(a)
|
57
|
+
super
|
58
|
+
write_attribute(:#{field_name}, convert_array_to_string(a))
|
59
|
+
end
|
60
|
+
)
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
module InstanceMethods
|
66
|
+
|
67
|
+
attr :current_context
|
68
|
+
|
69
|
+
def convert_string_to_array(s)
|
70
|
+
s.split(",").map(&:strip)
|
71
|
+
end
|
72
|
+
|
73
|
+
def convert_array_to_string(a)
|
74
|
+
a.map(&:strip).join(", ")
|
75
|
+
end
|
76
|
+
|
77
|
+
def tag_contexts
|
78
|
+
tagify_options.keys
|
79
|
+
end
|
80
|
+
|
81
|
+
def tags_for_context
|
82
|
+
send("#{@current_context}_array".to_sym)
|
83
|
+
end
|
84
|
+
|
85
|
+
def context_has_meta_model?
|
86
|
+
!tagify_options[@current_context][:meta_in].blank?
|
87
|
+
end
|
88
|
+
|
89
|
+
def context_meta_model
|
90
|
+
send(tagify_options[@current_context][:meta_in])
|
91
|
+
end
|
92
|
+
|
93
|
+
def context_is_changed?
|
94
|
+
!changes[@current_context.to_s].blank?
|
95
|
+
end
|
96
|
+
|
97
|
+
def context_added_tags
|
98
|
+
tags_for_context - changes[@current_context.to_s][0].split(",").map(&:strip)
|
99
|
+
end
|
100
|
+
|
101
|
+
def context_removed_tags
|
102
|
+
changes[@current_context.to_s][0].split(",").map(&:strip) - tags_for_context
|
103
|
+
end
|
104
|
+
|
105
|
+
def update_meta_model
|
106
|
+
tag_contexts.each do |context|
|
107
|
+
@current_context = context
|
108
|
+
if context_is_changed? && context_has_meta_model?
|
109
|
+
context_meta_model.update_meta_tags(context, context_added_tags, context_removed_tags)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def decrement_all_in_meta_model
|
115
|
+
tag_contexts.each do |context|
|
116
|
+
context_meta_model.update_meta_tags(context, nil, tags_for_context)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
data/mongoid_tag.gemspec
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "mongoid_tag/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "mongoid_tag"
|
7
|
+
s.version = MongoidTag::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Christian Hager"]
|
10
|
+
s.email = ["christian@rondeventure.com"]
|
11
|
+
s.homepage = %q{http://github.com/aq1018/mongoid_taggable_with_context}
|
12
|
+
s.summary = %q{Mongoid tagging with scope and meta}
|
13
|
+
s.description = %q{Mongoid tagging gem that holds meta about tags in a scoped context.}
|
14
|
+
|
15
|
+
s.licenses = ["MIT"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
|
18
|
+
s.rubygems_version = %q{1.6.2}
|
19
|
+
|
20
|
+
s.extra_rdoc_files = [
|
21
|
+
"LICENSE.txt",
|
22
|
+
"README.rdoc"
|
23
|
+
]
|
24
|
+
|
25
|
+
s.files = [
|
26
|
+
"Gemfile",
|
27
|
+
"LICENSE.txt",
|
28
|
+
"README.rdoc",
|
29
|
+
"Rakefile",
|
30
|
+
"VERSION",
|
31
|
+
"init.rb",
|
32
|
+
"lib/mongoid_tag/tag.rb",
|
33
|
+
"lib/mongoid_tag/meta.rb",
|
34
|
+
"lib/mongoid_tag/meta_tag.rb",
|
35
|
+
"lib/mongoid_tag.rb",
|
36
|
+
"mongoid_tag.gemspec",
|
37
|
+
"spec/mongoid_tag_spec.rb",
|
38
|
+
"spec/spec_helper.rb"
|
39
|
+
]
|
40
|
+
|
41
|
+
s.test_files = [
|
42
|
+
"spec/mongoid_tag_spec.rb",
|
43
|
+
"spec/spec_helper.rb"
|
44
|
+
]
|
45
|
+
|
46
|
+
s.add_development_dependency(%q<database_cleaner>, [">= 0"])
|
47
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
|
48
|
+
s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
|
49
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
50
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
51
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<reek>, ["~> 1.2.8"])
|
53
|
+
s.add_development_dependency(%q<roodi>, ["~> 2.1.0"])
|
54
|
+
|
55
|
+
s.add_dependency(%q<mongoid>, ["~> 2.1.0"])
|
56
|
+
s.add_dependency(%q<bson>, ["~> 1.3.0"])
|
57
|
+
s.add_dependency(%q<bson_ext>, ["~> 1.3.0"])
|
58
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class Product
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Tag
|
6
|
+
|
7
|
+
tag :tags
|
8
|
+
end
|
9
|
+
|
10
|
+
class ProductWithCategory
|
11
|
+
include Mongoid::Document
|
12
|
+
include Mongoid::Tag
|
13
|
+
|
14
|
+
belongs_to :category
|
15
|
+
|
16
|
+
tag :tags, :meta_in => :category
|
17
|
+
end
|
18
|
+
|
19
|
+
class Category
|
20
|
+
include Mongoid::Document
|
21
|
+
include Mongoid::Tag::Meta
|
22
|
+
|
23
|
+
has_many :products
|
24
|
+
|
25
|
+
tagmeta_for :tags
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
describe Mongoid::Tag do
|
30
|
+
|
31
|
+
describe "tagged object" do
|
32
|
+
before(:each) do
|
33
|
+
@p1 = Product.new
|
34
|
+
@p2 = Product.new
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should create a tags_array" do
|
38
|
+
@p1.tags = "new, blue"
|
39
|
+
@p1.tags_array.should == ["new", "blue"]
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should create a string from array" do
|
43
|
+
@p1.tags_array = ["new", "blue"]
|
44
|
+
@p1.tags.should == "new, blue"
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should wash away whitespace" do
|
48
|
+
@p1.tags = "new , blue"
|
49
|
+
@p1.tags_array.should == ["new", "blue"]
|
50
|
+
@p1.tags_array = ["new ", " blue"]
|
51
|
+
@p1.tags.should == "new, blue"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "scopes" do
|
56
|
+
before(:each) do
|
57
|
+
@p1 = Product.create
|
58
|
+
@p2 = Product.create
|
59
|
+
end
|
60
|
+
|
61
|
+
it "finds all models tagged with one or more tags" do
|
62
|
+
@p1.tags = "new, green"
|
63
|
+
@p2.tags = "new, blue"
|
64
|
+
@p1.save; @p2.save;
|
65
|
+
Product.with_any_tags("new").to_a.should == [@p1, @p2]
|
66
|
+
Product.with_any_tags("green").to_a.should == [@p1]
|
67
|
+
Product.with_any_tags("blue").to_a.should == [@p2]
|
68
|
+
Product.with_any_tags(["new", "blue"]).to_a.should == [@p1, @p2]
|
69
|
+
end
|
70
|
+
|
71
|
+
it "finds all models tagged with one or more tags" do
|
72
|
+
@p1.tags = "new, green"
|
73
|
+
@p2.tags = "new, blue"
|
74
|
+
@p1.save; @p2.save;
|
75
|
+
Product.with_all_tags("new").to_a.should == [@p1, @p2]
|
76
|
+
Product.with_all_tags("green").to_a.should == [@p1]
|
77
|
+
Product.with_all_tags("blue").to_a.should == [@p2]
|
78
|
+
Product.with_all_tags(["new", "blue"]).to_a.should == [@p2]
|
79
|
+
end
|
80
|
+
|
81
|
+
it "fonds all models not tagged with one or more tags" do
|
82
|
+
@p1.tags = "new, green"
|
83
|
+
@p2.tags = "new, blue"
|
84
|
+
@p1.save; @p2.save;
|
85
|
+
Product.without_tags("new").to_a.should == []
|
86
|
+
Product.without_tags("green").to_a.should == [@p2]
|
87
|
+
Product.without_tags("blue").to_a.should == [@p1]
|
88
|
+
Product.without_tags(["new", "blue"]).to_a.should == []
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
describe Mongoid::Tag::Meta do
|
95
|
+
|
96
|
+
before(:each) do
|
97
|
+
@c = Category.create
|
98
|
+
@p = ProductWithCategory.create(:category => @c)
|
99
|
+
@p2 = ProductWithCategory.create(:category => @c)
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should increase count when a a child is tagged" do
|
103
|
+
@p.update_attributes(:tags => "new, blue")
|
104
|
+
@c.tags_with_weight.should == [["new", 1], ["blue", 1]]
|
105
|
+
@p2.update_attributes(:tags => "blue")
|
106
|
+
@c.tags_with_weight.should == [["new", 1], ["blue", 2]]
|
107
|
+
@p2.update_attributes(:tags => "blue, green")
|
108
|
+
@c.tags_with_weight.should == [["new", 1], ["blue", 2], ["green", 1]]
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should decrease count when a tag is removed" do
|
112
|
+
@p.update_attributes(:tags => "new, blue")
|
113
|
+
@c.tags_with_weight.should == [["new", 1], ["blue", 1]]
|
114
|
+
@p.update_attributes(:tags => "new")
|
115
|
+
@c.tags_with_weight.should == [["new", 1], ["blue", 0]]
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should decrease count when a child is destroyed" do
|
119
|
+
@p.update_attributes(:tags => "new, blue")
|
120
|
+
@c.tags_with_weight.should == [["new", 1], ["blue", 1]]
|
121
|
+
@p.destroy
|
122
|
+
@c.tags_with_weight.should == [["new", 0], ["blue", 0]]
|
123
|
+
end
|
124
|
+
|
125
|
+
it "can get the meta for all tags" do
|
126
|
+
@c.add_tag("cheap", {:color => "red"})
|
127
|
+
@c.tags_with_meta.should == [["cheap", {:color=>"red", :count=>1}]]
|
128
|
+
@c.add_tag("expensive", {:color => "green"})
|
129
|
+
@c.add_tag("medium", {:color => "#ddd"})
|
130
|
+
@c.tags_with_meta.should == [["cheap", {:color=>"red", :count=>1}], ["expensive", {:color=>"green", :count=>1}], ["medium", {:color=>"#ddd", :count=>1}]]
|
131
|
+
end
|
132
|
+
|
133
|
+
it "can update meta for a tag" do
|
134
|
+
@c.add_tag("cheap", {:color => "red"})
|
135
|
+
@c.tags_with_meta.should == [["cheap", {:color=>"red", :count=>1}]]
|
136
|
+
@c.add_tag("cheap", {:color => "blue"})
|
137
|
+
@c.tags_with_meta.should == [["cheap", {:color=>"blue", :count=>1}]]
|
138
|
+
end
|
139
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
require 'mongoid'
|
6
|
+
require 'mongoid_tag.rb'
|
7
|
+
require 'database_cleaner'
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
|
11
|
+
config.before(:suite) do
|
12
|
+
DatabaseCleaner.strategy = :truncation
|
13
|
+
end
|
14
|
+
|
15
|
+
config.after(:each) do
|
16
|
+
DatabaseCleaner.clean
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
Mongoid.configure do |config|
|
22
|
+
config.skip_version_check = true
|
23
|
+
config.master = Mongo::Connection.new.db("mongoid_tag_test")
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,195 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mongoid_tag
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Christian Hager
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-09-07 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: database_cleaner
|
16
|
+
requirement: &2160316240 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2160316240
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &2160315400 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.3.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2160315400
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: yard
|
38
|
+
requirement: &2160314720 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.6.0
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2160314720
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: &2160314060 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.0
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2160314060
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: jeweler
|
60
|
+
requirement: &2160313440 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.5.2
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2160313440
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rcov
|
71
|
+
requirement: &2160312720 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2160312720
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: reek
|
82
|
+
requirement: &2160311160 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 1.2.8
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *2160311160
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: roodi
|
93
|
+
requirement: &2160310440 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ~>
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 2.1.0
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *2160310440
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: mongoid
|
104
|
+
requirement: &2160309720 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 2.1.0
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *2160309720
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: bson
|
115
|
+
requirement: &2160309000 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ~>
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 1.3.0
|
121
|
+
type: :runtime
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: *2160309000
|
124
|
+
- !ruby/object:Gem::Dependency
|
125
|
+
name: bson_ext
|
126
|
+
requirement: &2160308280 !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ~>
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.3.0
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: *2160308280
|
135
|
+
- !ruby/object:Gem::Dependency
|
136
|
+
name: bundler
|
137
|
+
requirement: &2160307560 !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ~>
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: 1.0.0
|
143
|
+
type: :runtime
|
144
|
+
prerelease: false
|
145
|
+
version_requirements: *2160307560
|
146
|
+
description: Mongoid tagging gem that holds meta about tags in a scoped context.
|
147
|
+
email:
|
148
|
+
- christian@rondeventure.com
|
149
|
+
executables: []
|
150
|
+
extensions: []
|
151
|
+
extra_rdoc_files:
|
152
|
+
- LICENSE.txt
|
153
|
+
- README.rdoc
|
154
|
+
files:
|
155
|
+
- Gemfile
|
156
|
+
- LICENSE.txt
|
157
|
+
- README.rdoc
|
158
|
+
- Rakefile
|
159
|
+
- VERSION
|
160
|
+
- init.rb
|
161
|
+
- lib/mongoid_tag/tag.rb
|
162
|
+
- lib/mongoid_tag/meta.rb
|
163
|
+
- lib/mongoid_tag/meta_tag.rb
|
164
|
+
- lib/mongoid_tag.rb
|
165
|
+
- mongoid_tag.gemspec
|
166
|
+
- spec/mongoid_tag_spec.rb
|
167
|
+
- spec/spec_helper.rb
|
168
|
+
homepage: http://github.com/aq1018/mongoid_taggable_with_context
|
169
|
+
licenses:
|
170
|
+
- MIT
|
171
|
+
post_install_message:
|
172
|
+
rdoc_options: []
|
173
|
+
require_paths:
|
174
|
+
- lib
|
175
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
+
none: false
|
177
|
+
requirements:
|
178
|
+
- - ! '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
none: false
|
183
|
+
requirements:
|
184
|
+
- - ! '>='
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
requirements: []
|
188
|
+
rubyforge_project:
|
189
|
+
rubygems_version: 1.8.8
|
190
|
+
signing_key:
|
191
|
+
specification_version: 3
|
192
|
+
summary: Mongoid tagging with scope and meta
|
193
|
+
test_files:
|
194
|
+
- spec/mongoid_tag_spec.rb
|
195
|
+
- spec/spec_helper.rb
|