pico_phone 0.6.2-aarch64-linux

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.
@@ -0,0 +1,294 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Not loaded at runtime — exists only for YARD and IDE tooling.
4
+ # All methods are defined in ext/pico_phone/pico_phone.cpp via Rice.
5
+
6
+ module PicoPhone
7
+ # @!method self.parse(string, region = nil)
8
+ # Parse a phone number string into a PhoneNumber object.
9
+ # @param string [String] raw phone number input
10
+ # @param region [String, nil] ISO 3166-1 alpha-2 region hint (e.g. "US")
11
+ # @return [PhoneNumber]
12
+
13
+ # @!method self.valid?(string)
14
+ # @param string [String]
15
+ # @return [Boolean]
16
+
17
+ # @!method self.possible?(string)
18
+ # @param string [String]
19
+ # @return [Boolean]
20
+
21
+ # @!method self.valid_for_country?(string, region)
22
+ # @param string [String]
23
+ # @param region [String] ISO 3166-1 alpha-2 region code
24
+ # @return [Boolean]
25
+
26
+ # @!method self.possible_for_country?(string, region)
27
+ # @param string [String]
28
+ # @param region [String] ISO 3166-1 alpha-2 region code
29
+ # @return [Boolean]
30
+
31
+ # @!method self.possible_countries(string)
32
+ # Regions that could own this number based on length or pattern.
33
+ # @param string [String]
34
+ # @return [Array<String>] ISO 3166-1 alpha-2 region codes
35
+
36
+ # @!method self.valid_countries(string)
37
+ # Regions for which this number passes strict pattern validation.
38
+ # @param string [String]
39
+ # @return [Array<String>] ISO 3166-1 alpha-2 region codes
40
+
41
+ # @!method self.supported_types_for_region(region)
42
+ # @param region [String] ISO 3166-1 alpha-2 region code
43
+ # @return [Array<Symbol>]
44
+
45
+ # @!method self.example_number(region)
46
+ # @param region [String] ISO 3166-1 alpha-2 region code
47
+ # @return [PhoneNumber]
48
+
49
+ # @!method self.example_number_for_type(region, type)
50
+ # @param region [String] ISO 3166-1 alpha-2 region code
51
+ # @param type [Symbol] e.g. :mobile, :fixed_line, :toll_free
52
+ # @return [PhoneNumber]
53
+
54
+ # @!method self.emergency_number?(string, region)
55
+ # @param string [String]
56
+ # @param region [String] ISO 3166-1 alpha-2 region code
57
+ # @return [Boolean]
58
+
59
+ # @!method self.short_number_valid?(string, region)
60
+ # @param string [String]
61
+ # @param region [String] ISO 3166-1 alpha-2 region code
62
+ # @return [Boolean]
63
+
64
+ # @!method self.short_number_cost(string, region)
65
+ # @param string [String]
66
+ # @param region [String] ISO 3166-1 alpha-2 region code
67
+ # @return [Symbol] :toll_free, :standard_rate, :premium_rate, or :unknown_cost
68
+
69
+ # @!method self.supported_regions
70
+ # All region codes the library knows about (~245 in libphonenumber 9.x).
71
+ # @return [Array<String>] ISO 3166-1 alpha-2 region codes
72
+
73
+ # @!method self.convert_alpha_characters(string)
74
+ # Convert vanity number alpha characters to digits (e.g. "1-800-FLOWERS" → "1-800-3569377").
75
+ # @param string [String]
76
+ # @return [String]
77
+
78
+ # @!method self.alpha_number?(string)
79
+ # @param string [String]
80
+ # @return [Boolean]
81
+
82
+ # @!method self.country_calling_code(region)
83
+ # Returns the international calling code for a region.
84
+ # Returns 0 for unknown or invalid region codes.
85
+ # @param region [String] ISO 3166-1 alpha-2 region code (e.g. "US")
86
+ # @return [Integer] e.g. 1 for "US", 33 for "FR", 0 for unknown
87
+
88
+ # @!method self.number_match(first, second)
89
+ # Compare two phone number strings and return how closely they match.
90
+ # Neither string requires a region hint; E.164 input gives the most precise result.
91
+ # @param first [String]
92
+ # @param second [String]
93
+ # @return [Symbol] :exact_match, :nsn_match, :short_nsn_match, :no_match, or :invalid_number
94
+
95
+ # @!method self.find_numbers(text, region, leniency: :valid)
96
+ # Scan a block of text and return every phone number found in it.
97
+ # @param text [String] arbitrary text to search (must be valid UTF-8)
98
+ # @param region [String] ISO 3166-1 alpha-2 default region for numbers without a country code
99
+ # @param leniency [Symbol] :possible, :valid (default), :strict_grouping, or :exact_grouping
100
+ # @return [Array<PhoneNumberMatch>]
101
+
102
+ # Represents a single phone number match found by {PicoPhone.find_numbers}.
103
+ class PhoneNumberMatch
104
+ # Byte offset of the match start within the searched text.
105
+ # @return [Integer]
106
+ def start; end
107
+
108
+ # Exclusive byte offset of the match end within the searched text.
109
+ # The matched substring is text[start...end_index].
110
+ # @return [Integer]
111
+ def end_index; end
112
+
113
+ # The substring of the searched text that was matched.
114
+ # @return [String]
115
+ def raw_string; end
116
+
117
+ # The parsed phone number.
118
+ # @return [PhoneNumber]
119
+ def number; end
120
+ end
121
+
122
+ class PhoneNumber
123
+ # @param string [String, nil] raw phone number input
124
+ # @param region [String, nil] ISO 3166-1 alpha-2 region hint (e.g. "US")
125
+ def initialize(string, region = nil); end
126
+
127
+ # @return [Boolean]
128
+ def valid?; end
129
+
130
+ # @return [Boolean]
131
+ def invalid?; end
132
+
133
+ # @return [Boolean]
134
+ def possible?; end
135
+
136
+ # @return [Boolean]
137
+ def impossible?; end
138
+
139
+ # Why the number is or is not possible.
140
+ # @return [Symbol] :is_possible, :is_possible_local_only, :too_short, :too_long,
141
+ # :invalid_country_code, or :invalid_length
142
+ def possible_with_reason; end
143
+
144
+ # @return [String] e.g. "(510) 274-5656"
145
+ def national; end
146
+
147
+ # @return [String] e.g. "+1 510-274-5656"
148
+ def international; end
149
+
150
+ # @return [String] e.g. "+15102745656"
151
+ def e164; end
152
+
153
+ # @return [String, nil]
154
+ def extension; end
155
+
156
+ # @return [Boolean]
157
+ def has_extension?; end
158
+
159
+ # National format with extension appended using the configured prefix.
160
+ # @return [String]
161
+ def full_national; end
162
+
163
+ # International format with extension appended using the configured prefix.
164
+ # @return [String]
165
+ def full_international; end
166
+
167
+ # E.164 format with extension appended using the configured prefix.
168
+ # @return [String]
169
+ def full_e164; end
170
+
171
+ # @return [Integer] e.g. 1 for US/CA, 61 for AU
172
+ def country_code; end
173
+
174
+ # @return [String] ISO 3166-1 alpha-2 region code (e.g. "US")
175
+ def country; end
176
+
177
+ # @return [String] geographic area code digits, or empty string if none
178
+ def area_code; end
179
+
180
+ # National significant number as plain digits, no formatting punctuation.
181
+ # @return [String]
182
+ def raw_national; end
183
+
184
+ # International number digits with calling code, no formatting punctuation.
185
+ # @return [String]
186
+ def raw_international; end
187
+
188
+ # @return [Symbol] :fixed_line, :mobile, :fixed_line_or_mobile, :toll_free,
189
+ # :premium_rate, :shared_cost, :voip, :personal_number, :pager, :uan,
190
+ # :voicemail, or :unknown
191
+ def type; end
192
+
193
+ # Subscriber number after the area code. Returns the full national number when
194
+ # there is no geographic area code (e.g. mobile numbers in AU).
195
+ # @return [String]
196
+ def local_number; end
197
+
198
+ # Text description of the geographic area the number is from (e.g. a city
199
+ # or region), falling back to the country name when no finer-grained
200
+ # description is available. Returns an empty string for non-geographical
201
+ # numbers (e.g. toll-free) or numbers that could not be parsed.
202
+ # @param language [String] two- or three-letter ISO 639 language code (default: "en")
203
+ # @return [String]
204
+ def geo_name(language = "en"); end
205
+
206
+ # Name of the carrier the number was originally allocated to. In
207
+ # countries that support mobile number portability, the number may no
208
+ # longer actually belong to this carrier -- this is the carrier at
209
+ # allocation time, not necessarily the current one. Returns an empty
210
+ # string when no carrier mapping exists for the prefix, or for numbers
211
+ # that could not be parsed.
212
+ # @param language [String] two- or three-letter ISO 639 language code (default: "en")
213
+ # @return [String]
214
+ def carrier_name(language = "en"); end
215
+
216
+ # IANA time zone names the number's prefix belongs to. A single prefix
217
+ # can map to several zones (e.g. NANPA numbers span many), hence the
218
+ # plural. Time zone identifiers aren't translated, so unlike geo_name
219
+ # and carrier_name there's no language parameter. Returns an empty
220
+ # array when no mapping exists for the prefix, or for numbers that
221
+ # could not be parsed.
222
+ # @return [Array<String>]
223
+ def timezones; end
224
+
225
+ # @param region [String] ISO 3166-1 alpha-2 region code
226
+ # @return [Boolean]
227
+ def valid_for_country?(region); end
228
+
229
+ # @param region [String] ISO 3166-1 alpha-2 region code
230
+ # @return [Boolean]
231
+ def invalid_for_country?(region); end
232
+
233
+ # The raw input string as passed to the constructor. Survives a failed parse.
234
+ # @return [String, nil]
235
+ def original; end
236
+
237
+ # E.164 for a valid number; falls back to {#original} for an invalid one.
238
+ # Returns an empty string when nil was passed as input.
239
+ # @return [String]
240
+ def to_s; end
241
+
242
+ # Format using the same style (international vs. national) as the original input.
243
+ # @return [String]
244
+ def format_in_original_format; end
245
+
246
+ # Format the number as it would be dialed from outside its home country.
247
+ # @param region [String] ISO 3166-1 alpha-2 region of the caller
248
+ # @return [String]
249
+ def out_of_country_format(region); end
250
+
251
+ # Format the number for convenient dialing on a mobile device in the given region.
252
+ # @param region [String] ISO 3166-1 alpha-2 region of the caller
253
+ # @return [String]
254
+ def mobile_dialing_format(region); end
255
+
256
+ # Regions that could own this number based on length (unambiguous codes) or
257
+ # pattern (shared calling codes like +1 or +7).
258
+ # @return [Array<String>] ISO 3166-1 alpha-2 region codes
259
+ def possible_countries; end
260
+
261
+ # Regions for which this number passes strict pattern validation.
262
+ # @return [Array<String>] ISO 3166-1 alpha-2 region codes
263
+ def valid_countries; end
264
+
265
+ # True for fixed-line numbers tied to a geographic area code.
266
+ # @return [Boolean]
267
+ def geographical?; end
268
+
269
+ # Compare this number against another and return how closely they match.
270
+ # Pass a String or a PhoneNumber. When passed a PhoneNumber, the country code
271
+ # stored in the proto is used for comparison, giving more precise results than
272
+ # a bare national-format string.
273
+ # @param other [String, PhoneNumber]
274
+ # @return [Symbol] :exact_match, :nsn_match, :short_nsn_match, :no_match, or :invalid_number
275
+ def match_type(other); end
276
+
277
+ # True when the number's digit count is consistent with the given type in its region.
278
+ # More permissive than {#type}: a 10-digit US number is possible for both
279
+ # :fixed_line_or_mobile and :toll_free since they share the same digit count.
280
+ # @param type [Symbol] e.g. :mobile, :toll_free, :fixed_line
281
+ # @return [Boolean]
282
+ def possible_for_type?(type); end
283
+
284
+ # False for numbers that only work within their own country.
285
+ # @return [Boolean]
286
+ def can_be_internationally_dialled?; end
287
+
288
+ # Removes trailing digits until the number is valid, returning the truncated
289
+ # number as a new PhoneNumber. Returns nil if the number was not too long or
290
+ # if no valid truncation exists. Does not mutate the receiver.
291
+ # @return [PhoneNumber, nil]
292
+ def truncate; end
293
+ end
294
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PicoPhone
4
+ VERSION = "0.6.2"
5
+ end
data/lib/pico_phone.rb ADDED
@@ -0,0 +1,29 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+ require "pico_phone/version"
4
+
5
+ # Native/precompiled gems ship one binary per Ruby minor actually tested in CI (bucketed by
6
+ # major.minor, e.g. "3.1", "3.4", "4.0") under lib/pico_phone/<major.minor>/. This is an EXACT
7
+ # match only, deliberately -- a binary built under one minor can produce wrong results (not just
8
+ # fail to load) under a different minor, because Rice (the C++ binding layer) is header-only and
9
+ # some Ruby C-API usage compiles down to macros that bake in that minor's internal struct layout.
10
+ # Ruby's "ABI stable within a major series" promise doesn't cover that, so there is no safe
11
+ # cross-minor fallback here. Source/dynamic gem installs (compiled fresh at `gem install` time
12
+ # against system libphonenumber) never have any lib/pico_phone/<major.minor>/ directory -- they
13
+ # fall straight through to the flat path below, unchanged from before this loader existed.
14
+ begin
15
+ abi = RUBY_VERSION.split(".").first(2).join(".")
16
+ bucket = File.join(__dir__, "pico_phone", abi)
17
+
18
+ if File.directory?(bucket)
19
+ require "pico_phone/#{abi}/pico_phone"
20
+ else
21
+ require "pico_phone/pico_phone"
22
+ end
23
+ rescue LoadError
24
+ require "pico_phone/pico_phone"
25
+ end
26
+
27
+ module PicoPhone
28
+ class Error < StandardError; end
29
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pico_phone
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.2
5
+ platform: aarch64-linux
6
+ authors:
7
+ - Gabi Jack
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rice
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '4.3'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '4.3'
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '3.0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: rake
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '13.0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '13.0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: rake-compiler
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.2'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.2'
68
+ description: pico_phone wraps Google's libphonenumber C++ library via a Rice native
69
+ extension, providing phone number parsing, validation, and formatting for any country.
70
+ It uses the same engine as Android's dialer and delivers native C++ performance
71
+ for high-throughput server-side use.
72
+ email:
73
+ - gabi@gabijack.com
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - LICENSE.txt
79
+ - THIRD_PARTY_LICENSES.txt
80
+ - ext/pico_phone/carrier_data.cc
81
+ - ext/pico_phone/carrier_mapper.cc
82
+ - ext/pico_phone/carrier_mapper.h
83
+ - ext/pico_phone/extconf.rb
84
+ - ext/pico_phone/pico_phone.cpp
85
+ - ext/pico_phone/timezone_data.cc
86
+ - ext/pico_phone/timezone_data.h
87
+ - ext/pico_phone/timezone_mapper.cc
88
+ - ext/pico_phone/timezone_mapper.h
89
+ - ext/pico_phone/vendor_headers/phonenumbers/geocoding/area_code_map.h
90
+ - ext/pico_phone/vendor_headers/phonenumbers/geocoding/carrier_data.h
91
+ - ext/pico_phone/vendor_headers/phonenumbers/geocoding/geocoding_data.h
92
+ - ext/pico_phone/vendor_headers/phonenumbers/geocoding/mapping_file_provider.h
93
+ - lib/pico_phone.rb
94
+ - lib/pico_phone/3.1/pico_phone.so
95
+ - lib/pico_phone/3.2/pico_phone.so
96
+ - lib/pico_phone/3.3/pico_phone.so
97
+ - lib/pico_phone/3.4/pico_phone.so
98
+ - lib/pico_phone/4.0/pico_phone.so
99
+ - lib/pico_phone/phone_number.rb
100
+ - lib/pico_phone/version.rb
101
+ homepage: https://github.com/gjack/pico_phone
102
+ licenses:
103
+ - MIT
104
+ metadata:
105
+ homepage_uri: https://github.com/gjack/pico_phone
106
+ source_code_uri: https://github.com/gjack/pico_phone
107
+ documentation_uri: https://rubydoc.info/gems/pico_phone
108
+ changelog_uri: https://github.com/gjack/pico_phone/releases
109
+ bug_tracker_uri: https://github.com/gjack/pico_phone/issues
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 3.0.0
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubygems_version: 4.0.16
125
+ specification_version: 4
126
+ summary: A thin Ruby wrapper around Google's libphonenumber for parsing, validating,
127
+ and formatting phone numbers
128
+ test_files: []