rentlinx 0.9.2 → 0.9.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: f7ed5ff7c85420c6a64056f16eb8c0be453f5c55
4
- data.tar.gz: 78f10e0fcb464325ed9a6054ad006388c2136bee
3
+ metadata.gz: 0551c6f33a75e1776a0bb4d932c0a4b4e09f5591
4
+ data.tar.gz: 9354d52fbf2bd6f1cc3757332ca92ca8e10893a2
5
5
  SHA512:
6
- metadata.gz: cb2c09a3a2888959e63d3a2026f499fa8118c73e5aa34eeeaaf6c35fe7bce5ec9adddfa83f3556ebaffc4438eadabe52767d64a50f894cb12d40188debb54b3e
7
- data.tar.gz: a71d96fa5e04166e0f9181a62375631b840369d97557be03f6c819795e30ccd28e3171e5cc81e19f4b11ea5d1e18f3398d5c67feb367aa5f14c1aef8e3fe97f4
6
+ metadata.gz: becc388be2bcfe16eeff36740e784671a624d940e06badbe9f6a205e92132b249b3f0c74440538c2a40b6e474207bcb6a9751a47071a7a6f862dc41d310af4e0
7
+ data.tar.gz: fd6a4aee865dd53a85dc43dd34e4c4dcef0359cd1aa34c4a02e8b927fb0e3c3d44150590021ae89aab06fc5b81f954493a1732db846bd6ce9827fc75ecc409c4
@@ -1,20 +1,28 @@
1
- require 'phony'
2
-
3
1
  module Rentlinx
4
2
  # Validator for phone numbers
5
3
  class PhoneValidator < BaseValidator
6
- # Validates and normalizes the phone number with Phony
4
+ # Validates and normalizes the phone number
7
5
  def processed_value
8
6
  return '' if value_blank?
9
7
  return @value unless valid?
10
- Phony.normalize(@value)
8
+ @value.gsub(/\D/, '')
11
9
  end
12
10
 
13
11
  private
14
12
 
15
13
  def validate
16
- return if value_blank? || Phony.plausible?(@value) || Phony.plausible?('1' + @value)
14
+ return if value_blank? ||
15
+ valid_us_number_without_country_code?(processed_value) ||
16
+ valid_us_number_with_country_code?(processed_value)
17
17
  @error = "#{@value} is not a valid phone number"
18
18
  end
19
+
20
+ def valid_us_number_with_country_code?(number)
21
+ number.start_with?('1') && valid_us_number_without_country_code?(number[1..-1])
22
+ end
23
+
24
+ def valid_us_number_without_country_code?(number)
25
+ !number.start_with?('1') && !number.start_with?('0') && number.size == 10
26
+ end
19
27
  end
20
28
  end
@@ -1,5 +1,5 @@
1
1
  # This is the main rentlinx module. All Rentlinx objects
2
2
  # and methods are namespaced under this module.
3
3
  module Rentlinx
4
- VERSION = '0.9.2'
4
+ VERSION = '0.9.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rentlinx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - AppFolio, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-07 00:00:00.000000000 Z
11
+ date: 2015-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.8'
41
- - !ruby/object:Gem::Dependency
42
- name: phony
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '2.12'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '2.12'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: logging
57
43
  requirement: !ruby/object:Gem::Requirement