semantically-taggable 0.1.14 → 0.2.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/spec/schema.rb
CHANGED
@@ -28,6 +28,7 @@ ActiveRecord::Schema.define :version => 0 do
|
|
28
28
|
t.string :description
|
29
29
|
t.string :delimiter, :limit => 10, :default => ','
|
30
30
|
t.boolean :polyhierarchical, :default => false
|
31
|
+
t.boolean :restrict_to_known_tags, :default => false
|
31
32
|
end
|
32
33
|
|
33
34
|
# Transitive closure table for multiple parent tags
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe SemanticallyTaggable::Tag do
|
4
|
-
let(:
|
5
|
-
let(:
|
4
|
+
let(:dg_topics) { SemanticallyTaggable::Scheme.by_name(:dg_topics) }
|
5
|
+
let(:keywords) { SemanticallyTaggable::Scheme.by_name(:keywords) }
|
6
6
|
|
7
7
|
before do
|
8
8
|
reset_database!
|
@@ -21,21 +21,46 @@ describe SemanticallyTaggable::Tag do
|
|
21
21
|
}.should raise_error(ActiveRecord::RecordNotFound)
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
keyword = SemanticallyTaggable::Tag.find_by_name('1')
|
30
|
-
keyword.scheme.should == scheme
|
31
|
-
end
|
24
|
+
describe "creating tags within schemes" do
|
25
|
+
it "should save schemes with the tag" do
|
26
|
+
SemanticallyTaggable::Tag.create!(:name => '1') do |tag|
|
27
|
+
tag.scheme = dg_topics
|
28
|
+
end
|
32
29
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
tag = SemanticallyTaggable::Tag.find_by_name('1')
|
31
|
+
tag.scheme.should == dg_topics
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should treat tags in different schemes as different tags" do
|
35
|
+
SemanticallyTaggable::Tag.create(:name => '1') do |tag|
|
36
|
+
tag.scheme = dg_topics
|
37
|
+
end
|
38
|
+
|
39
|
+
lambda {
|
40
|
+
SemanticallyTaggable::Tag.find_or_create_all_with_like_by_name('1', '2', :keywords)
|
41
|
+
}.should change(SemanticallyTaggable::Tag, :count).by(2)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should not find tags in different schemes equal" do
|
45
|
+
topic = SemanticallyTaggable::Tag.create(:name => '1') do |tag|
|
46
|
+
tag.scheme = dg_topics
|
47
|
+
end
|
48
|
+
tag = SemanticallyTaggable::Tag.create(:name => '1') do |tag|
|
49
|
+
tag.scheme = keywords
|
50
|
+
end
|
51
|
+
|
52
|
+
topic.should_not == tag
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should silently drop tags when the scheme is set to restrict_to_known_tags" do
|
56
|
+
tag = SemanticallyTaggable::Tag.create(:name => '1') do |tag|
|
57
|
+
tag.scheme = dg_topics
|
58
|
+
end
|
59
|
+
|
60
|
+
lambda {
|
61
|
+
SemanticallyTaggable::Tag.find_or_create_all_with_like_by_name('1', '2', :dg_topics).should == [tag]
|
62
|
+
}.should change(SemanticallyTaggable::Tag, :count).by(0)
|
63
|
+
end
|
39
64
|
end
|
40
65
|
end
|
41
66
|
|
@@ -43,9 +68,9 @@ describe SemanticallyTaggable::Tag do
|
|
43
68
|
describe "Tag relationships" do
|
44
69
|
describe "Bidirectional associations" do
|
45
70
|
before do
|
46
|
-
@parent =
|
47
|
-
@child =
|
48
|
-
@unrelated =
|
71
|
+
@parent = dg_topics.create_tag(:name => 'Tax')
|
72
|
+
@child = dg_topics.create_tag(:name => 'Income Tax')
|
73
|
+
@unrelated = dg_topics.create_tag(:name => 'unrelated')
|
49
74
|
end
|
50
75
|
|
51
76
|
describe "when assigning with narrower" do
|
@@ -68,27 +93,14 @@ describe SemanticallyTaggable::Tag do
|
|
68
93
|
specify { @child.broader_tags.should include(@parent) }
|
69
94
|
specify { @parent.narrower_tags.should include(@child) }
|
70
95
|
end
|
71
|
-
|
72
|
-
# describe "when assigning from both ends, such as might happen in the import" do
|
73
|
-
# before do
|
74
|
-
# @parent.narrower_tags << @child
|
75
|
-
# @child.broader_tags << @parent
|
76
|
-
#
|
77
|
-
# @child.save
|
78
|
-
# @parent.save
|
79
|
-
# end
|
80
|
-
#
|
81
|
-
# specify { @parent.should have(1).narrower_tag }
|
82
|
-
# specify { @child.should have(1).broader_tag }
|
83
|
-
# end
|
84
96
|
end
|
85
97
|
|
86
98
|
describe "Related tags" do
|
87
99
|
before do
|
88
|
-
@tax_tag =
|
89
|
-
@income_tax_tag =
|
90
|
-
@inheritance_tax_tag =
|
91
|
-
@giraffes =
|
100
|
+
@tax_tag = dg_topics.create_tag(:name => 'Tax')
|
101
|
+
@income_tax_tag = dg_topics.create_tag(:name => 'Income Tax')
|
102
|
+
@inheritance_tax_tag = dg_topics.create_tag(:name => 'Inheritance Tax')
|
103
|
+
@giraffes = dg_topics.create_tag(:name => 'giraffes')
|
92
104
|
|
93
105
|
@tax_tag.related_tags << [@income_tax_tag, @inheritance_tax_tag]
|
94
106
|
@tax_tag.save
|
@@ -129,8 +141,8 @@ describe SemanticallyTaggable::Tag do
|
|
129
141
|
end
|
130
142
|
|
131
143
|
describe "Tag synonyms" do
|
132
|
-
let(:benefits_tag) {
|
133
|
-
let(:benefits_keyword) {
|
144
|
+
let(:benefits_tag) { dg_topics.create_tag(:name => 'Benefits') }
|
145
|
+
let(:benefits_keyword) { keywords.create_tag(:name => 'Benefits') }
|
134
146
|
|
135
147
|
it "should allow a tag to have synonyms" do
|
136
148
|
benefits_tag.synonyms << SemanticallyTaggable::Synonym.new(:name => 'State Benefits')
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: semantically-taggable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Russell Garner
|
@@ -14,120 +15,128 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-
|
18
|
+
date: 2011-06-01 00:00:00 +01:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
+
prerelease: false
|
23
|
+
type: :runtime
|
22
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
25
|
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 7
|
27
30
|
segments:
|
28
31
|
- 3
|
29
32
|
- 0
|
30
33
|
version: "3.0"
|
31
|
-
|
32
|
-
prerelease: false
|
34
|
+
name: rails
|
33
35
|
version_requirements: *id001
|
34
36
|
- !ruby/object:Gem::Dependency
|
35
|
-
|
37
|
+
prerelease: false
|
38
|
+
type: :runtime
|
36
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
37
40
|
none: false
|
38
41
|
requirements:
|
39
42
|
- - ">="
|
40
43
|
- !ruby/object:Gem::Version
|
44
|
+
hash: 7
|
41
45
|
segments:
|
42
46
|
- 3
|
43
47
|
- 0
|
44
48
|
version: "3.0"
|
45
|
-
|
46
|
-
prerelease: false
|
49
|
+
name: activerecord
|
47
50
|
version_requirements: *id002
|
48
51
|
- !ruby/object:Gem::Dependency
|
49
|
-
|
52
|
+
prerelease: false
|
53
|
+
type: :runtime
|
50
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
51
55
|
none: false
|
52
56
|
requirements:
|
53
57
|
- - ">="
|
54
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
55
60
|
segments:
|
56
61
|
- 0
|
57
62
|
version: "0"
|
58
|
-
|
59
|
-
prerelease: false
|
63
|
+
name: mysql
|
60
64
|
version_requirements: *id003
|
61
65
|
- !ruby/object:Gem::Dependency
|
62
|
-
|
66
|
+
prerelease: false
|
67
|
+
type: :runtime
|
63
68
|
requirement: &id004 !ruby/object:Gem::Requirement
|
64
69
|
none: false
|
65
70
|
requirements:
|
66
71
|
- - ">="
|
67
72
|
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
68
74
|
segments:
|
69
75
|
- 0
|
70
76
|
version: "0"
|
71
|
-
|
72
|
-
prerelease: false
|
77
|
+
name: nokogiri
|
73
78
|
version_requirements: *id004
|
74
79
|
- !ruby/object:Gem::Dependency
|
75
|
-
|
80
|
+
prerelease: false
|
81
|
+
type: :development
|
76
82
|
requirement: &id005 !ruby/object:Gem::Requirement
|
77
83
|
none: false
|
78
84
|
requirements:
|
79
85
|
- - ~>
|
80
86
|
- !ruby/object:Gem::Version
|
87
|
+
hash: 31
|
81
88
|
segments:
|
82
89
|
- 2
|
83
90
|
- 4
|
84
91
|
- 0
|
85
92
|
version: 2.4.0
|
86
|
-
|
87
|
-
prerelease: false
|
93
|
+
name: rspec
|
88
94
|
version_requirements: *id005
|
89
95
|
- !ruby/object:Gem::Dependency
|
90
|
-
|
96
|
+
prerelease: false
|
97
|
+
type: :development
|
91
98
|
requirement: &id006 !ruby/object:Gem::Requirement
|
92
99
|
none: false
|
93
100
|
requirements:
|
94
101
|
- - ~>
|
95
102
|
- !ruby/object:Gem::Version
|
103
|
+
hash: 23
|
96
104
|
segments:
|
97
105
|
- 1
|
98
106
|
- 0
|
99
107
|
- 0
|
100
108
|
version: 1.0.0
|
101
|
-
|
102
|
-
prerelease: false
|
109
|
+
name: bundler
|
103
110
|
version_requirements: *id006
|
104
111
|
- !ruby/object:Gem::Dependency
|
105
|
-
|
112
|
+
prerelease: false
|
113
|
+
type: :development
|
106
114
|
requirement: &id007 !ruby/object:Gem::Requirement
|
107
115
|
none: false
|
108
116
|
requirements:
|
109
117
|
- - ~>
|
110
118
|
- !ruby/object:Gem::Version
|
119
|
+
hash: 7
|
111
120
|
segments:
|
112
121
|
- 1
|
113
122
|
- 5
|
114
123
|
- 2
|
115
124
|
version: 1.5.2
|
116
|
-
|
117
|
-
prerelease: false
|
125
|
+
name: jeweler
|
118
126
|
version_requirements: *id007
|
119
127
|
- !ruby/object:Gem::Dependency
|
120
|
-
|
128
|
+
prerelease: false
|
129
|
+
type: :development
|
121
130
|
requirement: &id008 !ruby/object:Gem::Requirement
|
122
131
|
none: false
|
123
132
|
requirements:
|
124
133
|
- - ">="
|
125
134
|
- !ruby/object:Gem::Version
|
135
|
+
hash: 3
|
126
136
|
segments:
|
127
137
|
- 0
|
128
138
|
version: "0"
|
129
|
-
|
130
|
-
prerelease: false
|
139
|
+
name: rcov
|
131
140
|
version_requirements: *id008
|
132
141
|
description: |-
|
133
142
|
Based really very heavily on acts_as_taggable_on, but introduces tagging schemes and moves
|
@@ -192,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
201
|
requirements:
|
193
202
|
- - ">="
|
194
203
|
- !ruby/object:Gem::Version
|
195
|
-
hash:
|
204
|
+
hash: 3
|
196
205
|
segments:
|
197
206
|
- 0
|
198
207
|
version: "0"
|
@@ -201,13 +210,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
210
|
requirements:
|
202
211
|
- - ">="
|
203
212
|
- !ruby/object:Gem::Version
|
213
|
+
hash: 3
|
204
214
|
segments:
|
205
215
|
- 0
|
206
216
|
version: "0"
|
207
217
|
requirements: []
|
208
218
|
|
209
219
|
rubyforge_project:
|
210
|
-
rubygems_version: 1.
|
220
|
+
rubygems_version: 1.5.2
|
211
221
|
signing_key:
|
212
222
|
specification_version: 3
|
213
223
|
summary: A semantic tagging system for Rails 3
|