telephone_number 1.3.3 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/data/geocoding/de/43.dat +0 -0
  3. data/data/geocoding/de/43.txt +9 -2
  4. data/data/geocoding/de/49.dat +0 -0
  5. data/data/geocoding/de/49.txt +2 -2
  6. data/data/geocoding/en/261.dat +0 -0
  7. data/data/geocoding/en/261.txt +0 -2
  8. data/data/geocoding/en/263.dat +0 -0
  9. data/data/geocoding/en/263.txt +9 -25
  10. data/data/geocoding/en/33.dat +0 -0
  11. data/data/geocoding/en/33.txt +28 -216
  12. data/data/geocoding/en/358.dat +0 -0
  13. data/data/geocoding/en/358.txt +1 -8
  14. data/data/geocoding/en/370.dat +0 -0
  15. data/data/geocoding/en/370.txt +1 -1
  16. data/data/geocoding/en/43.dat +0 -0
  17. data/data/geocoding/en/43.txt +9 -2
  18. data/data/geocoding/en/49.dat +0 -0
  19. data/data/geocoding/en/49.txt +2 -2
  20. data/data/geocoding/en/52.dat +0 -0
  21. data/data/geocoding/en/52.txt +12 -40
  22. data/data/geocoding/en/60.dat +0 -0
  23. data/data/geocoding/en/60.txt +32 -44
  24. data/data/geocoding/en/64.dat +0 -0
  25. data/data/geocoding/en/64.txt +18 -2
  26. data/data/geocoding/en/91.dat +0 -0
  27. data/data/geocoding/en/91.txt +12 -5
  28. data/data/geocoding/es/52.dat +0 -0
  29. data/data/geocoding/es/52.txt +11 -39
  30. data/data/geocoding/fi/358.dat +0 -0
  31. data/data/geocoding/fi/358.txt +1 -8
  32. data/data/geocoding/fr/33.dat +0 -0
  33. data/data/geocoding/fr/33.txt +28 -216
  34. data/data/geocoding/sv/358.dat +0 -0
  35. data/data/geocoding/sv/358.txt +1 -8
  36. data/data/telephone_number_data_file.dat +0 -0
  37. data/data/telephone_number_data_file.xml +2999 -2632
  38. data/data/timezones/map_data.dat +0 -0
  39. data/data/timezones/map_data.txt +64 -968
  40. data/lib/telephone_number/formatter.rb +11 -15
  41. data/lib/telephone_number/version.rb +1 -1
  42. metadata +2 -2
@@ -34,19 +34,15 @@ module TelephoneNumber
34
34
  end
35
35
 
36
36
  def build_national_number(formatted: true)
37
- captures = normalized_number.match(number_format.pattern).captures
38
-
39
- formatted_string = format(ruby_format_string(number_format.format), *captures)
40
- captures.delete(country.mobile_token)
41
-
42
- if number_format.national_prefix_formatting_rule
43
- national_prefix_string = number_format.national_prefix_formatting_rule.dup
44
- national_prefix_string.gsub!(/\$NP/, country.national_prefix.to_s)
45
- national_prefix_string.gsub!(/\$FG/, captures[0])
46
- formatted_string.sub!(captures[0], national_prefix_string)
37
+ national_prefix_formatting_rule = number_format.national_prefix_formatting_rule
38
+ formatted_number = if national_prefix_formatting_rule
39
+ national_prefix_formatting_rule = national_prefix_formatting_rule.sub(/\$NP/, country.national_prefix.to_s).sub(/\$FG/, '\\\1')
40
+ format = number_format.format.sub(/(\$\d)/, national_prefix_formatting_rule).gsub(/\$/, '\\\\')
41
+ normalized_number.sub(number_format.pattern, format)
42
+ else
43
+ normalized_number.sub(number_format.pattern, number_format.format.gsub(/\$/, '\\\\'))
47
44
  end
48
-
49
- formatted ? formatted_string : TelephoneNumber.sanitize(formatted_string)
45
+ formatted ? formatted_number : TelephoneNumber.sanitize(formatted_number)
50
46
  end
51
47
 
52
48
  def build_e164_number(formatted: true)
@@ -56,9 +52,9 @@ module TelephoneNumber
56
52
 
57
53
  def build_international_number(formatted: true)
58
54
  return original_or_default if !valid? || number_format.nil?
59
- captures = normalized_number.match(number_format.pattern).captures
60
- key = number_format.intl_format || number_format.format
61
- formatted_string = "+#{country.country_code} #{format(ruby_format_string(key), *captures)}"
55
+ format_to_use = number_format.intl_format || number_format.format
56
+ formatted_string = normalized_number.sub(number_format.pattern, format_to_use.gsub(/\$/, '\\\\'))
57
+ formatted_string = "+#{country.country_code} #{formatted_string}"
62
58
  formatted ? formatted_string : TelephoneNumber.sanitize(formatted_string)
63
59
  end
64
60
 
@@ -1,3 +1,3 @@
1
1
  module TelephoneNumber
2
- VERSION = "1.3.3"
2
+ VERSION = "1.3.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telephone_number
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - MOBI Wireless Management
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-13 00:00:00.000000000 Z
11
+ date: 2018-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler