simplec 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/simplec/document.rb +10 -2
- data/app/models/simplec/document_set.rb +10 -1
- data/app/models/simplec/page.rb +8 -3
- data/lib/simplec/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dee3744e8854330cbcf79ae6c9f2495c342a02e
|
4
|
+
data.tar.gz: ff0bceb7a5930bee2c635b0cc9d46076ee70bc99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d93a2f80baa72c5db2973d063d4246c9eac0bf218be65576be8b9162733e6188cd74b85240418cc72acd40d7df426ea01f802d7e9e277c5087fd294175a59a66
|
7
|
+
data.tar.gz: 0bd3858809d3d3587920e1989e879f37e5fcdca6fcc4bce2b556f0a5fc5041e8e0b5a67ce25e6b7f9c318b8e8654e0effef128b61be40834cb643970ad781744
|
@@ -16,6 +16,14 @@ module Simplec
|
|
16
16
|
self.file.url
|
17
17
|
end
|
18
18
|
|
19
|
+
# @!visibility private
|
20
|
+
module Normalizers
|
21
|
+
def slug=(val)
|
22
|
+
super val.blank? ? nil : val
|
23
|
+
end
|
24
|
+
end
|
25
|
+
prepend Normalizers
|
26
|
+
|
19
27
|
private
|
20
28
|
|
21
29
|
def validate_subdomain_or_set!
|
@@ -25,13 +33,13 @@ module Simplec
|
|
25
33
|
end
|
26
34
|
|
27
35
|
def validate_slug!
|
28
|
-
return if self.slug.
|
36
|
+
return if self.slug.blank?
|
29
37
|
similar = self.class.where(slug: self.slug).where.not(id: self.id)
|
30
38
|
return if similar.size == 0
|
31
39
|
return if (
|
32
40
|
similar.map(&:subdomain_ids).flatten & self.subdomain_ids
|
33
41
|
).length == 0
|
34
|
-
errors.add :slug, '
|
42
|
+
errors.add :slug, 'must be unique across linked subdomains'
|
35
43
|
end
|
36
44
|
|
37
45
|
end
|
@@ -9,6 +9,14 @@ module Simplec
|
|
9
9
|
validate :validate_subdomain!
|
10
10
|
validate :validate_slug!
|
11
11
|
|
12
|
+
# @!visibility private
|
13
|
+
module Normalizers
|
14
|
+
def slug=(val)
|
15
|
+
super val.blank? ? nil : val
|
16
|
+
end
|
17
|
+
end
|
18
|
+
prepend Normalizers
|
19
|
+
|
12
20
|
private
|
13
21
|
|
14
22
|
def validate_subdomain!
|
@@ -17,12 +25,13 @@ module Simplec
|
|
17
25
|
end
|
18
26
|
|
19
27
|
def validate_slug!
|
28
|
+
return if self.slug.blank?
|
20
29
|
similar = self.class.where(slug: self.slug).where.not(id: self.id)
|
21
30
|
return if similar.size == 0
|
22
31
|
return if (
|
23
32
|
similar.map(&:subdomain_ids).flatten & self.subdomain_ids
|
24
33
|
).length == 0
|
25
|
-
errors.add :slug, '
|
34
|
+
errors.add :slug, 'must be unique across linked subdomains'
|
26
35
|
end
|
27
36
|
|
28
37
|
end
|
data/app/models/simplec/page.rb
CHANGED
@@ -392,13 +392,12 @@ module Simplec
|
|
392
392
|
# @!visibility private
|
393
393
|
module Normalizers
|
394
394
|
def slug=(val)
|
395
|
-
|
396
|
-
super val
|
395
|
+
super clean_path(val)
|
397
396
|
end
|
398
397
|
|
399
398
|
def slug
|
400
399
|
if self.parent_id && self.parent.nil?
|
401
|
-
self.path
|
400
|
+
clean_path(self.path)
|
402
401
|
else
|
403
402
|
super
|
404
403
|
end
|
@@ -410,6 +409,12 @@ module Simplec
|
|
410
409
|
|
411
410
|
private
|
412
411
|
|
412
|
+
def clean_path(val)
|
413
|
+
val ?
|
414
|
+
val.to_s.strip.gsub(/[\s-]+/, '-').gsub(/[^\w-]/, '').split('/').reject(&:blank?).join('/') :
|
415
|
+
val
|
416
|
+
end
|
417
|
+
|
413
418
|
def validate_path_not_nil!
|
414
419
|
return unless self.path.nil?
|
415
420
|
errors.add :path, "cannot be nil"
|
data/lib/simplec/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simplec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|