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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a64d1071c4dbf56186641557dfba393fdf97339
4
- data.tar.gz: 738b2dd24a3b76c577f415e17517558912ce4c26
3
+ metadata.gz: 2c04809d89194272a646adae214107d477077393
4
+ data.tar.gz: 5d0b923257713e148f9fe159eae757c760eb1e61
5
5
  SHA512:
6
- metadata.gz: 39b2e31eff31f19eaa895f4db037a59879c53c38d8884a780bda2976470d3efc6d9747f67a21353ed82ed48545ee5821a57e9cff883553fcd196bef1c67b1907
7
- data.tar.gz: dbec0ab755aefbc7d0c5a542804222dc8aae7e80341f56925671071a897d573e7352d8dc0e0aca8b47ccabb38f1008a63389069700229685f79207d6165edec4
6
+ metadata.gz: 1e24b77a2840a8d7c33850ee7d98ed9175c148ba97d4077bc5b9389789640712829a5459e4237102ecc17a10418a7f184ab3536605c88208f220369c688f7465
7
+ data.tar.gz: a06914346a5af6108ee18d8d6c2bdad20ef1de677d567504879dde34467af33b6f7f47bf34b467eadc9274bd14d8a7d445bd98ffcb08cd7e9a93afbcb5b9229d
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'humanid'
6
- s.version = '1.0.1'
6
+ s.version = '1.0.3'
7
7
  s.authors = ['Yaroslav Konoplov']
8
8
  s.email = ['eahome00@gmail.com']
9
9
  s.summary = 'ActiveRecord human id'
@@ -38,5 +38,5 @@ class ActiveRecord::Base
38
38
  end
39
39
 
40
40
  class ActiveRecord::ConnectionAdapters::TableDefinition
41
- include HumanID::ColumnTypes
41
+ include HumanID::Migration
42
42
  end
@@ -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 the rest of non-word and non-ASCII characters with hyphen
37
- str = str.gsub(/\W+/, separator)
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.default_locale = previous_locale
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.1
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-10-23 00:00:00.000000000 Z
11
+ date: 2016-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport