mongoid_taggable_with_context-meta 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +81 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +64 -0
- data/LICENSE.txt +20 -0
- data/README +0 -0
- data/README.md +169 -0
- data/Rakefile +35 -0
- data/VERSION +1 -0
- data/lib/mongoid_taggable_with_context/meta.rb +59 -0
- data/lib/mongoid_taggable_with_context/meta_tag.rb +13 -0
- data/lib/mongoid_taggable_with_context-meta.rb +3 -0
- data/mongoid_taggable_with_context-meta.gemspec +87 -0
- data/spec/mongoid_taggable_with_context_with_meta_spec.rb +87 -0
- data/spec/spec_helper.rb +24 -0
- metadata +196 -0
data/.rvmrc
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
|
7
|
+
environment_id="ruby-1.9.3-p125@mongoid_taggable_with_context-meta"
|
8
|
+
|
9
|
+
#
|
10
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
11
|
+
#
|
12
|
+
# rvmrc_rvm_version="1.10.2" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
#
|
18
|
+
|
19
|
+
#
|
20
|
+
# Uncomment following line if you want options to be set only for given project.
|
21
|
+
#
|
22
|
+
# PROJECT_JRUBY_OPTS=( --1.9 )
|
23
|
+
#
|
24
|
+
# The variable PROJECT_JRUBY_OPTS requires the following to be run in shell:
|
25
|
+
#
|
26
|
+
# chmod +x ${rvm_path}/hooks/after_use_jruby_opts
|
27
|
+
#
|
28
|
+
|
29
|
+
#
|
30
|
+
# First we attempt to load the desired environment directly from the environment
|
31
|
+
# file. This is very fast and efficient compared to running through the entire
|
32
|
+
# CLI and selector. If you want feedback on which environment was used then
|
33
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
34
|
+
#
|
35
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
|
36
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
37
|
+
then
|
38
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
39
|
+
|
40
|
+
if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
|
41
|
+
then
|
42
|
+
. "${rvm_path:-$HOME/.rvm}/hooks/after_use"
|
43
|
+
fi
|
44
|
+
else
|
45
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
46
|
+
if ! rvm --create "$environment_id"
|
47
|
+
then
|
48
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
49
|
+
return 1
|
50
|
+
fi
|
51
|
+
fi
|
52
|
+
|
53
|
+
#
|
54
|
+
# If you use an RVM gemset file to install a list of gems (*.gems), you can have
|
55
|
+
# it be automatically loaded. Uncomment the following and adjust the filename if
|
56
|
+
# necessary.
|
57
|
+
#
|
58
|
+
# filename=".gems"
|
59
|
+
# if [[ -s "$filename" ]]
|
60
|
+
# then
|
61
|
+
# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
|
62
|
+
# fi
|
63
|
+
|
64
|
+
# If you use bundler, this might be useful to you:
|
65
|
+
# if [[ -s Gemfile ]] && ! command -v bundle >/dev/null
|
66
|
+
# then
|
67
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
68
|
+
# gem install bundler
|
69
|
+
# fi
|
70
|
+
# if [[ -s Gemfile ]] && command -v bundle
|
71
|
+
# then
|
72
|
+
# bundle install
|
73
|
+
# fi
|
74
|
+
|
75
|
+
if [[ $- == *i* ]] # check for interactive shells
|
76
|
+
then
|
77
|
+
echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
|
78
|
+
else
|
79
|
+
echo "Using: $GEM_HOME" # don't use colors in interactive shells
|
80
|
+
fi
|
81
|
+
|
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'mongo', '~> 1.5.2'
|
4
|
+
gem "mongoid", "= 2.4.4"
|
5
|
+
gem 'mongoid_taggable_with_context'
|
6
|
+
|
7
|
+
# Add dependencies to develop your gem here.
|
8
|
+
# Include everything needed to run rake, tests, features, etc.
|
9
|
+
group :development do
|
10
|
+
gem 'database_cleaner'
|
11
|
+
gem 'bson', '~> 1.5.2'
|
12
|
+
gem 'bson_ext', '~> 1.5.2'
|
13
|
+
gem 'rspec'
|
14
|
+
gem 'mongoid-rspec'
|
15
|
+
gem 'yard'
|
16
|
+
gem 'bundler', '>= 1.0.0'
|
17
|
+
gem 'jeweler'
|
18
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activemodel (3.2.1)
|
5
|
+
activesupport (= 3.2.1)
|
6
|
+
builder (~> 3.0.0)
|
7
|
+
activesupport (3.2.1)
|
8
|
+
i18n (~> 0.6)
|
9
|
+
multi_json (~> 1.0)
|
10
|
+
bson (1.5.2)
|
11
|
+
bson_ext (1.5.2)
|
12
|
+
bson (= 1.5.2)
|
13
|
+
builder (3.0.0)
|
14
|
+
database_cleaner (0.7.1)
|
15
|
+
diff-lcs (1.1.3)
|
16
|
+
git (1.2.5)
|
17
|
+
i18n (0.6.0)
|
18
|
+
jeweler (1.8.3)
|
19
|
+
bundler (~> 1.0)
|
20
|
+
git (>= 1.2.5)
|
21
|
+
rake
|
22
|
+
rdoc
|
23
|
+
json (1.6.5)
|
24
|
+
mongo (1.5.2)
|
25
|
+
bson (= 1.5.2)
|
26
|
+
mongoid (2.4.4)
|
27
|
+
activemodel (~> 3.1)
|
28
|
+
mongo (~> 1.3)
|
29
|
+
tzinfo (~> 0.3.22)
|
30
|
+
mongoid-rspec (1.4.4)
|
31
|
+
mongoid (~> 2.0)
|
32
|
+
rspec (~> 2)
|
33
|
+
mongoid_taggable_with_context (0.8.0)
|
34
|
+
mongoid (>= 2.0.0)
|
35
|
+
multi_json (1.1.0)
|
36
|
+
rake (0.9.2.2)
|
37
|
+
rdoc (3.12)
|
38
|
+
json (~> 1.4)
|
39
|
+
rspec (2.8.0)
|
40
|
+
rspec-core (~> 2.8.0)
|
41
|
+
rspec-expectations (~> 2.8.0)
|
42
|
+
rspec-mocks (~> 2.8.0)
|
43
|
+
rspec-core (2.8.0)
|
44
|
+
rspec-expectations (2.8.0)
|
45
|
+
diff-lcs (~> 1.1.2)
|
46
|
+
rspec-mocks (2.8.0)
|
47
|
+
tzinfo (0.3.31)
|
48
|
+
yard (0.7.5)
|
49
|
+
|
50
|
+
PLATFORMS
|
51
|
+
ruby
|
52
|
+
|
53
|
+
DEPENDENCIES
|
54
|
+
bson (~> 1.5.2)
|
55
|
+
bson_ext (~> 1.5.2)
|
56
|
+
bundler (>= 1.0.0)
|
57
|
+
database_cleaner
|
58
|
+
jeweler
|
59
|
+
mongo (~> 1.5.2)
|
60
|
+
mongoid (= 2.4.4)
|
61
|
+
mongoid-rspec
|
62
|
+
mongoid_taggable_with_context
|
63
|
+
rspec
|
64
|
+
yard
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Maik Vlcek
|
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
File without changes
|
data/README.md
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
mongoid_taggable_with_context-meta
|
2
|
+
=============================
|
3
|
+
|
4
|
+
NOTE: this is in IMPLEMENTAION PHASE: Not supposed to work right now
|
5
|
+
|
6
|
+
[![Build Status](https://secure.travis-ci.org/mediavrog/mongoid_taggable_with_context-meta.png?branch=master)](http://travis-ci.org/mediavrog/mongoid_taggable_with_context-meta) [![Dependency Status](https://gemnasium.com/mediavrog/mongoid_taggable_with_context-meta.png?travis)](https://gemnasium.com/mediavrog/mongoid_taggable_with_context-meta)
|
7
|
+
|
8
|
+
Extends mongoid_taggable_with_context with support to attach meta information to tags.
|
9
|
+
|
10
|
+
Installation
|
11
|
+
------------
|
12
|
+
|
13
|
+
You can simply install from rubygems:
|
14
|
+
|
15
|
+
```
|
16
|
+
gem install mongoid_taggable_with_context-meta
|
17
|
+
```
|
18
|
+
|
19
|
+
or in Gemfile:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gem 'mongoid_taggable_with_context-meta'
|
23
|
+
```
|
24
|
+
|
25
|
+
TODO from here
|
26
|
+
|
27
|
+
Basic Usage
|
28
|
+
-----------
|
29
|
+
|
30
|
+
To make a document taggable you need to include Mongoid::TaggableOnContext into your document and call the *taggable* macro with optional arguments:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
class Post
|
34
|
+
include Mongoid::Document
|
35
|
+
include Mongoid::TaggableWithContext
|
36
|
+
|
37
|
+
field :title
|
38
|
+
field :content
|
39
|
+
|
40
|
+
# default context is 'tags'.
|
41
|
+
# This creates #tags, #tags=, #tags_array, #tags_array= instance methods
|
42
|
+
# separator is " " by default
|
43
|
+
# #tags method returns space separated string
|
44
|
+
# #tags= methods accepts space separated string
|
45
|
+
# #tags_array method returns an array of tags
|
46
|
+
# #tags_array= method accepts an array of tags
|
47
|
+
# #tags and #tags_array are automatically synched.
|
48
|
+
taggable
|
49
|
+
|
50
|
+
# tagging for 'interests' context.
|
51
|
+
# This creates #interests, #interests=, #interests_array, #interests_array= instance methods
|
52
|
+
taggable :interests
|
53
|
+
|
54
|
+
# tagging for 'skills' context.
|
55
|
+
# This creates #skills, #skills=, #skills_array, #skills_array= instance methods
|
56
|
+
# changing tag separator to "," (Default is " ")
|
57
|
+
taggable :skills, :separator => ','
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
61
|
+
Then in your form, for example:
|
62
|
+
|
63
|
+
```rhtml
|
64
|
+
<% form_for @post do |f| %>
|
65
|
+
<p>
|
66
|
+
<%= f.label :title %><br />
|
67
|
+
<%= f.text_field :title %>
|
68
|
+
</p>
|
69
|
+
<p>
|
70
|
+
<%= f.label :content %><br />
|
71
|
+
<%= f.text_area :content %>
|
72
|
+
</p>
|
73
|
+
<p>
|
74
|
+
<%= f.label :tags %><br />
|
75
|
+
<%= text_field_tag 'post[tags]' %>
|
76
|
+
</p>
|
77
|
+
<p>
|
78
|
+
<%= f.label :interests %><br />
|
79
|
+
<%= text_field_tag 'post[interests]' %>
|
80
|
+
</p>
|
81
|
+
<p>
|
82
|
+
<%= f.label :skills %><br />
|
83
|
+
<%= text_field_tag 'post[skills]' %>
|
84
|
+
</p>
|
85
|
+
<p>
|
86
|
+
<button type="submit">Send</button>
|
87
|
+
</p>
|
88
|
+
<% end %>
|
89
|
+
```
|
90
|
+
|
91
|
+
Aggregation Strategies
|
92
|
+
----------------------
|
93
|
+
|
94
|
+
By including an aggregation strategy in your document, tag aggregations will be automatically available to you.
|
95
|
+
This lib presents the following aggregation strategies:
|
96
|
+
|
97
|
+
* MapReduce
|
98
|
+
* RealTime
|
99
|
+
|
100
|
+
The following document will automatically aggregate counts on all tag contexts.
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
class Post
|
104
|
+
include Mongoid::Document
|
105
|
+
include Mongoid::TaggableWithContext
|
106
|
+
|
107
|
+
# automatically adds real time aggregations to all tag contexts
|
108
|
+
include Mongoid::TaggableWithContext::AggregationStrategy::RealTime
|
109
|
+
|
110
|
+
# alternatively for map-reduce
|
111
|
+
# include Mongoid::TaggableWithContext::AggregationStrategy::MapReduce
|
112
|
+
|
113
|
+
field :title
|
114
|
+
field :content
|
115
|
+
|
116
|
+
taggable
|
117
|
+
taggable :interests
|
118
|
+
taggable :skills, :separator => ','
|
119
|
+
end
|
120
|
+
```
|
121
|
+
|
122
|
+
When you include an aggregation strategy, your document also gains a few extra methods to retrieve aggregation data.
|
123
|
+
In the case of previous example the following methods are included:
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
Post.tags
|
127
|
+
Post.tags_with_weight
|
128
|
+
Post.interests
|
129
|
+
Post.interests_with_weight
|
130
|
+
Post.skills
|
131
|
+
Post.skills_with_weight
|
132
|
+
```
|
133
|
+
|
134
|
+
Here is how to use these methods in more detail:
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
Post.create!(:tags => "food,ant,bee")
|
138
|
+
Post.create!(:tags => "juice,food,bee,zip")
|
139
|
+
Post.create!(:tags => "honey,strip,food")
|
140
|
+
|
141
|
+
Post.tags # will retrieve ["ant", "bee", "food", "honey", "juice", "strip", "zip"]
|
142
|
+
Post.tags_with_weight # will retrieve:
|
143
|
+
# [
|
144
|
+
# ['ant', 1],
|
145
|
+
# ['bee', 2],
|
146
|
+
# ['food', 3],
|
147
|
+
# ['honey', 1],
|
148
|
+
# ['juice', 1],
|
149
|
+
# ['strip', 1],
|
150
|
+
# ['zip', 1]
|
151
|
+
# ]
|
152
|
+
```
|
153
|
+
|
154
|
+
Contributing to mongoid_taggable_with_context-meta
|
155
|
+
--------------------------------------------------------
|
156
|
+
|
157
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
158
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
159
|
+
* Fork the project
|
160
|
+
* Start a feature/bugfix branch
|
161
|
+
* Commit and push until you are happy with your contribution
|
162
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
163
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
164
|
+
|
165
|
+
Copyright
|
166
|
+
---------
|
167
|
+
|
168
|
+
Copyright (c) 2012 Maik Vlcek. See LICENSE.txt for
|
169
|
+
further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
gem.name = "mongoid_taggable_with_context-meta"
|
15
|
+
gem.homepage = "https://github.com/mediavrog/mongoid_taggable_with_context-meta"
|
16
|
+
gem.license = "MIT"
|
17
|
+
gem.summary = %Q{Attach with_meta information to tags}
|
18
|
+
gem.description = %Q{It provides methods to add with_meta data to tags created with Mongoid Taggable with Context.}
|
19
|
+
gem.email = "maik@mediavrog.net"
|
20
|
+
gem.authors = ["Maik Vlcek"]
|
21
|
+
gem.add_dependency 'mongoid_taggable_with_context'
|
22
|
+
end
|
23
|
+
Jeweler::RubygemsDotOrgTasks.new
|
24
|
+
|
25
|
+
require 'rspec/core'
|
26
|
+
require 'rspec/core/rake_task'
|
27
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
28
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
29
|
+
spec.rspec_opts = "--color --format progress"
|
30
|
+
end
|
31
|
+
|
32
|
+
task :default => :spec
|
33
|
+
|
34
|
+
require 'yard'
|
35
|
+
YARD::Rake::YardocTask.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'meta_tag'
|
2
|
+
|
3
|
+
module Mongoid
|
4
|
+
module TaggableWithContext
|
5
|
+
module Meta
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
embeds_many :meta_tags, :as => :meta_tagable, :class_name => "Mongoid::TaggableWithContext::Meta::MetaTag"
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
module ClassMethods
|
15
|
+
alias_method :taggable_original, :taggable
|
16
|
+
|
17
|
+
def taggable(*args)
|
18
|
+
taggable_original(*args)
|
19
|
+
|
20
|
+
options = args.extract_options!
|
21
|
+
tags_field = (args.blank? ? :tags : args.shift).to_sym
|
22
|
+
options = self.taggable_with_context_options[tags_field]
|
23
|
+
|
24
|
+
# META Handling
|
25
|
+
if options[:with_meta]
|
26
|
+
|
27
|
+
# instance methods
|
28
|
+
class_eval <<-END
|
29
|
+
|
30
|
+
# retrieve with_meta tags in various formats
|
31
|
+
def #{tags_field}_having_meta
|
32
|
+
self.#{tags_field}_having_meta_array.join(get_tag_separator_for(:"#{tags_field}"))
|
33
|
+
end
|
34
|
+
|
35
|
+
def #{tags_field}_having_meta_array
|
36
|
+
self.#{tags_field}_having_and_including_meta.collect{|i| i[0]}
|
37
|
+
end
|
38
|
+
|
39
|
+
def #{tags_field}_having_and_including_meta
|
40
|
+
self.meta_tags.where(context: "#{tags_field}").collect{|i| [i.name, i.with_meta] }
|
41
|
+
end
|
42
|
+
|
43
|
+
def #{tags_field}_including_meta
|
44
|
+
normal_tags = self.#{tags_field}_array - self.#{tags_field}_having_meta_array
|
45
|
+
self.#{tags_field}_having_and_including_meta + normal_tags.collect{|i| [i, {}]}
|
46
|
+
end
|
47
|
+
|
48
|
+
# adds single with_meta enhances tag
|
49
|
+
def add_#{tags_field.to_s.singularize}_with_meta(tag_name, with_meta)
|
50
|
+
self.meta_tags.create(:context => "#{tags_field}", :name => tag_name.strip, :with_meta => with_meta)
|
51
|
+
self.#{tags_field}_array << tag_name
|
52
|
+
end
|
53
|
+
END
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'mongoid'
|
2
|
+
|
3
|
+
module Mongoid::TaggableWithContext
|
4
|
+
module Meta
|
5
|
+
class MetaTag
|
6
|
+
include Mongoid::Document
|
7
|
+
field :name, :type => String
|
8
|
+
field :context
|
9
|
+
field :with_meta, :type => Hash, :default => {}
|
10
|
+
embedded_in :meta_tagable, :polymorphic => true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
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 = "mongoid_taggable_with_context-meta"
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Maik Vlcek"]
|
12
|
+
s.date = "2012-02-27"
|
13
|
+
s.description = "It provides methods to add with_meta data to tags created with Mongoid Taggable with Context."
|
14
|
+
s.email = "maik@mediavrog.net"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README",
|
18
|
+
"README.md"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".rvmrc",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README",
|
26
|
+
"README.md",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"lib/mongoid_taggable_with_context-meta.rb",
|
30
|
+
"lib/mongoid_taggable_with_context/meta.rb",
|
31
|
+
"lib/mongoid_taggable_with_context/meta_tag.rb",
|
32
|
+
"mongoid_taggable_with_context-meta.gemspec",
|
33
|
+
"spec/mongoid_taggable_with_context_with_meta_spec.rb",
|
34
|
+
"spec/spec_helper.rb"
|
35
|
+
]
|
36
|
+
s.homepage = "https://github.com/mediavrog/mongoid_taggable_with_context-meta"
|
37
|
+
s.licenses = ["MIT"]
|
38
|
+
s.require_paths = ["lib"]
|
39
|
+
s.rubygems_version = "1.8.15"
|
40
|
+
s.summary = "Attach with_meta information to tags"
|
41
|
+
|
42
|
+
if s.respond_to? :specification_version then
|
43
|
+
s.specification_version = 3
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
|
+
s.add_runtime_dependency(%q<mongo>, ["~> 1.5.2"])
|
47
|
+
s.add_runtime_dependency(%q<mongoid>, ["= 2.4.4"])
|
48
|
+
s.add_runtime_dependency(%q<mongoid_taggable_with_context>, [">= 0"])
|
49
|
+
s.add_development_dependency(%q<database_cleaner>, [">= 0"])
|
50
|
+
s.add_development_dependency(%q<bson>, ["~> 1.5.2"])
|
51
|
+
s.add_development_dependency(%q<bson_ext>, ["~> 1.5.2"])
|
52
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
53
|
+
s.add_development_dependency(%q<mongoid-rspec>, [">= 0"])
|
54
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
55
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
56
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
57
|
+
s.add_runtime_dependency(%q<mongoid_taggable_with_context>, [">= 0"])
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<mongo>, ["~> 1.5.2"])
|
60
|
+
s.add_dependency(%q<mongoid>, ["= 2.4.4"])
|
61
|
+
s.add_dependency(%q<mongoid_taggable_with_context>, [">= 0"])
|
62
|
+
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
63
|
+
s.add_dependency(%q<bson>, ["~> 1.5.2"])
|
64
|
+
s.add_dependency(%q<bson_ext>, ["~> 1.5.2"])
|
65
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
66
|
+
s.add_dependency(%q<mongoid-rspec>, [">= 0"])
|
67
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
68
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
69
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
70
|
+
s.add_dependency(%q<mongoid_taggable_with_context>, [">= 0"])
|
71
|
+
end
|
72
|
+
else
|
73
|
+
s.add_dependency(%q<mongo>, ["~> 1.5.2"])
|
74
|
+
s.add_dependency(%q<mongoid>, ["= 2.4.4"])
|
75
|
+
s.add_dependency(%q<mongoid_taggable_with_context>, [">= 0"])
|
76
|
+
s.add_dependency(%q<database_cleaner>, [">= 0"])
|
77
|
+
s.add_dependency(%q<bson>, ["~> 1.5.2"])
|
78
|
+
s.add_dependency(%q<bson_ext>, ["~> 1.5.2"])
|
79
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
80
|
+
s.add_dependency(%q<mongoid-rspec>, [">= 0"])
|
81
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
82
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
83
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
84
|
+
s.add_dependency(%q<mongoid_taggable_with_context>, [">= 0"])
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
class MyModel
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::TaggableWithContext
|
6
|
+
include Mongoid::TaggableWithContext::Meta
|
7
|
+
|
8
|
+
taggable :with_meta => true
|
9
|
+
taggable :artists, :with_meta => true
|
10
|
+
end
|
11
|
+
|
12
|
+
describe Mongoid::TaggableWithContext::Meta do
|
13
|
+
|
14
|
+
context "handling with_meta with tags" do
|
15
|
+
before :each do
|
16
|
+
@m = MyModel.new
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should not interfere with tags retrieval" do
|
20
|
+
@m.tags_array = %w[tag1 tag2]
|
21
|
+
@m.add_tag_with_meta('tag_with_meta', {:key => 'meep', :key2 => 'meep2'})
|
22
|
+
|
23
|
+
@m.tags_array.should == %w[tag1 tag2 tag_with_meta]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should provide method to retrieve only tags with with_meta information as array" do
|
27
|
+
@m.tags_array = %w[tag1 tag2]
|
28
|
+
@m.add_tag_with_meta('tag_with_meta', {:key => 'meep', :key2 => 'meep2'})
|
29
|
+
@m.add_tag_with_meta('tag_with_meta_2', {:key => 'meep_t2', :key2 => 'meep2_t2'})
|
30
|
+
|
31
|
+
@m.tags_having_meta.should == 'tag_with_meta tag_with_meta_2'
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should provide method to retrieve only tags with with_meta information as string" do
|
35
|
+
@m.tags_array = %w[tag1 tag2]
|
36
|
+
@m.add_tag_with_meta('tag_with_meta', {:key => 'meep', :key2 => 'meep2'})
|
37
|
+
@m.add_tag_with_meta('tag_with_meta_2', {:key => 'meep_t2', :key2 => 'meep2_t2'})
|
38
|
+
|
39
|
+
@m.tags_having_meta_array.should == %w[tag_with_meta tag_with_meta_2]
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should provide method to retrieve only tags with with_meta information as objects as array" do
|
43
|
+
@m.tags_array = %w[tag1 tag2]
|
44
|
+
@m.add_tag_with_meta('tag_with_meta', {:key => 'meep', :key2 => 'meep2'})
|
45
|
+
@m.add_tag_with_meta('tag_with_meta_2', {:key => 'meep_t2', :key2 => 'meep2_t2'})
|
46
|
+
|
47
|
+
@m.tags_having_and_including_meta.should == [
|
48
|
+
['tag_with_meta', {:key => 'meep', :key2 => 'meep2'}],
|
49
|
+
['tag_with_meta_2', {:key => 'meep_t2', :key2 => 'meep2_t2'}]
|
50
|
+
]
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should provide method to retrieve all tags with with_meta information (if available) as objects as array" do
|
54
|
+
@m.tags_array = %w[tag1 tag2]
|
55
|
+
@m.add_tag_with_meta('tag_with_meta', {:key => 'meep', :key2 => 'meep2'})
|
56
|
+
@m.add_tag_with_meta('tag_with_meta_2', {:key => 'meep_t2', :key2 => 'meep2_t2'})
|
57
|
+
|
58
|
+
@m.tags_including_meta.sort.should == [
|
59
|
+
['tag1', {}],
|
60
|
+
['tag2', {}],
|
61
|
+
['tag_with_meta', {:key => 'meep', :key2 => 'meep2'}],
|
62
|
+
['tag_with_meta_2', {:key => 'meep_t2', :key2 => 'meep2_t2'}]
|
63
|
+
].sort
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should set with_meta for an existing tag"
|
67
|
+
it "should erase with_meta for deleted tag"
|
68
|
+
end
|
69
|
+
|
70
|
+
context "respecting context" do
|
71
|
+
before :each do
|
72
|
+
@m = MyModel.new
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should show proper tags" do
|
76
|
+
@m.tags_array = %w[tag1 tag2]
|
77
|
+
@m.add_tag_with_meta('tag_with_meta', {:key => 'meep', :key2 => 'meep2'})
|
78
|
+
|
79
|
+
@m.artists_array = %w[artist1 artist2]
|
80
|
+
@m.add_artist_with_meta('artist_with_meta', {:key => 'meep', :key2 => 'meep2'})
|
81
|
+
|
82
|
+
@m.tags_array.should == %w[tag1 tag2 tag_with_meta]
|
83
|
+
@m.artists_array.should == %w[artist1 artist2 artist_with_meta]
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
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_taggable_with_context'
|
7
|
+
require 'mongoid_taggable_with_context.rb'
|
8
|
+
require 'database_cleaner'
|
9
|
+
|
10
|
+
Mongoid::MONGODB_VERSION = "1.8.2"
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.before(:suite) do
|
14
|
+
DatabaseCleaner.strategy = :truncation
|
15
|
+
end
|
16
|
+
|
17
|
+
config.after(:each) do
|
18
|
+
DatabaseCleaner.clean
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Mongoid.configure do |config|
|
23
|
+
config.master = Mongo::Connection.new.db("mongoid_taggable_with_context_with_meta_test")
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mongoid_taggable_with_context-meta
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Maik Vlcek
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: mongo
|
16
|
+
requirement: &20297280 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.5.2
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *20297280
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: mongoid
|
27
|
+
requirement: &20295820 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - =
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.4.4
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *20295820
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: mongoid_taggable_with_context
|
38
|
+
requirement: &20293280 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *20293280
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: database_cleaner
|
49
|
+
requirement: &20292340 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *20292340
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: bson
|
60
|
+
requirement: &20291620 !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: *20291620
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bson_ext
|
71
|
+
requirement: &20290900 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.5.2
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *20290900
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: rspec
|
82
|
+
requirement: &20221760 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *20221760
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: mongoid-rspec
|
93
|
+
requirement: &20220580 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *20220580
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: yard
|
104
|
+
requirement: &20218360 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *20218360
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
name: bundler
|
115
|
+
requirement: &20217440 !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 1.0.0
|
121
|
+
type: :development
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: *20217440
|
124
|
+
- !ruby/object:Gem::Dependency
|
125
|
+
name: jeweler
|
126
|
+
requirement: &20216080 !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: *20216080
|
135
|
+
- !ruby/object:Gem::Dependency
|
136
|
+
name: mongoid_taggable_with_context
|
137
|
+
requirement: &20138380 !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
type: :runtime
|
144
|
+
prerelease: false
|
145
|
+
version_requirements: *20138380
|
146
|
+
description: It provides methods to add with_meta data to tags created with Mongoid
|
147
|
+
Taggable with Context.
|
148
|
+
email: maik@mediavrog.net
|
149
|
+
executables: []
|
150
|
+
extensions: []
|
151
|
+
extra_rdoc_files:
|
152
|
+
- LICENSE.txt
|
153
|
+
- README
|
154
|
+
- README.md
|
155
|
+
files:
|
156
|
+
- .rvmrc
|
157
|
+
- Gemfile
|
158
|
+
- Gemfile.lock
|
159
|
+
- LICENSE.txt
|
160
|
+
- README
|
161
|
+
- README.md
|
162
|
+
- Rakefile
|
163
|
+
- VERSION
|
164
|
+
- lib/mongoid_taggable_with_context-meta.rb
|
165
|
+
- lib/mongoid_taggable_with_context/meta.rb
|
166
|
+
- lib/mongoid_taggable_with_context/meta_tag.rb
|
167
|
+
- mongoid_taggable_with_context-meta.gemspec
|
168
|
+
- spec/mongoid_taggable_with_context_with_meta_spec.rb
|
169
|
+
- spec/spec_helper.rb
|
170
|
+
homepage: https://github.com/mediavrog/mongoid_taggable_with_context-meta
|
171
|
+
licenses:
|
172
|
+
- MIT
|
173
|
+
post_install_message:
|
174
|
+
rdoc_options: []
|
175
|
+
require_paths:
|
176
|
+
- lib
|
177
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
178
|
+
none: false
|
179
|
+
requirements:
|
180
|
+
- - ! '>='
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
183
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
|
+
none: false
|
185
|
+
requirements:
|
186
|
+
- - ! '>='
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '0'
|
189
|
+
requirements: []
|
190
|
+
rubyforge_project:
|
191
|
+
rubygems_version: 1.8.15
|
192
|
+
signing_key:
|
193
|
+
specification_version: 3
|
194
|
+
summary: Attach with_meta information to tags
|
195
|
+
test_files: []
|
196
|
+
has_rdoc:
|