phonelib 0.6.31 → 0.6.32

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: 43546d3902acfd547a1f87e50e537819435332f6
4
- data.tar.gz: bf66b6bf8704ac1cfe8634073abea9b4952f3ab7
3
+ metadata.gz: b11cbc72e5e26801a5d20ca72809f466560fe557
4
+ data.tar.gz: 99888d8b8767f57c7ccc2034a714e2e6a0500633
5
5
  SHA512:
6
- metadata.gz: 7b7b9bfae6444b5024a1777cfeee308698460017d8d49f540b3da544ebec9c9631a21f988f7db9c8f574ca2170a160646763a25a323e8f1d1b5151c99d54347f
7
- data.tar.gz: de56a607d4e6d5e077014a9377978cb36055b2d789f94fb65673be7aae8b33a50c9f5dcaabf313b5a7d9150c0ea8c71d1cb993dc2a594997fd35ab1ac16cf96f
6
+ metadata.gz: 170c12fc42e597aa724905503a5cbb4bf3692dd78d6c367f05e7edc2c8b2b80439b46f2ef7e10751d1c2ec3dc37b0c57c905f584dfa423af66e2bd17d265c1b5
7
+ data.tar.gz: a0ff6272b78ddc16c36118d6e11d55dbd8fdb87555b27855460914e61315d938edf012e78aeceec62aee8bc9350e406e0c5948aa3ddfbcf34b8f94a485e60d50
data/README.md CHANGED
@@ -71,7 +71,7 @@ To set symbols that are used for separating extension from phone number for pars
71
71
 
72
72
  ``` ruby
73
73
  Phonelib.extension_separate_symbols = '#;' # for single symbol separator
74
- Phonelib.extension_separator = %w(ext # ; extension) # each string will be treated as separator
74
+ Phonelib.extension_separate_symbols = %w(ext # ; extension) # each string will be treated as separator
75
75
  ```
76
76
 
77
77
  In case you need to overwrite some Google's libphonenumber library data, you need to assign file path to this setter. File should be Marshal.dump'ed with existing structure like in ```Phonelib.phone_data```. Gem is simply doing ```merge``` between hashes.
@@ -255,6 +255,16 @@ There is a ```to_s``` method, it will return ```e164``` in case number is valid
255
255
  phone.to_s # returns number in E164 format if number is valid or original otherwise
256
256
  ```
257
257
 
258
+ You can compare 2 instances of ```Phonelib::Phone``` with ```==``` method or just use it with string
259
+
260
+ ```ruby
261
+ phone1 = Phonelib.parse('+12125551234') # Phonelib::Phone instance
262
+ phone2 = Phonelib.parse('+12125551234') # Phonelib::Phone instance
263
+ phone1 == phone2 # returns true
264
+ phone1 == '+12125551234' # returns true
265
+ phone1 == '12125551234;123' # returns true
266
+ ```
267
+
258
268
  There is extended data available for numbers. It will return <tt>nil</tt> in case there is no data or phone is impossible.
259
269
  Can return array of values in case there are some results for specified number
260
270
 
Binary file
Binary file
@@ -37,6 +37,15 @@ module Phonelib
37
37
  valid? ? e164 : original
38
38
  end
39
39
 
40
+ # Compare a phone number against a string or other parsed number
41
+ # @param other [String|Phonelib::Phone] Phone number to compare against
42
+ # @return [Boolean] result of equality comparison
43
+ def ==(other)
44
+ other = Phonelib.parse(other) unless other.is_a?(Phonelib::Phone)
45
+ return (e164 == other.e164) if valid? && other.valid?
46
+ original == other.original
47
+ end
48
+
40
49
  # method to get sanitized phone number (only numbers)
41
50
  # @return [String] Sanitized phone number
42
51
  def sanitized
@@ -50,7 +50,7 @@ module Phonelib
50
50
  national = @national_number
51
51
  if (matches = @national_number.match(cr(fmt[Core::PATTERN])))
52
52
  fmt = fmt[:intl_format] || fmt[:format]
53
- national = fmt.gsub(/\$\d/) { |el| matches[el[1].to_i] }
53
+ national = fmt.gsub(/\$\d/) { |el| matches[el[1].to_i] } unless fmt == 'NA'
54
54
  end
55
55
 
56
56
  "#{prefix}#{country_code} #{national}"
@@ -1,4 +1,4 @@
1
1
  module Phonelib
2
2
  # @private
3
- VERSION = '0.6.31'
3
+ VERSION = '0.6.32'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phonelib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.31
4
+ version: 0.6.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vadim Senderovich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-27 00:00:00.000000000 Z
11
+ date: 2019-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake