mongoid-path_extension 0.1.4 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +1 -1
- data/CHANGELOG.md +8 -0
- data/README.md +3 -0
- data/lib/mongoid/path_extension/version.rb +1 -1
- data/lib/mongoid/path_extension.rb +17 -16
- data/mongoid-path_extension.gemspec +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2e87b6b31e7ed916ba10faed245954aa02fc6cba4b33d09c4925d6d9e7344eb
|
4
|
+
data.tar.gz: ef77ad94990d477659361e96805ea6005b5bd1858636d4eb7e4892b49c58348f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d9ae33f7c07e6c111b6c12d59265dcb99d64506c3432f626e55d0fc73fea4777789147c426e880bd8bcc4385556fb4a0fcb4b89d9cbdc508ce306c9f3e2ecbe
|
7
|
+
data.tar.gz: b0bec0c9b219200094f7886cfc9f6e108534762940b1cfb76e93c7da916e2a496fdfd8d41b7146041cf15c7f6dcc186552cd23187e20a9d68fea612b38d7438d
|
data/.github/workflows/test.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -38,6 +38,9 @@ my_doc.path.permalink # => 'LevelThree'
|
|
38
38
|
my_doc.path.parent_path # => 'LevelOne/LevelTwo'
|
39
39
|
my_doc.path.parent_permalink # => 'LevelTwo'
|
40
40
|
my_doc.path.has_parent? # => true
|
41
|
+
|
42
|
+
my_doc.path.permalink = 'NewPermalink'
|
43
|
+
puts my_doc.path.permalink # => 'NewPermalink'
|
41
44
|
```
|
42
45
|
|
43
46
|
## Development
|
@@ -2,6 +2,8 @@ require 'mongoid'
|
|
2
2
|
|
3
3
|
module Mongoid
|
4
4
|
class PathExtension < String
|
5
|
+
delegate(:permalink, to: :parent, prefix: true)
|
6
|
+
|
5
7
|
def initialize(str)
|
6
8
|
super str.to_s
|
7
9
|
@str = str.to_s
|
@@ -20,32 +22,31 @@ module Mongoid
|
|
20
22
|
components.last
|
21
23
|
end
|
22
24
|
|
25
|
+
def permalink=(value)
|
26
|
+
return if value.blank?
|
27
|
+
new_str = [parent&.to_s, value].compact.join("/")
|
28
|
+
@str.replace(new_str)
|
29
|
+
end
|
30
|
+
|
23
31
|
def absolute
|
24
32
|
['/', @str].join
|
25
33
|
end
|
26
34
|
|
27
35
|
def has_parent?
|
28
|
-
|
36
|
+
parent.present?
|
29
37
|
end
|
30
38
|
|
31
|
-
def
|
32
|
-
|
33
|
-
res = []
|
34
|
-
components[0..-2].each_with_index do |component, index|
|
35
|
-
res << components[0..index].join('/')
|
36
|
-
end
|
37
|
-
res
|
39
|
+
def parent
|
40
|
+
ancestors.last
|
38
41
|
end
|
42
|
+
alias_method :parent_path, :parent
|
39
43
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
def parent_permalink
|
46
|
-
return unless has_parent?
|
47
|
-
components[-2]
|
44
|
+
def ancestors
|
45
|
+
components[0..-2].each_with_index.map do |component, index|
|
46
|
+
Mongoid::PathExtension.new(components[0..index].join('/'))
|
47
|
+
end
|
48
48
|
end
|
49
|
+
alias_method :ancestor_paths, :ancestors
|
49
50
|
|
50
51
|
class << self
|
51
52
|
def demongoize(value)
|
@@ -25,5 +25,5 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency 'guard'
|
26
26
|
spec.add_development_dependency 'guard-minitest'
|
27
27
|
spec.add_development_dependency 'minitest'
|
28
|
-
spec.add_development_dependency 'rake'
|
28
|
+
spec.add_development_dependency 'rake'
|
29
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-path_extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -98,16 +98,16 @@ dependencies:
|
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '0'
|
111
111
|
description:
|
112
112
|
email:
|
113
113
|
- tomas.celizna@gmail.com
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
- !ruby/object:Gem::Version
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
|
-
rubygems_version: 3.
|
156
|
+
rubygems_version: 3.5.17
|
157
157
|
signing_key:
|
158
158
|
specification_version: 4
|
159
159
|
summary: Mongoid field extension simplifying path parsing.
|