dm-tags 0.0.3 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +0 -5
- data/License.txt +1 -1
- data/Manifest.txt +1 -1
- data/README.txt +1 -3
- data/Rakefile +4 -4
- data/lib/dm-tags/dm_tags.rb +16 -15
- data/lib/dm-tags/tag.rb +2 -2
- data/lib/dm-tags/tagging.rb +3 -3
- data/lib/dm-tags/version.rb +2 -2
- data/lib/dm-tags.rb +1 -2
- data/setup.rb +4 -4
- data/spec/classes.rb +1 -1
- data/spec/dm-setup.rb +1 -1
- data/spec/dm-tags/dm_tags_spec.rb +1 -1
- data/spec/dm-tags/tag_spec.rb +4 -4
- data/spec/dm-tags/taggable_spec.rb +7 -7
- data/spec/dm-tags/tagging_spec.rb +3 -3
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +8 -8
data/History.txt
CHANGED
data/License.txt
CHANGED
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
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.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
http://dm-tags.rubyforge.org/
|
4
4
|
http://github.com/bobby/dm-tags/
|
5
5
|
|
6
|
-
dm-tags is now part of dm-more [http://github.com/sam/dm-more].
|
7
|
-
|
8
6
|
== Description
|
9
7
|
|
10
8
|
This package brings tagging to DataMapper. It is inspired by Acts As Taggable On by Michael Bleigh, github's mbleigh. Props to him for the contextual tagging based on Acts As Taggable on Steroids.
|
@@ -115,4 +113,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
115
113
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
116
114
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
117
115
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
118
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
116
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'config/requirements'
|
2
|
-
require 'config/hoe' # setup Hoe + all gem configuration
|
3
|
-
|
4
|
-
Dir['tasks/**/*.rake'].each { |rake| load rake }
|
1
|
+
require 'config/requirements'
|
2
|
+
require 'config/hoe' # setup Hoe + all gem configuration
|
3
|
+
|
4
|
+
Dir['tasks/**/*.rake'].each { |rake| load rake }
|
data/lib/dm-tags/dm_tags.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'dm-core'
|
1
2
|
module DataMapper
|
2
3
|
module Resource
|
3
4
|
class << self
|
@@ -30,7 +31,7 @@ module DataMapper
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def #{arg.to_s.singular}_list
|
33
|
-
@#{arg.to_s.singular}_list
|
34
|
+
@#{arg.to_s.singular}_list ||= #{arg}.map{|#{arg.to_s.singular}| #{arg.to_s.singular}.name}.sort
|
34
35
|
end
|
35
36
|
|
36
37
|
def #{arg.to_s.singular}_list=(string)
|
@@ -41,22 +42,22 @@ module DataMapper
|
|
41
42
|
return if #{arg.to_s.singular}_list.empty?
|
42
43
|
deleted_#{arg} = frozen_#{arg.to_s.singular}_list.to_s.split(',') - #{arg.to_s.singular}_list
|
43
44
|
deleted_#{arg}.each do |name|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
tag = Tag.first(:name => name)
|
46
|
+
tagging = #{arg.to_s.singular}_taggings.first(:tag_id => tag.id)
|
47
|
+
tagging.destroy
|
48
|
+
#{arg.to_s.singular}_taggings.reload
|
49
|
+
end
|
50
|
+
#{arg.to_s.singular}_list.each do |name|
|
51
|
+
tag = Tag.first(:name => name)
|
52
|
+
next if #{arg}.to_a.include?(tag)
|
53
|
+
tag = Tag.create!(:name => name) unless tag
|
54
|
+
#{arg.to_s.singular}_taggings << Tagging.new(:tag => tag, :taggable_type => self.class.to_s, :tag_context => "#{arg}")
|
55
|
+
end
|
56
|
+
self.frozen_#{arg.to_s.singular}_list = #{arg}.map{|#{arg.to_s.singular}| #{arg.to_s.singular}.name}.sort.join(',')
|
48
57
|
end
|
49
|
-
|
50
|
-
tag = Tag.first(:name => name)
|
51
|
-
next if #{arg}.to_a.include?(tag)
|
52
|
-
tag = Tag.create!(:name => name) unless tag
|
53
|
-
#{arg.to_s.singular}_taggings << Tagging.new(:tag => tag, :taggable_type => self.class.to_s, :tag_context => "#{arg}")
|
54
|
-
end
|
55
|
-
self.frozen_#{arg.to_s.singular}_list = #{arg}.map{|#{arg.to_s.singular}| #{arg.to_s.singular}.name}.sort.join(',')
|
58
|
+
RUBY
|
56
59
|
end
|
57
|
-
RUBY
|
58
60
|
end
|
59
|
-
end
|
60
61
|
|
61
62
|
def has_tags(*args)
|
62
63
|
has_tags_on :tags
|
@@ -93,4 +94,4 @@ def self.included(receiver)
|
|
93
94
|
receiver.extend(ClassMethods)
|
94
95
|
end
|
95
96
|
end
|
96
|
-
end
|
97
|
+
end
|
data/lib/dm-tags/tag.rb
CHANGED
data/lib/dm-tags/tagging.rb
CHANGED
@@ -5,10 +5,10 @@ class Tagging
|
|
5
5
|
property :taggable_id, Integer, :nullable => false
|
6
6
|
property :taggable_type, String, :nullable => false
|
7
7
|
property :tag_context, String, :nullable => false
|
8
|
-
|
8
|
+
|
9
9
|
belongs_to :tag
|
10
|
-
|
10
|
+
|
11
11
|
def taggable
|
12
12
|
eval("#{taggable_type}.get!(#{taggable_id})") if taggable_type and taggable_id
|
13
13
|
end
|
14
|
-
end
|
14
|
+
end
|
data/lib/dm-tags/version.rb
CHANGED
data/lib/dm-tags.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__)) unless
|
2
2
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
|
4
|
-
require 'dm-core'
|
5
4
|
require 'dm-tags/tagging'
|
6
5
|
require 'dm-tags/tag'
|
7
|
-
require 'dm-tags/dm_tags'
|
6
|
+
require 'dm-tags/dm_tags'
|
data/setup.rb
CHANGED
@@ -659,7 +659,7 @@ module FileOperations
|
|
659
659
|
def ruby(*args)
|
660
660
|
command config('rubyprog'), *args
|
661
661
|
end
|
662
|
-
|
662
|
+
|
663
663
|
def make(task = nil)
|
664
664
|
command(*[config('makeprog'), task].compact)
|
665
665
|
end
|
@@ -722,7 +722,7 @@ module HookScriptAPI
|
|
722
722
|
def srcdirectory?(path)
|
723
723
|
File.dir?(srcfile(path))
|
724
724
|
end
|
725
|
-
|
725
|
+
|
726
726
|
def srcfile?(path)
|
727
727
|
File.file?(srcfile(path))
|
728
728
|
end
|
@@ -826,7 +826,7 @@ class ToplevelInstaller
|
|
826
826
|
__send__ "exec_#{task}"
|
827
827
|
end
|
828
828
|
end
|
829
|
-
|
829
|
+
|
830
830
|
def run_metaconfigs
|
831
831
|
@config.load_script "#{@ardir}/metaconfig"
|
832
832
|
end
|
@@ -1404,7 +1404,7 @@ class Installer
|
|
1404
1404
|
end
|
1405
1405
|
|
1406
1406
|
# picked up many entries from cvs-1.11.1/src/ignore.c
|
1407
|
-
JUNK_FILES = %w(
|
1407
|
+
JUNK_FILES = %w(
|
1408
1408
|
core RCSLOG tags TAGS .make.state
|
1409
1409
|
.nse_depinfo #* .#* cvslog.* ,* .del-* *.olb
|
1410
1410
|
*~ *.old *.bak *.BAK *.orig *.rej _$* *$
|
data/spec/classes.rb
CHANGED
data/spec/dm-setup.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
DataMapper.setup(:default, 'sqlite3::memory:')
|
2
|
-
DataMapper.auto_migrate!
|
2
|
+
DataMapper.auto_migrate!
|
data/spec/dm-tags/tag_spec.rb
CHANGED
@@ -4,19 +4,19 @@ describe Tag do
|
|
4
4
|
before(:each) do
|
5
5
|
@tag = Tag.new
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
it "should have id and name properties" do
|
9
9
|
@tag.attributes.should have_key(:id)
|
10
10
|
@tag.attributes.should have_key(:name)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it "should have many Taggings" do
|
14
14
|
Tag.relationships.should have_key(:taggings)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "should validate the presence of name" do
|
18
18
|
@tag.should_not be_valid
|
19
19
|
@tag.name = "Meme"
|
20
20
|
@tag.should be_valid
|
21
21
|
end
|
22
|
-
end
|
22
|
+
end
|
@@ -35,7 +35,7 @@ describe "Taggable" do
|
|
35
35
|
@taggable = DefaultTaggedModel.first
|
36
36
|
@taggable.tag_list.should == valid_array
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
it "should set the associated collection of tags to those whose names
|
40
40
|
are in the tag list upon saving, creating and deleting as necessary" do
|
41
41
|
tag1 = Tag.create!(:name => 'tag1')
|
@@ -54,13 +54,13 @@ describe "Taggable" do
|
|
54
54
|
@taggable.tags.sort_by{|tag| tag.id}.should == [tag3, Tag.first(:name => 'tag4')]
|
55
55
|
@taggable.skills.sort_by{|skill| skill.id}.should_not == [tag3, Tag.first(:name => 'tag4')]
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
describe ".tagged_with" do
|
59
59
|
it "should have a class method .tagged_with" do
|
60
60
|
DefaultTaggedModel.should respond_to(:tagged_with)
|
61
61
|
UntaggedModel.should_not respond_to(:tagged_with)
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
it "should return taggables tagged with the name given in the first argument" do
|
65
65
|
@taggable.tag_list = 'tag1, tag2, tag3'
|
66
66
|
@taggable.save
|
@@ -69,7 +69,7 @@ describe "Taggable" do
|
|
69
69
|
taggable.save
|
70
70
|
DefaultTaggedModel.tagged_with('tag1').sort_by{|t| t.id}.to_a.should == [@taggable, taggable]
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
it "should return taggables of the context specified by the second argument" do
|
74
74
|
taggable1 = TaggedModel.new
|
75
75
|
taggable2 = TaggedModel.new
|
@@ -82,16 +82,16 @@ describe "Taggable" do
|
|
82
82
|
TaggedModel.tagged_with('tag1', :on => 'tags').should == [taggable1]
|
83
83
|
end
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
it "should have a class method .taggable? which returns true if tagging is defined, and false otherwise" do
|
87
87
|
UntaggedModel.taggable?.should be_false
|
88
88
|
TaggedModel.taggable?.should be_true
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
it "should have an instance method #taggable? which returns the same as the instance's class would" do
|
92
92
|
UntaggedModel.new.taggable?.should == UntaggedModel.taggable?
|
93
93
|
UntaggedModel.new.taggable?.should be_false
|
94
94
|
TaggedModel.new.taggable?.should == TaggedModel.taggable?
|
95
95
|
TaggedModel.new.taggable?.should be_true
|
96
96
|
end
|
97
|
-
end
|
97
|
+
end
|
@@ -20,7 +20,7 @@ describe Tagging do
|
|
20
20
|
# @tagging.attributes.should have_key(:tagger_type)
|
21
21
|
@tagging.attributes.should have_key(:tag_context)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
it "should validate the presence of tag_id, taggable_id, taggable_type and tag_context" do
|
25
25
|
@tagging.should_not be_valid
|
26
26
|
@tagging.tag_id = 1
|
@@ -37,7 +37,7 @@ describe Tagging do
|
|
37
37
|
Tagging.relationships[:tag].should be
|
38
38
|
Tagging.relationships[:tag].parent_model.should == Tag
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
it "should have a method Tagging#taggable which returns the associated taggable instance" do
|
42
42
|
@tagging.should respond_to(:taggable)
|
43
43
|
@tagging.taggable.should_not be
|
@@ -46,4 +46,4 @@ describe Tagging do
|
|
46
46
|
TaggedModel.should_receive(:get!).with(11111)
|
47
47
|
@tagging.taggable
|
48
48
|
end
|
49
|
-
end
|
49
|
+
end
|
data/spec/spec.opts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--colour
|
1
|
+
--colour
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bobby Calderwood
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-11-18 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,9 +20,9 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.
|
23
|
+
version: 1.8.0
|
24
24
|
version:
|
25
|
-
description: This package brings tagging to DataMapper. It is inspired by Acts As Taggable On by Michael Bleigh, github's mbleigh.
|
25
|
+
description: This package brings tagging to DataMapper. It is inspired by Acts As Taggable On by Michael Bleigh, github's mbleigh. Props to him for the contextual tagging based on Acts As Taggable on Steroids.
|
26
26
|
email:
|
27
27
|
- bobby_calderwood@me.com
|
28
28
|
executables: []
|
@@ -56,7 +56,7 @@ files:
|
|
56
56
|
- spec/spec_helper.rb
|
57
57
|
- tasks/rspec.rake
|
58
58
|
has_rdoc: true
|
59
|
-
homepage: http://
|
59
|
+
homepage: http://datamapper.rubyforge.org
|
60
60
|
post_install_message: ""
|
61
61
|
rdoc_options:
|
62
62
|
- --main
|
@@ -77,11 +77,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version:
|
78
78
|
requirements: []
|
79
79
|
|
80
|
-
rubyforge_project:
|
81
|
-
rubygems_version: 1.
|
80
|
+
rubyforge_project: datamapper
|
81
|
+
rubygems_version: 1.3.1
|
82
82
|
signing_key:
|
83
83
|
specification_version: 2
|
84
|
-
summary: This package brings tagging to DataMapper. It is inspired by Acts As Taggable On by Michael Bleigh, github's mbleigh.
|
84
|
+
summary: This package brings tagging to DataMapper. It is inspired by Acts As Taggable On by Michael Bleigh, github's mbleigh. Props to him for the contextual tagging based on Acts As Taggable on Steroids.
|
85
85
|
test_files:
|
86
86
|
- spec/dm-tags/dm_tags_spec.rb
|
87
87
|
- spec/dm-tags/tag_spec.rb
|