phonelib 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +9 -3
  3. data/data/extended_data.dat +0 -0
  4. data/data/libphonenumber/README.md +1 -1
  5. data/data/libphonenumber/cpp/src/phonenumbers/lite_metadata.cc +6313 -6305
  6. data/data/libphonenumber/cpp/src/phonenumbers/metadata.cc +5989 -5980
  7. data/data/libphonenumber/cpp/src/phonenumbers/short_metadata.cc +2063 -1977
  8. data/data/libphonenumber/java/build.xml +30 -0
  9. data/data/libphonenumber/java/carrier/pom.xml +4 -4
  10. data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/227_en +0 -0
  11. data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/231_en +0 -0
  12. data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/252_en +0 -0
  13. data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/254_en +0 -0
  14. data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/255_en +0 -0
  15. data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/40_en +0 -0
  16. data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/509_en +0 -0
  17. data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/91_en +0 -0
  18. data/data/libphonenumber/java/carrier/src/com/google/i18n/phonenumbers/carrier/data/95_en +0 -0
  19. data/data/libphonenumber/java/demo/pom.xml +5 -5
  20. data/data/libphonenumber/java/geocoder/pom.xml +4 -4
  21. data/data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/1854_en +0 -0
  22. data/data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/264_en +0 -0
  23. data/data/libphonenumber/java/geocoder/src/com/google/i18n/phonenumbers/geocoding/data/config +0 -0
  24. data/data/libphonenumber/java/internal/prefixmapper/pom.xml +3 -3
  25. data/data/libphonenumber/java/libphonenumber/pom.xml +16 -2
  26. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/ShortNumbersRegionCodeSet.java +8 -2
  27. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/SingleFileMetadataSourceImpl.java +98 -0
  28. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_IN +0 -0
  29. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_KE +0 -0
  30. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_LR +0 -0
  31. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MM +0 -0
  32. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_MR +0 -0
  33. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NA +0 -0
  34. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_NE +0 -0
  35. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_PT +0 -0
  36. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_RO +0 -0
  37. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_SO +0 -0
  38. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_TZ +0 -0
  39. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/PhoneNumberMetadataProto_US +0 -0
  40. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/ShortNumberMetadataProto_CD +0 -0
  41. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/ShortNumberMetadataProto_CF +0 -0
  42. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/ShortNumberMetadataProto_CG +0 -0
  43. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/ShortNumberMetadataProto_ER +0 -0
  44. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/ShortNumberMetadataProto_KP +0 -0
  45. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/ShortNumberMetadataProto_NE +0 -0
  46. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/ShortNumberMetadataProto_NO +0 -0
  47. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/ShortNumberMetadataProto_PT +0 -0
  48. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/ShortNumberMetadataProto_SO +0 -0
  49. data/data/libphonenumber/java/libphonenumber/src/com/google/i18n/phonenumbers/data/SingleFilePhoneNumberMetadataProto +0 -0
  50. data/data/libphonenumber/java/libphonenumber/test/com/google/i18n/phonenumbers/data/SingleFilePhoneNumberMetadataProtoForTesting +0 -0
  51. data/data/libphonenumber/java/pom.xml +1 -1
  52. data/data/libphonenumber/java/release_notes.txt +12 -0
  53. data/data/libphonenumber/javascript/README.md +86 -0
  54. data/data/libphonenumber/javascript/i18n/phonenumbers/demo-compiled.js +73 -73
  55. data/data/libphonenumber/javascript/i18n/phonenumbers/metadata.js +29 -29
  56. data/data/libphonenumber/javascript/i18n/phonenumbers/metadatalite.js +29 -29
  57. data/data/libphonenumber/resources/PhoneNumberMetadata.xml +86 -66
  58. data/data/libphonenumber/resources/ShortNumberMetadata.xml +276 -24
  59. data/data/libphonenumber/resources/carrier/en/227.txt +1 -0
  60. data/data/libphonenumber/resources/carrier/en/231.txt +3 -0
  61. data/data/libphonenumber/resources/carrier/en/252.txt +3 -0
  62. data/data/libphonenumber/resources/carrier/en/254.txt +3 -0
  63. data/data/libphonenumber/resources/carrier/en/255.txt +6 -0
  64. data/data/libphonenumber/resources/carrier/en/40.txt +1 -0
  65. data/data/libphonenumber/resources/carrier/en/509.txt +5 -5
  66. data/data/libphonenumber/resources/carrier/en/880.txt +1 -1
  67. data/data/libphonenumber/resources/carrier/en/91.txt +37 -4
  68. data/data/libphonenumber/resources/carrier/en/95.txt +29 -0
  69. data/data/libphonenumber/resources/geocoding/en/1.txt +1 -0
  70. data/data/libphonenumber/resources/geocoding/en/264.txt +1 -0
  71. data/data/libphonenumber/tools/java/cpp-build/target/cpp-build-1.0-SNAPSHOT-jar-with-dependencies.jar +0 -0
  72. data/data/libphonenumber/tools/java/java-build/src/com/google/i18n/phonenumbers/BuildMetadataProtoFromXml.java +32 -14
  73. data/data/libphonenumber/tools/java/java-build/target/java-build-1.0-SNAPSHOT-jar-with-dependencies.jar +0 -0
  74. data/data/phone_data.dat +0 -0
  75. data/lib/phonelib/core.rb +15 -0
  76. data/lib/phonelib/data_importer.rb +12 -0
  77. data/lib/phonelib/phone_analyzer.rb +6 -109
  78. data/lib/phonelib/phone_analyzer_helper.rb +128 -0
  79. data/lib/phonelib/version.rb +1 -1
  80. data/lib/phonelib.rb +1 -0
  81. metadata +28 -3
  82. data/data/libphonenumber/javascript/README +0 -101
@@ -14,7 +14,7 @@
14
14
 
15
15
  88011|Citycell
16
16
  88015|TeleTalk
17
- 88016|Beeong3G
17
+ 88016|Airtel
18
18
  88017|Grameenphone
19
19
  88018|Robi
20
20
  88019|Banglalink
@@ -153,8 +153,34 @@
153
153
  917241|Idea
154
154
  917247|Idea
155
155
  917248|Idea
156
- 917250|AirTel
157
- 917259|AirTel
156
+ 9172490|Telewings
157
+ 9172491|Telewings
158
+ 9172492|Telewings
159
+ 9172493|Telewings
160
+ 9172494|Telewings
161
+ 9172495|Telewings
162
+ 9172496|Telewings
163
+ 9172498|Telewings
164
+ 9172499|Vodafone
165
+ 917250|Airtel
166
+ 917251|Vodafone
167
+ 917252|Vodafone
168
+ 917253|Vodafone
169
+ 917254|Idea
170
+ 917255|Idea
171
+ 917256|Idea
172
+ 9172570|Idea
173
+ 9172578|Airtel
174
+ 9172579|Airtel
175
+ 917258|Airtel
176
+ 917259|Airtel
177
+ 917260|Airtel
178
+ 9172610|Airtel
179
+ 9172618|Airtel
180
+ 9172619|Vodafone
181
+ 917262|Vodafone
182
+ 917263|Vodafone
183
+ 917264|Vodafone
158
184
  917265|Idea
159
185
  917266|Telewings
160
186
  917267|Telewings
@@ -1138,6 +1164,9 @@
1138
1164
  918521|AirTel
1139
1165
  918522|Telewings
1140
1166
  918523|Telewings
1167
+ 9185239|Vodafone
1168
+ 918524|Vodafone
1169
+ 918525|Vodafone
1141
1170
  918526|Aircel
1142
1171
  918527|AirTel
1143
1172
  918528|Videocon
@@ -1413,6 +1442,10 @@
1413
1442
  918827|AirTel
1414
1443
  9188280|Airtel
1415
1444
  9188285|Idea
1445
+ 9188286|Idea
1446
+ 9188287|Idea
1447
+ 9188288|Idea
1448
+ 9188289|Idea
1416
1449
  918829|Tata Docomo
1417
1450
  918852|Tata Docomo
1418
1451
  918853|AirTel
@@ -1650,7 +1683,7 @@
1650
1683
  919103|Reliance
1651
1684
  919104|Telewings
1652
1685
  919105|Loop Mobile
1653
- 919106|Loop Mobile
1686
+ 919106|Tata Docomo
1654
1687
  919107|Loop Mobile
1655
1688
  919108|Airtel
1656
1689
  919109|Loop Mobile
@@ -2058,7 +2091,7 @@
2058
2091
  919512|Vodafone
2059
2092
  919513|ETISALAT
2060
2093
  919514|ETISALAT
2061
- 919515|Etisalat DB(cheers)
2094
+ 919515|Airtel
2062
2095
  919516|Etisalat DB(cheers)
2063
2096
  919517|ETISALAT
2064
2097
  919518|ETISALAT
@@ -12,6 +12,35 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ 959250|Huawei
16
+ 959251|Huawei
17
+ 959252|Huawei
18
+ 959253|Huawei
19
+ 959254|Huawei
20
+ 9592557|ASB
21
+ 9592558|ASB
22
+ 9592559|ASB
23
+ 959256|ZTE
24
+ 959257|ZTE
25
+ 959258|ZTE
26
+ 959259|ZTE
27
+ 959260|Huawei
28
+ 959261|Huawei
29
+ 959262|Huawei
30
+ 959263|Huawei
31
+ 959264|Huawei
32
+ 959265|ZTE
33
+ 95930|MECTel
34
+ 95931|MECTel
35
+ 95932|MECTel
36
+ 95933|MECTel
37
+ 95936|MECTel
38
+ 959426|ZTE
39
+ 959427|ZTE
40
+ 95951|ZTE
41
+ 95955|ZTE
42
+ 95977|Telenor
15
43
  95978|Telenor
16
44
  95979|Telenor
45
+ 95996|Ooredoo
17
46
  95997|Ooredoo
@@ -30181,6 +30181,7 @@
30181
30181
  1850983|Milton, FL
30182
30182
  1850994|Milton, FL
30183
30183
  1850997|Monticello, FL
30184
+ 1854|Ohio
30184
30185
  1856|New Jersey
30185
30186
  1856205|Vineland, NJ
30186
30187
  1856216|Cherry Hill, NJ
@@ -365,6 +365,7 @@
365
365
  26463297|Noordoewer
366
366
  26463345|Mariental
367
367
  26463626|Helmeringhausen
368
+ 26463683|Keetmanshoop
368
369
  26463693|South
369
370
  264637034|Keetmanshoop
370
371
  264637035|Luderitz
@@ -53,6 +53,7 @@ public class BuildMetadataProtoFromXml extends Command {
53
53
  private static final String DATA_PREFIX = "data-prefix";
54
54
  private static final String MAPPING_CLASS = "mapping-class";
55
55
  private static final String COPYRIGHT = "copyright";
56
+ private static final String SINGLE_FILE = "single-file";
56
57
  private static final String LITE_BUILD = "lite-build";
57
58
 
58
59
  private static final String HELP_MESSAGE =
@@ -62,12 +63,17 @@ public class BuildMetadataProtoFromXml extends Command {
62
63
  " --" + OUTPUT_DIR + "=PATH Use PATH as the root directory for output files.\n" +
63
64
  " --" + DATA_PREFIX +
64
65
  "=PATH Use PATH (relative to " + OUTPUT_DIR + ") as the basename when\n" +
65
- " writing phone number metadata (one file per region) in\n" +
66
- " proto format.\n" +
66
+ " writing phone number metadata in proto format.\n" +
67
+ " One file per region will be written unless " + SINGLE_FILE + "\n" +
68
+ " is set, in which case a single file will be written with\n" +
69
+ " metadata for all regions.\n" +
67
70
  " --" + MAPPING_CLASS + "=NAME Store country code mappings in the class NAME, which\n" +
68
71
  " will be written to a file in " + OUTPUT_DIR + ".\n" +
69
72
  " --" + COPYRIGHT + "=YEAR Use YEAR in generated copyright headers.\n" +
70
73
  "\n" +
74
+ " [--" + SINGLE_FILE + "=<true|false>] Optional (default: false). Whether to write\n" +
75
+ " metadata to a single file, instead of one file\n" +
76
+ " per region.\n" +
71
77
  " [--" + LITE_BUILD + "=<true|false>] Optional (default: false). In a lite build,\n" +
72
78
  " certain metadata will be omitted. At this\n" +
73
79
  " moment, example numbers information is omitted.\n" +
@@ -79,6 +85,7 @@ public class BuildMetadataProtoFromXml extends Command {
79
85
  " --" + DATA_PREFIX + "=data/PhoneNumberMetadataProto \\\n" +
80
86
  " --" + MAPPING_CLASS + "=CountryCodeToRegionCodeMap \\\n" +
81
87
  " --" + COPYRIGHT + "=2010 \\\n" +
88
+ " --" + SINGLE_FILE + "=false \\\n" +
82
89
  " --" + LITE_BUILD + "=false\n";
83
90
 
84
91
  private static final String GENERATION_COMMENT =
@@ -101,6 +108,7 @@ public class BuildMetadataProtoFromXml extends Command {
101
108
  String dataPrefix = null;
102
109
  String mappingClass = null;
103
110
  String copyright = null;
111
+ boolean singleFile = false;
104
112
  boolean liteBuild = false;
105
113
 
106
114
  for (int i = 1; i < getArgs().length; i++) {
@@ -122,6 +130,9 @@ public class BuildMetadataProtoFromXml extends Command {
122
130
  mappingClass = value;
123
131
  } else if (COPYRIGHT.equals(key)) {
124
132
  copyright = value;
133
+ } else if (SINGLE_FILE.equals(key) &&
134
+ ("true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value))) {
135
+ singleFile = "true".equalsIgnoreCase(value);
125
136
  } else if (LITE_BUILD.equals(key) &&
126
137
  ("true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value))) {
127
138
  liteBuild = "true".equalsIgnoreCase(value);
@@ -147,19 +158,26 @@ public class BuildMetadataProtoFromXml extends Command {
147
158
  PhoneMetadataCollection metadataCollection =
148
159
  BuildMetadataFromXml.buildPhoneMetadataCollection(inputFile, liteBuild);
149
160
 
150
- for (PhoneMetadata metadata : metadataCollection.getMetadataList()) {
151
- String regionCode = metadata.getId();
152
- // For non-geographical country calling codes (e.g. +800), or for alternate formats, use the
153
- // country calling codes instead of the region code to form the file name.
154
- if (regionCode.equals("001") || regionCode.isEmpty()) {
155
- regionCode = Integer.toString(metadata.getCountryCode());
156
- }
157
- PhoneMetadataCollection outMetadataCollection = new PhoneMetadataCollection();
158
- outMetadataCollection.addMetadata(metadata);
159
- FileOutputStream outputForRegion = new FileOutputStream(filePrefix + "_" + regionCode);
160
- ObjectOutputStream out = new ObjectOutputStream(outputForRegion);
161
- outMetadataCollection.writeExternal(out);
161
+ if (singleFile) {
162
+ FileOutputStream output = new FileOutputStream(filePrefix);
163
+ ObjectOutputStream out = new ObjectOutputStream(output);
164
+ metadataCollection.writeExternal(out);
162
165
  out.close();
166
+ } else {
167
+ for (PhoneMetadata metadata : metadataCollection.getMetadataList()) {
168
+ String regionCode = metadata.getId();
169
+ // For non-geographical country calling codes (e.g. +800), or for alternate formats, use the
170
+ // country calling codes instead of the region code to form the file name.
171
+ if (regionCode.equals("001") || regionCode.isEmpty()) {
172
+ regionCode = Integer.toString(metadata.getCountryCode());
173
+ }
174
+ PhoneMetadataCollection outMetadataCollection = new PhoneMetadataCollection();
175
+ outMetadataCollection.addMetadata(metadata);
176
+ FileOutputStream outputForRegion = new FileOutputStream(filePrefix + "_" + regionCode);
177
+ ObjectOutputStream out = new ObjectOutputStream(outputForRegion);
178
+ outMetadataCollection.writeExternal(out);
179
+ out.close();
180
+ }
163
181
  }
164
182
 
165
183
  Map<Integer, List<String>> countryCodeToRegionCodeMap =
data/data/phone_data.dat CHANGED
Binary file
data/lib/phonelib/core.rb CHANGED
@@ -38,6 +38,19 @@ module Phonelib
38
38
  @@default_country = country
39
39
  end
40
40
 
41
+ # flag identifies whether to use special phone types, like short code
42
+ @@parse_special = false
43
+
44
+ # getter for flag for special phone types parsing
45
+ def parse_special
46
+ @@parse_special
47
+ end
48
+
49
+ # setter for flag for special phone types parsing
50
+ def parse_special=(special)
51
+ @@parse_special = special
52
+ end
53
+
41
54
  # gem constants definition
42
55
 
43
56
  # Main data file
@@ -118,6 +131,8 @@ module Phonelib
118
131
  INTERNATIONAL_PREFIX = :international_prefix
119
132
  # Main country for code key
120
133
  MAIN_COUNTRY_FOR_CODE = :main_country_for_code
134
+ # Double country prefix flag key
135
+ DOUBLE_COUNTRY_PREFIX_FLAG = :double_prefix
121
136
  # Types key
122
137
  TYPES = :types
123
138
  # Formats key
@@ -17,6 +17,9 @@ module Phonelib
17
17
  class Importer
18
18
  include Phonelib::DataImporterHelper
19
19
 
20
+ # countries that can have double country prefix in number
21
+ DOUBLE_COUNTRY_CODES_COUNTRIES = %w(IN DE BR)
22
+
20
23
  # main data file in repo
21
24
  MAIN_FILE = 'resources/PhoneNumberMetadata.xml'
22
25
  # short number metadata
@@ -93,6 +96,7 @@ module Phonelib
93
96
  country[:types] = {}
94
97
 
95
98
  country.merge! get_types_and_formats(el.children)
99
+ country = add_double_country_flag country
96
100
  @data[country[:id]] = country
97
101
  end
98
102
  end
@@ -158,6 +162,14 @@ module Phonelib
158
162
  :c)
159
163
  end
160
164
 
165
+ # adds double country code flag in case country allows
166
+ def add_double_country_flag(country)
167
+ if DOUBLE_COUNTRY_CODES_COUNTRIES.include?(country[:id])
168
+ country[:double_prefix] = true
169
+ end
170
+ country
171
+ end
172
+
161
173
  # method extracts formats and types from xml data
162
174
  def get_types_and_formats(children)
163
175
  types = {}
@@ -1,14 +1,12 @@
1
1
  module Phonelib
2
2
  # phone analyzing methods module
3
3
  module PhoneAnalyzer
4
+ # extending with helper methods for analyze
5
+ include Phonelib::PhoneAnalyzerHelper
6
+
4
7
  # array of types not included for validation check in cycle
5
8
  NOT_FOR_CHECK = [:general_desc, :fixed_line, :mobile, :fixed_or_mobile]
6
9
 
7
- # caches regular expression, reusing it for later lookups
8
- def cr(regexp)
9
- Phonelib.phone_regexp_cache[regexp] ||= Regexp.new(regexp)
10
- end
11
-
12
10
  # parses provided phone if it is valid for country data and returns result of
13
11
  # analyze
14
12
  #
@@ -79,21 +77,14 @@ module Phonelib
79
77
  result = {}
80
78
  Phonelib.phone_data.each do |key, data|
81
79
  parsed = parse_single_country(phone, data)
80
+ if allows_double_prefix(data, phone, parsed && parsed[key])
81
+ parsed = parse_single_country("#{data[:country_code]}#{phone}", data)
82
+ end
82
83
  result.merge!(parsed) unless parsed.nil?
83
84
  end
84
85
  result
85
86
  end
86
87
 
87
- # Get country that was provided or default country in needable format
88
- #
89
- # ==== Attributes
90
- #
91
- # * +country+ - country passed for parsing
92
- def country_or_default_country(country)
93
- country = country || Phonelib.default_country
94
- country && country.to_s.upcase
95
- end
96
-
97
88
  # Create phone representation in e164 format
98
89
  #
99
90
  # ==== Attributes
@@ -113,27 +104,6 @@ module Phonelib
113
104
  end
114
105
  end
115
106
 
116
- # constructs full regex for phone validation for provided phone data
117
- # (international prefix, country code, national prefix, valid number)
118
- #
119
- # ==== Attributes
120
- #
121
- # * +data+ - country data hash
122
- # * +country_optional+ - whether to put country code as optional group
123
- def full_regex_for_data(data, type, country_optional = true)
124
- regex = []
125
- regex << "(#{data[Core::INTERNATIONAL_PREFIX]})?"
126
- regex << if country_optional
127
- "(#{data[Core::COUNTRY_CODE]})?"
128
- else
129
- data[Core::COUNTRY_CODE]
130
- end
131
- regex << "(#{data[Core::NATIONAL_PREFIX_FOR_PARSING] || data[Core::NATIONAL_PREFIX]})?"
132
- regex << "(#{data[Core::TYPES][Core::GENERAL][type]})"
133
-
134
- cr("^#{regex.join}$")
135
- end
136
-
137
107
  # returns national number and analyzing results for provided phone number
138
108
  #
139
109
  # ==== Attributes
@@ -152,21 +122,6 @@ module Phonelib
152
122
  { result[:id] => result }
153
123
  end
154
124
 
155
- # Check if phone match country data
156
- #
157
- # ==== Attributes
158
- #
159
- # * +phone+ - phone number for parsing
160
- # * +data+ - country data
161
- def phone_match_data?(phone, data, possible = false)
162
- country_code = "#{data[Core::COUNTRY_CODE]}"
163
- inter_prefix = "(#{data[Core::INTERNATIONAL_PREFIX]})?"
164
- return unless phone.match cr("^#{inter_prefix}#{country_code}")
165
-
166
- type = possible ? Core::POSSIBLE_PATTERN : Core::VALID_PATTERN
167
- phone.match full_regex_for_data(data, type, false)
168
- end
169
-
170
125
  # Returns all valid and possible phone number types for currently parsed
171
126
  # phone for provided data hash.
172
127
  #
@@ -189,28 +144,6 @@ module Phonelib
189
144
  sanitize_fixed_mobile(response)
190
145
  end
191
146
 
192
- # checks if types has both :mobile and :fixed_line and replaces it with
193
- # :fixed_or_mobile in case both present
194
- def sanitize_fixed_mobile(types)
195
- fixed_mobile = [Core::FIXED_LINE, Core::MOBILE]
196
- [:possible, :valid].each do |key|
197
- if (fixed_mobile - types[key]).empty?
198
- types[key] = types[key] - fixed_mobile + [Core::FIXED_OR_MOBILE]
199
- end
200
- end
201
- types
202
- end
203
-
204
- # returns array of phone types for check for current country data
205
- #
206
- # ==== Attributes
207
- #
208
- # * +data+ - country data hash
209
- def types_for_check(data)
210
- Core::TYPES_DESC.keys - PhoneAnalyzer::NOT_FOR_CHECK +
211
- fixed_and_mobile_keys(data)
212
- end
213
-
214
147
  # Gets matched number formatting rule or default one
215
148
  #
216
149
  # ==== Attributes
@@ -225,20 +158,6 @@ module Phonelib
225
158
  end || Core::DEFAULT_NUMBER_FORMAT
226
159
  end
227
160
 
228
- # Checks if fixed line pattern and mobile pattern are the same and returns
229
- # appropriate keys
230
- #
231
- # ==== Attributes
232
- #
233
- # * +data+ - country data
234
- def fixed_and_mobile_keys(data)
235
- if data[Core::FIXED_LINE] == data[Core::MOBILE]
236
- [Core::FIXED_OR_MOBILE]
237
- else
238
- [Core::FIXED_LINE, Core::MOBILE]
239
- end
240
- end
241
-
242
161
  # Returns possible and valid patterns for validation for provided type
243
162
  #
244
163
  # ==== Attributes
@@ -255,27 +174,5 @@ module Phonelib
255
174
  [patterns[Core::POSSIBLE_PATTERN], patterns[Core::VALID_PATTERN]]
256
175
  end
257
176
  end
258
-
259
- # Checks if passed number matches valid and possible patterns
260
- #
261
- # ==== Attributes
262
- #
263
- # * +number+ - phone number for validation
264
- # * +possible_pattern+ - possible pattern for validation
265
- # * +national_pattern+ - valid pattern for validation
266
- def number_valid_and_possible?(number, possible_pattern, national_pattern)
267
- possible_match = number.match(cr("^(?:#{possible_pattern})$"))
268
- possible = possible_match && possible_match.to_s.length == number.length
269
-
270
- return [possible, possible] if possible_pattern == national_pattern
271
- valid = false
272
- if possible
273
- # doing national pattern match only in case possible matches
274
- national_match = number.match(cr("^(?:#{national_pattern})$"))
275
- valid = national_match && national_match.to_s.length == number.length
276
- end
277
-
278
- [valid && possible, possible]
279
- end
280
177
  end
281
178
  end