railhead_permalink 0.2.7 → 0.3.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.
- checksums.yaml +4 -4
- data/lib/railhead_permalink.rb +8 -8
- data/railhead_permalink.gemspec +2 -2
- 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: 1df951f172d983cb4441b50dd86d57033ac5c38d
|
4
|
+
data.tar.gz: 361f8886278022895a3eca95f398d9ca7495a9d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d9755006f6bd7d8c0f6a89f865c5755e5a7c5e27d24c75d64435d77e0891def0f0914770501eda7b55b8294b3ec7ce239a51c3538bc0c6434d9e908ad7236d1
|
7
|
+
data.tar.gz: 5a0799954487dd0897f5153ccfc2831265227664ab74317a9215fcd6d3ee5ec1bab43bdbac98a0526df6d179590a7fff929d5a257c3359c7a060a2db3b75485d
|
data/lib/railhead_permalink.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
begin
|
2
2
|
require 'stringex_lite'
|
3
|
-
# stringex fix
|
3
|
+
# stringex 2.7.1 fix | 'Auður Ava Ólafdóttir'.to_url => "audur-ava-lafdottir"
|
4
4
|
class String
|
5
5
|
def to_url
|
6
6
|
Stringex::Unidecoder.decode(self).parameterize
|
@@ -32,21 +32,21 @@ module RailheadPermalink
|
|
32
32
|
class_attribute :permalink_options
|
33
33
|
|
34
34
|
self.permalink_options = {
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
35
|
+
field: field,
|
36
|
+
keep_existing: (options[:keep_existing] || false),
|
37
|
+
reserved_names: (options[:reserved_names] || []),
|
38
|
+
unique: (options[:unique] || false)
|
39
39
|
}
|
40
40
|
|
41
41
|
before_save :create_permalink
|
42
42
|
validates_presence_of field
|
43
|
-
validates_uniqueness_of field, :
|
43
|
+
validates_uniqueness_of field, case_sensitive: false, if: "#{field}_changed?".to_sym if permalink_options[:unique]
|
44
44
|
end
|
45
45
|
|
46
46
|
def find_with_permalink(*args)
|
47
47
|
key = args.first
|
48
48
|
if key.is_a?(String)
|
49
|
-
|
49
|
+
find_by(permalink: key) || find_without_permalink(*args)
|
50
50
|
else
|
51
51
|
find_without_permalink(*args)
|
52
52
|
end
|
@@ -62,7 +62,7 @@ module RailheadPermalink
|
|
62
62
|
unless self.permalink == key
|
63
63
|
permalink, counter = key, '-1'
|
64
64
|
while permalink_options[:reserved_names].include?(permalink) or permalink.blank? or
|
65
|
-
(object = self.class.where(:
|
65
|
+
(object = self.class.where(permalink: permalink).first and object != self)
|
66
66
|
counter.succ!
|
67
67
|
permalink = key + counter
|
68
68
|
end
|
data/railhead_permalink.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "railhead_permalink"
|
3
|
-
s.version = "0.
|
4
|
-
s.date = "2017-
|
3
|
+
s.version = "0.3.0"
|
4
|
+
s.date = "2017-08-29"
|
5
5
|
s.summary = "RailheadPermalink is a Ruby on Rails plugin that automatically finds ActiveRecord objects with permalink."
|
6
6
|
s.email = "bence.nagy@gmail.com"
|
7
7
|
s.homepage = "http://github.com/nagybence/railhead_permalink"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: railhead_permalink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bence Nagy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: bence.nagy@gmail.com
|