active_permalink 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df15e663dd9dd5bb8b4b873ccdd92a6d0b116547d143336ed9520bd4ac25ea81
|
4
|
+
data.tar.gz: 3bd4f5b7cdaef63d23ffd393647a4207d5d57c2ded5c98838e92ad91c1b62dcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d14ea28b8b4d5ef42ad0272f3a265c51dba1aa07f42349dcea0ed7c8c35e36c8b416f069e81573ce7e284509d31c7c8f6053d9bdcd925b1475208129f968a0d2
|
7
|
+
data.tar.gz: 1086cd95f88ba1a9d516026fa5376f549209a06b93334efe4a68ae7fc95dd35b53c19e1da2ddaa2f30bda46787c5f92e2633405eb44ae8391d7e6303f1df97c2
|
@@ -3,10 +3,10 @@ require 'any_ascii'
|
|
3
3
|
module ActivePermalink
|
4
4
|
class Generator
|
5
5
|
class << self
|
6
|
-
def generate(record, value, locale = nil)
|
6
|
+
def generate(record, value, locale = nil, raw: false)
|
7
7
|
return if value.nil? && !record.slug_should_generate?
|
8
8
|
|
9
|
-
options = record.permalink_options.merge(locale: locale)
|
9
|
+
options = record.permalink_options.merge(locale: locale, raw: raw)
|
10
10
|
generator = Generator.new(record, options)
|
11
11
|
generator.generate(value)
|
12
12
|
|
@@ -93,6 +93,8 @@ module ActivePermalink
|
|
93
93
|
value = @new_value.presence || @record.send(@field)
|
94
94
|
return if value.blank?
|
95
95
|
|
96
|
+
return value if @options[:raw] == true
|
97
|
+
|
96
98
|
value = AnyAscii.transliterate(value)
|
97
99
|
value.parameterize
|
98
100
|
end
|
@@ -29,8 +29,8 @@ module ActivePermalink
|
|
29
29
|
|
30
30
|
private
|
31
31
|
|
32
|
-
def _generate_permalink_slug(value)
|
33
|
-
slug_backend.write(value, I18n.locale)
|
32
|
+
def _generate_permalink_slug(value, **options)
|
33
|
+
slug_backend.write(value, I18n.locale, **options)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -60,9 +60,9 @@ module ActivePermalink
|
|
60
60
|
find_slug(locale)
|
61
61
|
end
|
62
62
|
|
63
|
-
def write(value, locale)
|
63
|
+
def write(value, locale, **options)
|
64
64
|
enforce_available_locales!(locale)
|
65
|
-
update_slug(value, locale)
|
65
|
+
update_slug(value, locale, **options)
|
66
66
|
end
|
67
67
|
|
68
68
|
private
|
@@ -97,8 +97,8 @@ module ActivePermalink
|
|
97
97
|
permalink.try(:slug)
|
98
98
|
end
|
99
99
|
|
100
|
-
def update_slug(value, locale)
|
101
|
-
Generator.generate(record, value, locale)
|
100
|
+
def update_slug(value, locale, **options)
|
101
|
+
Generator.generate(record, value, locale, **options)
|
102
102
|
@permalinks = record.permalinks.to_a
|
103
103
|
end
|
104
104
|
end
|
@@ -12,6 +12,10 @@ module ActivePermalink
|
|
12
12
|
on: [:create, :update],
|
13
13
|
if: :slug_needs_generate?
|
14
14
|
|
15
|
+
def raw_slug=(value)
|
16
|
+
_generate_permalink_slug(value, raw: true)
|
17
|
+
end
|
18
|
+
|
15
19
|
def slug=(value)
|
16
20
|
_generate_permalink_slug(value)
|
17
21
|
end
|
@@ -37,8 +41,8 @@ module ActivePermalink
|
|
37
41
|
@slug_should_generate = false
|
38
42
|
end
|
39
43
|
|
40
|
-
def _generate_permalink_slug(value)
|
41
|
-
Generator.generate(self, value)
|
44
|
+
def _generate_permalink_slug(value, **options)
|
45
|
+
Generator.generate(self, value, **options)
|
42
46
|
end
|
43
47
|
end
|
44
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_permalink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonian Guveli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
- !ruby/object:Gem::Version
|
143
143
|
version: '0'
|
144
144
|
requirements: []
|
145
|
-
rubygems_version: 3.1.
|
145
|
+
rubygems_version: 3.1.6
|
146
146
|
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: Add permalinks to ActiveRecord models
|