dm-taggings 0.11.0
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/.gitignore +9 -0
- data/Gemfile +142 -0
- data/History.txt +1 -0
- data/LICENSE +20 -0
- data/Manifest.txt +18 -0
- data/README.rdoc +155 -0
- data/Rakefile +45 -0
- data/TODO +5 -0
- data/VERSION +1 -0
- data/dm-taggings.gemspec +89 -0
- data/lib/dm-taggings.rb +19 -0
- data/lib/dm-taggings/is/tag.rb +42 -0
- data/lib/dm-taggings/is/taggable.rb +245 -0
- data/lib/dm-taggings/is/tagger.rb +115 -0
- data/lib/dm-taggings/is/tagging.rb +13 -0
- data/lib/dm-taggings/is/version.rb +7 -0
- data/lib/dm-taggings/spec/taggable_shared_spec.rb +259 -0
- data/lib/dm-taggings/spec/tagger_shared_spec.rb +47 -0
- data/spec/fixtures/models.rb +35 -0
- data/spec/integration/post_spec.rb +14 -0
- data/spec/integration/tag_spec.rb +24 -0
- data/spec/integration/taggable_spec.rb +39 -0
- data/spec/integration/user_spec.rb +18 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +21 -0
- data/tasks/hoe.rb +39 -0
- data/tasks/yard.rake +9 -0
- data/tasks/yardstick.rake +19 -0
- metadata +171 -0
@@ -0,0 +1,47 @@
|
|
1
|
+
share_examples_for 'A tagger resource' do
|
2
|
+
before :all do
|
3
|
+
%w[ @tagger @taggable ].each do |ivar|
|
4
|
+
raise "+#{ivar}+ should be defined in before block" unless instance_variable_defined?(ivar)
|
5
|
+
end
|
6
|
+
|
7
|
+
@foo_tag = Tag["foo"]
|
8
|
+
@bar_tag = Tag["bar"]
|
9
|
+
|
10
|
+
@tags = [@foo_tag, @bar_tag]
|
11
|
+
end
|
12
|
+
|
13
|
+
subject { @tagger }
|
14
|
+
|
15
|
+
[ :is_tagger, :tagger?, :add_taggable_object_classes, :taggable_object_classes ].each do |method|
|
16
|
+
it { should respond_to(method) }
|
17
|
+
end
|
18
|
+
|
19
|
+
describe ".tagger?" do
|
20
|
+
subject { @tagger.tagger? }
|
21
|
+
it { should be(true) }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#tag!" do
|
25
|
+
before :all do
|
26
|
+
@tagger_resource = @tagger.create
|
27
|
+
@taggable_resource = @taggable.create
|
28
|
+
|
29
|
+
@tags = @tagger_resource.tag!(@taggable_resource, :with => @tags)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should tag the taggable resource" do
|
33
|
+
@taggable_resource.tags.should include(*@tags)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should associate tagger with taggable" do
|
37
|
+
@tagger_resource.reload.send(DataMapper::Inflector.underscore(@taggable.name).pluralize).should include(@taggable_resource)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should associate taggings with tagger" do
|
41
|
+
@taggable_resource.taggings.each do |tagging|
|
42
|
+
tagging.send(DataMapper::Inflector.underscore(@tagger.name)).should eql(@tagger_resource)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Post
|
2
|
+
include DataMapper::Resource
|
3
|
+
|
4
|
+
property :id, Serial
|
5
|
+
property :name, String
|
6
|
+
property :description, Text
|
7
|
+
|
8
|
+
is :taggable
|
9
|
+
end
|
10
|
+
|
11
|
+
class User
|
12
|
+
include DataMapper::Resource
|
13
|
+
|
14
|
+
property :id, Serial
|
15
|
+
property :login, String
|
16
|
+
end
|
17
|
+
|
18
|
+
class Book
|
19
|
+
include DataMapper::Resource
|
20
|
+
|
21
|
+
property :id, Serial
|
22
|
+
property :isbn, String, :length => 13, :required => true, :default => "123412"
|
23
|
+
property :title, String, :required => true, :default => "Hobbit"
|
24
|
+
property :author, String
|
25
|
+
|
26
|
+
is :taggable, :by => [User]
|
27
|
+
end
|
28
|
+
|
29
|
+
class Song
|
30
|
+
include DataMapper::Resource
|
31
|
+
|
32
|
+
property :id, Serial
|
33
|
+
is :taggable
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
|
3
|
+
|
4
|
+
describe 'DataMapper::Is::Taggable' do
|
5
|
+
supported_by :all do
|
6
|
+
require "dm-taggings/spec/taggable_shared_spec"
|
7
|
+
|
8
|
+
describe Post do
|
9
|
+
before(:all) { @taggable = Post }
|
10
|
+
it_should_behave_like "A taggable resource"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
|
2
|
+
|
3
|
+
describe Tag do
|
4
|
+
supported_by :all do
|
5
|
+
it "should have id and name columns" do
|
6
|
+
[:id, :name].each do |property_name|
|
7
|
+
Tag.properties[property_name].should_not be_nil
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#strip_name" do
|
12
|
+
before { @tag = Tag.new }
|
13
|
+
|
14
|
+
it "should strip the tag name" do
|
15
|
+
@tag.name = "blue "
|
16
|
+
@tag.save
|
17
|
+
@tag.name.should == "blue"
|
18
|
+
second_tag = Tag.build("blue ")
|
19
|
+
second_tag.should == @tag
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
|
3
|
+
|
4
|
+
describe DataMapper::Is::Taggable do
|
5
|
+
supported_by :all do
|
6
|
+
describe Song do
|
7
|
+
describe ".is_taggable" do
|
8
|
+
describe "taggings relationship" do
|
9
|
+
subject { Song.relationships[:song_tags] }
|
10
|
+
|
11
|
+
it { should be_kind_of(DataMapper::Associations::OneToMany::Relationship) }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "remixed tagging" do
|
15
|
+
before :all do
|
16
|
+
begin
|
17
|
+
@tagging = SongTag
|
18
|
+
rescue; end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should belong to taggable" do
|
22
|
+
@tagging.relationships[:song].should be_kind_of(DataMapper::Associations::ManyToOne::Relationship)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe Tag do
|
27
|
+
it "should have new taggings relationship" do
|
28
|
+
Tag.relationships[:song_tags].should be_kind_of(DataMapper::Associations::OneToMany::Relationship)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should have new taggable relationship" do
|
32
|
+
Tag.relationships[:songs].should be_kind_of(DataMapper::Associations::ManyToMany::Relationship)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
|
3
|
+
|
4
|
+
describe 'DataMapper::Is::Taggable' do
|
5
|
+
supported_by :all do
|
6
|
+
require "dm-taggings/spec/tagger_shared_spec"
|
7
|
+
|
8
|
+
describe User do
|
9
|
+
before(:all) do
|
10
|
+
@tagger = User
|
11
|
+
@taggable = Book
|
12
|
+
end
|
13
|
+
|
14
|
+
it_should_behave_like "A tagger resource"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'dm-core/spec/setup'
|
2
|
+
require 'dm-core/spec/lib/adapter_helpers'
|
3
|
+
|
4
|
+
require 'dm-validations'
|
5
|
+
require 'dm-taggings'
|
6
|
+
|
7
|
+
SPEC_ROOT = Pathname(__FILE__).dirname
|
8
|
+
|
9
|
+
DataMapper::Spec.setup
|
10
|
+
|
11
|
+
require "#{SPEC_ROOT}/fixtures/models"
|
12
|
+
|
13
|
+
DataMapper.finalize
|
14
|
+
|
15
|
+
Spec::Runner.configure do |config|
|
16
|
+
config.extend(DataMapper::Spec::Adapters::Helpers)
|
17
|
+
|
18
|
+
config.before :suite do
|
19
|
+
DataMapper.auto_migrate!
|
20
|
+
end
|
21
|
+
end
|
data/tasks/hoe.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'hoe'
|
2
|
+
|
3
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
4
|
+
@config = nil
|
5
|
+
RUBYFORGE_USERNAME = "unknown"
|
6
|
+
def rubyforge_username
|
7
|
+
unless @config
|
8
|
+
begin
|
9
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
10
|
+
rescue
|
11
|
+
puts <<-EOS
|
12
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
13
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
14
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
15
|
+
EOS
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
end
|
19
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
20
|
+
end
|
21
|
+
|
22
|
+
hoe = Hoe.new(GEM_NAME, GEM_VERSION) do |p|
|
23
|
+
|
24
|
+
p.developer(AUTHOR, EMAIL)
|
25
|
+
|
26
|
+
p.description = PROJECT_DESCRIPTION
|
27
|
+
p.summary = PROJECT_SUMMARY
|
28
|
+
p.url = PROJECT_URL
|
29
|
+
|
30
|
+
p.rubyforge_name = PROJECT_NAME if PROJECT_NAME
|
31
|
+
|
32
|
+
p.clean_globs |= GEM_CLEAN
|
33
|
+
p.spec_extras = GEM_EXTRAS if GEM_EXTRAS
|
34
|
+
|
35
|
+
GEM_DEPENDENCIES.each do |dep|
|
36
|
+
p.extra_deps << dep
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/tasks/yard.rake
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
begin
|
2
|
+
require 'pathname'
|
3
|
+
require 'yardstick/rake/measurement'
|
4
|
+
require 'yardstick/rake/verify'
|
5
|
+
|
6
|
+
# yardstick_measure task
|
7
|
+
Yardstick::Rake::Measurement.new
|
8
|
+
|
9
|
+
# verify_measurements task
|
10
|
+
Yardstick::Rake::Verify.new do |verify|
|
11
|
+
verify.threshold = 100
|
12
|
+
end
|
13
|
+
rescue LoadError
|
14
|
+
%w[ yardstick_measure verify_measurements ].each do |name|
|
15
|
+
task name.to_s do
|
16
|
+
abort "Yardstick is not available. In order to run #{name}, you must: gem install yardstick"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dm-taggings
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 11
|
8
|
+
- 0
|
9
|
+
version: 0.11.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Piotr Solnica
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-10-14 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: dm-core
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 0
|
30
|
+
- 2
|
31
|
+
version: 1.0.2
|
32
|
+
type: :runtime
|
33
|
+
prerelease: false
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: dm-constraints
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 1
|
44
|
+
- 0
|
45
|
+
- 2
|
46
|
+
version: 1.0.2
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: dm-is-remixable
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
segments:
|
58
|
+
- 1
|
59
|
+
- 0
|
60
|
+
- 2
|
61
|
+
version: 1.0.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: rspec
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ~>
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 1
|
74
|
+
- 3
|
75
|
+
version: "1.3"
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: *id004
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: yard
|
81
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ~>
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
- 5
|
89
|
+
version: "0.5"
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: *id005
|
93
|
+
description: DataMapper plugin that adds the possibility to tag models
|
94
|
+
email: piotr.solnica@gmail.com
|
95
|
+
executables: []
|
96
|
+
|
97
|
+
extensions: []
|
98
|
+
|
99
|
+
extra_rdoc_files:
|
100
|
+
- LICENSE
|
101
|
+
- README.rdoc
|
102
|
+
- TODO
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- Gemfile
|
106
|
+
- History.txt
|
107
|
+
- LICENSE
|
108
|
+
- Manifest.txt
|
109
|
+
- README.rdoc
|
110
|
+
- Rakefile
|
111
|
+
- TODO
|
112
|
+
- VERSION
|
113
|
+
- dm-taggings.gemspec
|
114
|
+
- lib/dm-taggings.rb
|
115
|
+
- lib/dm-taggings/is/tag.rb
|
116
|
+
- lib/dm-taggings/is/taggable.rb
|
117
|
+
- lib/dm-taggings/is/tagger.rb
|
118
|
+
- lib/dm-taggings/is/tagging.rb
|
119
|
+
- lib/dm-taggings/is/version.rb
|
120
|
+
- lib/dm-taggings/spec/taggable_shared_spec.rb
|
121
|
+
- lib/dm-taggings/spec/tagger_shared_spec.rb
|
122
|
+
- spec/fixtures/models.rb
|
123
|
+
- spec/integration/post_spec.rb
|
124
|
+
- spec/integration/tag_spec.rb
|
125
|
+
- spec/integration/taggable_spec.rb
|
126
|
+
- spec/integration/user_spec.rb
|
127
|
+
- spec/spec.opts
|
128
|
+
- spec/spec_helper.rb
|
129
|
+
- tasks/hoe.rb
|
130
|
+
- tasks/yard.rake
|
131
|
+
- tasks/yardstick.rake
|
132
|
+
has_rdoc: true
|
133
|
+
homepage: http://github.com/solnic/dm-taggings
|
134
|
+
licenses: []
|
135
|
+
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options:
|
138
|
+
- --charset=UTF-8
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
hash: 108002145
|
147
|
+
segments:
|
148
|
+
- 0
|
149
|
+
version: "0"
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
none: false
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
segments:
|
156
|
+
- 0
|
157
|
+
version: "0"
|
158
|
+
requirements: []
|
159
|
+
|
160
|
+
rubyforge_project:
|
161
|
+
rubygems_version: 1.3.7
|
162
|
+
signing_key:
|
163
|
+
specification_version: 3
|
164
|
+
summary: Tagging plugin for DataMapper
|
165
|
+
test_files:
|
166
|
+
- spec/integration/taggable_spec.rb
|
167
|
+
- spec/integration/post_spec.rb
|
168
|
+
- spec/integration/tag_spec.rb
|
169
|
+
- spec/integration/user_spec.rb
|
170
|
+
- spec/fixtures/models.rb
|
171
|
+
- spec/spec_helper.rb
|