humanid 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/humanid.gemspec +1 -1
- data/lib/humanid.rb +1 -1
- data/lib/humanid/extension/builder.rb +1 -1
- data/lib/humanid/transliteration.rb +10 -5
- 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: 2c04809d89194272a646adae214107d477077393
|
4
|
+
data.tar.gz: 5d0b923257713e148f9fe159eae757c760eb1e61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e24b77a2840a8d7c33850ee7d98ed9175c148ba97d4077bc5b9389789640712829a5459e4237102ecc17a10418a7f184ab3536605c88208f220369c688f7465
|
7
|
+
data.tar.gz: a06914346a5af6108ee18d8d6c2bdad20ef1de677d567504879dde34467af33b6f7f47bf34b467eadc9274bd14d8a7d445bd98ffcb08cd7e9a93afbcb5b9229d
|
data/humanid.gemspec
CHANGED
data/lib/humanid.rb
CHANGED
@@ -79,8 +79,8 @@ module HumanID
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def add_persistence_callbacks
|
82
|
+
@model.after_create :"assign_#{@human_id}!", if: :"need_to_update_#{@human_id}?"
|
82
83
|
@model.before_validation :"assign_#{@human_id}", if: :"need_to_update_#{@human_id}?"
|
83
|
-
@model.after_save :"assign_#{@human_id}!", if: :"need_to_update_#{@human_id}?"
|
84
84
|
end
|
85
85
|
|
86
86
|
def add_uniqueness_validation
|
@@ -30,16 +30,21 @@ module HumanID
|
|
30
30
|
str = str.downcase if downcase
|
31
31
|
|
32
32
|
if normalize
|
33
|
-
# Strip leading and trailing non-word and non-ASCII characters
|
34
|
-
str = str.gsub(/(\A\W+)|(\W+\z)/, '')
|
35
33
|
|
36
|
-
# Replace
|
37
|
-
str = str.gsub(/\W
|
34
|
+
# Replace non-word and non-ASCII characters with hyphens.
|
35
|
+
str = str.gsub(/\W/, '-')
|
36
|
+
|
37
|
+
# Strip leading and trailing hyphens.
|
38
|
+
str = str.gsub(/(\A-+)|(-+\z)/, '')
|
39
|
+
|
40
|
+
# Collapse hyphens.
|
41
|
+
str = str.gsub(/-+/, '-')
|
42
|
+
|
38
43
|
end
|
39
44
|
|
40
45
|
str
|
41
46
|
ensure
|
42
|
-
I18n.
|
47
|
+
I18n.locale = previous_locale
|
43
48
|
end
|
44
49
|
|
45
50
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: humanid
|
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
|
- Yaroslav Konoplov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|