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.
@@ -7,6 +7,7 @@ class SemanticallyTaggableMigration < ActiveRecord::Migration
|
|
7
7
|
t.string :description
|
8
8
|
t.string :delimiter, :limit => 10, :default => ','
|
9
9
|
t.boolean :polyhierarchical, :default => false
|
10
|
+
t.boolean :restrict_to_known_tags, :default => false
|
10
11
|
end
|
11
12
|
|
12
13
|
add_index :schemes, :name, :unique => true
|
@@ -68,21 +68,24 @@ module SemanticallyTaggable
|
|
68
68
|
|
69
69
|
scheme = SemanticallyTaggable::Scheme.by_name(scheme_name)
|
70
70
|
list = [list].flatten
|
71
|
-
|
72
71
|
return [] if list.empty?
|
73
72
|
|
74
73
|
existing_tags = scheme.tags.named_any(list).all
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
if scheme.restrict_to_known_tags
|
75
|
+
created_tags = []
|
76
|
+
else
|
77
|
+
new_tag_names = list.reject do |name|
|
78
|
+
name = comparable_name(name)
|
79
|
+
existing_tags.any? { |tag| comparable_name(tag.name) == name }
|
80
|
+
end
|
81
|
+
created_tags = new_tag_names.map { |name| Tag.create(:name => name) { |tag| tag.scheme = scheme } }
|
78
82
|
end
|
79
|
-
created_tags = new_tag_names.map { |name| Tag.create(:name => name) { |tag| tag.scheme = scheme } }
|
80
83
|
|
81
84
|
existing_tags + created_tags
|
82
85
|
end
|
83
86
|
|
84
87
|
def ==(object)
|
85
|
-
super || (object.is_a?(Tag) && name == object.name)
|
88
|
+
super || (object.is_a?(Tag) && name == object.name && scheme == object.scheme)
|
86
89
|
end
|
87
90
|
|
88
91
|
def to_s
|
data/spec/database_seeder.rb
CHANGED
@@ -4,7 +4,8 @@ def load_schemes!
|
|
4
4
|
[
|
5
5
|
{
|
6
6
|
:name => 'dg_topics', :meta_name => 'DC.subject', :meta_scheme => 'Directgov.Topic',
|
7
|
-
:description => 'Directgov taxonomy concept ID taggings', :delimiter => ';', :polyhierarchical => true
|
7
|
+
:description => 'Directgov taxonomy concept ID taggings', :delimiter => ';', :polyhierarchical => true,
|
8
|
+
:restrict_to_known_tags => true
|
8
9
|
},
|
9
10
|
{
|
10
11
|
:name => 'keywords', :meta_name => 'keywords',
|