needle_in_a_haystack 1.0.1 → 1.0.3
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.
- checksums.yaml +4 -4
- data/lib/needle_in_a_haystack/concerns/base_tag.rb +11 -0
- data/lib/needle_in_a_haystack/concerns/base_tagging.rb +11 -0
- data/lib/{concerns → needle_in_a_haystack/concerns}/taggable.rb +0 -1
- data/lib/needle_in_a_haystack/{haystack_tag.rb → models/haystack_tag.rb} +16 -14
- data/lib/needle_in_a_haystack/models/haystack_tagging.rb +4 -0
- data/lib/needle_in_a_haystack/version.rb +1 -1
- data/lib/needle_in_a_haystack.rb +6 -2
- metadata +7 -5
- data/lib/needle_in_a_haystack/haystack_tagging.rb +0 -4
- /data/lib/needle_in_a_haystack/{haystack_ontology.rb → models/haystack_ontology.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47f3b28b275f615fb0cbfabb20d76cf70ef0adbf63875c6a2aae2c0b19e27e39
|
4
|
+
data.tar.gz: 9807a09a01410b9f299a268c828880df1e5fbbcf9cf6c7c16769b29da1fbb366
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a940a2d003014274c368e4daf453f1ab35711057eaec59a465d61ff3b319395806486fa95d3d19c7e4071f6c2e0e49cc6514079ce14b7921df722345ba9c651b
|
7
|
+
data.tar.gz: 29b755d8403392d44cb9561d2a119b1c5b61bb3ebbb269ea4b7f78c241280e396c34c52bb4a1d895e5474d9cf90bae4a74945214f31803724d4734b318a28239
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class BaseTag < ApplicationRecord
|
2
|
+
self.abstract_class = true
|
3
|
+
|
4
|
+
def name
|
5
|
+
raise NotImplementedError, "Subclasses must implement a name-method"
|
6
|
+
end
|
7
|
+
|
8
|
+
def description
|
9
|
+
raise NotImplementedError, "Subclasses must implement a description-method"
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class BaseTagging < ApplicationRecord
|
2
|
+
self.abstract_class = true
|
3
|
+
|
4
|
+
def tag
|
5
|
+
raise NotImplementedError, "Subclasses must implement a tag-method"
|
6
|
+
end
|
7
|
+
|
8
|
+
def taggable
|
9
|
+
raise NotImplementedError, "Subclasses must implement a taggable-method"
|
10
|
+
end
|
11
|
+
end
|
@@ -1,25 +1,27 @@
|
|
1
|
-
class HaystackTag <
|
2
|
-
belongs_to :parent_tag, class_name: "
|
3
|
-
has_many :children, class_name: "
|
1
|
+
class HaystackTag < BaseTag
|
2
|
+
belongs_to :parent_tag, class_name: "HaystackTag", optional: true
|
3
|
+
has_many :children, class_name: "HaystackTag", foreign_key: "parent_tag_id", dependent: :destroy, inverse_of: :parent_tag
|
4
4
|
has_many :haystack_taggings, dependent: :destroy
|
5
5
|
has_many :taggables, through: :haystack_taggings
|
6
6
|
|
7
|
-
|
8
|
-
NeedleInAHaystack.configuration.taggable_models.each do |model|
|
9
|
-
has_many "taggable_#{model.name.underscore.pluralize}".to_sym, through: :haystack_taggings, source: :taggable, source_type: model.name
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
validates :name, presence: true
|
7
|
+
validates :name, presence: true, uniqueness: true
|
14
8
|
validates :description, presence: true
|
15
9
|
validate :prevent_circular_reference
|
16
10
|
|
11
|
+
def name
|
12
|
+
self[:name]
|
13
|
+
end
|
14
|
+
|
15
|
+
def description
|
16
|
+
self[:description]
|
17
|
+
end
|
18
|
+
|
17
19
|
def ancestors
|
18
20
|
ancestors = []
|
19
|
-
|
20
|
-
while
|
21
|
-
ancestors <<
|
22
|
-
|
21
|
+
current = self
|
22
|
+
while current.parent_tag
|
23
|
+
ancestors << current.parent_tag
|
24
|
+
current = current.parent_tag
|
23
25
|
end
|
24
26
|
ancestors
|
25
27
|
end
|
@@ -1 +1 @@
|
|
1
|
-
VERSION = "1.0.
|
1
|
+
VERSION = "1.0.3".freeze
|
data/lib/needle_in_a_haystack.rb
CHANGED
@@ -2,8 +2,12 @@ require "needle_in_a_haystack/version"
|
|
2
2
|
require "needle_in_a_haystack/engine"
|
3
3
|
require "needle_in_a_haystack/application_record"
|
4
4
|
require "needle_in_a_haystack/configuration"
|
5
|
-
require "needle_in_a_haystack/
|
6
|
-
require "needle_in_a_haystack/
|
5
|
+
require "needle_in_a_haystack/concerns/base_tagging"
|
6
|
+
require "needle_in_a_haystack/concerns/base_tag"
|
7
|
+
|
8
|
+
require "needle_in_a_haystack/models/haystack_ontology"
|
9
|
+
require "needle_in_a_haystack/models/haystack_tag"
|
10
|
+
require "needle_in_a_haystack/models/haystack_tagging"
|
7
11
|
|
8
12
|
module NeedleInAHaystack
|
9
13
|
class << self
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: needle_in_a_haystack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frans Verberne
|
@@ -275,14 +275,16 @@ files:
|
|
275
275
|
- config/initializers/redis.rb
|
276
276
|
- config/initializers/wrap_parameters.rb
|
277
277
|
- config/locales/en.yml
|
278
|
-
- lib/concerns/taggable.rb
|
279
278
|
- lib/needle_in_a_haystack.rb
|
280
279
|
- lib/needle_in_a_haystack/application_record.rb
|
280
|
+
- lib/needle_in_a_haystack/concerns/base_tag.rb
|
281
|
+
- lib/needle_in_a_haystack/concerns/base_tagging.rb
|
282
|
+
- lib/needle_in_a_haystack/concerns/taggable.rb
|
281
283
|
- lib/needle_in_a_haystack/configuration.rb
|
282
284
|
- lib/needle_in_a_haystack/engine.rb
|
283
|
-
- lib/needle_in_a_haystack/haystack_ontology.rb
|
284
|
-
- lib/needle_in_a_haystack/haystack_tag.rb
|
285
|
-
- lib/needle_in_a_haystack/haystack_tagging.rb
|
285
|
+
- lib/needle_in_a_haystack/models/haystack_ontology.rb
|
286
|
+
- lib/needle_in_a_haystack/models/haystack_tag.rb
|
287
|
+
- lib/needle_in_a_haystack/models/haystack_tagging.rb
|
286
288
|
- lib/needle_in_a_haystack/version.rb
|
287
289
|
- lib/tasks/location_create.rake
|
288
290
|
- spec/factories/haystack_tags.rb
|
File without changes
|