dm-taggings 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/dm-taggings.gemspec +2 -2
- data/lib/dm-taggings/is/taggable.rb +7 -13
- data/lib/dm-taggings/spec/taggable_shared_spec.rb +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/dm-taggings.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dm-taggings}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Piotr Solnica"]
|
12
|
-
s.date = %q{2011-03-
|
12
|
+
s.date = %q{2011-03-25}
|
13
13
|
s.description = %q{DataMapper plugin providing taggable and tagger models}
|
14
14
|
s.email = %q{piotr.solnica@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -30,8 +30,9 @@ module DataMapper
|
|
30
30
|
include DataMapper::Is::Taggable::InstanceMethods
|
31
31
|
|
32
32
|
class << self
|
33
|
-
attr_reader :tagging_parent_name, :tagging_relationship_name,
|
34
|
-
:tagging_class, :taggable_relationship_name,
|
33
|
+
attr_reader :tagging_parent_name, :tagging_relationship_name,
|
34
|
+
:tagging_relationship, :tagging_class, :taggable_relationship_name,
|
35
|
+
:tagging_name, :taggable_options
|
35
36
|
end
|
36
37
|
|
37
38
|
# set up options hash
|
@@ -63,7 +64,8 @@ module DataMapper
|
|
63
64
|
belongs_to tagging_parent_name, model_name
|
64
65
|
|
65
66
|
options[:by].each do |tagger_class|
|
66
|
-
belongs_to inflector.underscore(inflector.demodulize(tagger_class.name)),
|
67
|
+
belongs_to inflector.underscore(inflector.demodulize(tagger_class.name)),
|
68
|
+
tagger_class.name, :required => false
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
@@ -102,16 +104,8 @@ module DataMapper
|
|
102
104
|
# A collection of taggables
|
103
105
|
#
|
104
106
|
# @api public
|
105
|
-
def tagged_with(
|
106
|
-
|
107
|
-
|
108
|
-
tag_ids = if tags_or_names.all? { |tag| tag.kind_of?(Tag) }
|
109
|
-
tags_or_names
|
110
|
-
else
|
111
|
-
Tag.all(:name => tags_or_names)
|
112
|
-
end.map { |tag| tag.id }
|
113
|
-
|
114
|
-
all("#{tagging_relationship_name}.tag_id" => tag_ids)
|
107
|
+
def tagged_with(tag_names)
|
108
|
+
tagging_class.all("tag.name" => tag_names).send(taggable_relationship_name)
|
115
109
|
end
|
116
110
|
end # ClassMethods
|
117
111
|
|
@@ -54,7 +54,7 @@ share_examples_for 'A taggable resource' do
|
|
54
54
|
|
55
55
|
describe ".tagged_with" do
|
56
56
|
let(:resource_one) { create_taggable(:tag_list => "red, green, blue") }
|
57
|
-
let(:resource_two) { create_taggable(:tag_list => "orange, yellow") }
|
57
|
+
let(:resource_two) { create_taggable(:tag_list => "red, orange, yellow") }
|
58
58
|
|
59
59
|
before do
|
60
60
|
resource_one
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: dm-taggings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Piotr Solnica
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-25 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -142,7 +142,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
142
|
requirements:
|
143
143
|
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
hash:
|
145
|
+
hash: 837854607
|
146
146
|
segments:
|
147
147
|
- 0
|
148
148
|
version: "0"
|