ruby_postal 0.3.2 → 1.0.0
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.
- checksums.yaml +4 -4
- data/ext/expand/expand.c +19 -19
- data/ext/parser/parser.c +4 -4
- data/lib/ruby_postal/expand.rb +6 -1
- data/lib/ruby_postal/parser.rb +4 -1
- data/lib/ruby_postal/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cfed3caf5e214289a39e94df25d5d4782bc6dc2
|
4
|
+
data.tar.gz: ca7b10563387b3cbc01f685cfe02c1f7cae7a600
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db45f5012b38d971d86401df0eda768e32b4f4978e21b6a32e676f427afc106ca1ded4c8dc48be5e6b05d2a271a50a640e17015d1eb633c14e5c6e4bc31ae14c
|
7
|
+
data.tar.gz: 19bdd1a4ab16c554d2e894bd98b34be24dd406fe1c45f4f0d7017ae1156f27e64aacec7cca2571d1618dfa3b9b8a576de0cebabaac967206d2549fabac0597f9
|
data/ext/expand/expand.c
CHANGED
@@ -82,7 +82,7 @@ VALUE rb_expand_address(int argc, VALUE *argv, VALUE self) {
|
|
82
82
|
len_languages = (size_t)RARRAY_LEN(rb_languages);
|
83
83
|
}
|
84
84
|
|
85
|
-
|
85
|
+
libpostal_normalize_options_t options = libpostal_get_default_options();
|
86
86
|
|
87
87
|
size_t i;
|
88
88
|
char **languages = NULL;
|
@@ -95,7 +95,7 @@ VALUE rb_expand_address(int argc, VALUE *argv, VALUE self) {
|
|
95
95
|
VALUE rb_lang = rb_ary_entry(rb_languages, (int)i);
|
96
96
|
if (rb_lang != Qnil && TYPE(rb_lang) == T_STRING) {
|
97
97
|
size_t rb_lang_len = RSTRING_LEN(rb_lang);
|
98
|
-
if (rb_lang_len > 0 && rb_lang_len <
|
98
|
+
if (rb_lang_len > 0 && rb_lang_len < LIBPOSTAL_MAX_LANGUAGE_LEN) {
|
99
99
|
char *lang = RSTRING_PTR(rb_lang);
|
100
100
|
languages[num_languages++] = lang;
|
101
101
|
}
|
@@ -205,7 +205,7 @@ VALUE rb_expand_address(int argc, VALUE *argv, VALUE self) {
|
|
205
205
|
}
|
206
206
|
|
207
207
|
size_t num_expansions = 0;
|
208
|
-
char **expansions =
|
208
|
+
char **expansions = libpostal_expand_address(address, options, &num_expansions);
|
209
209
|
|
210
210
|
VALUE rb_expansions = rb_ary_new2(num_expansions);
|
211
211
|
for (size_t i = 0; i < num_expansions; i++) {
|
@@ -229,20 +229,20 @@ void Init_expand() {
|
|
229
229
|
|
230
230
|
rb_define_module_function(rb_expand, "expand_address", rb_expand_address, -1);
|
231
231
|
|
232
|
-
rb_define_global_const("ADDRESS_NONE", UINT2NUM(
|
233
|
-
rb_define_global_const("ADDRESS_ANY", UINT2NUM(
|
234
|
-
rb_define_global_const("ADDRESS_NAME", UINT2NUM(
|
235
|
-
rb_define_global_const("ADDRESS_HOUSE_NUMBER", UINT2NUM(
|
236
|
-
rb_define_global_const("ADDRESS_STREET", UINT2NUM(
|
237
|
-
rb_define_global_const("ADDRESS_UNIT", UINT2NUM(
|
238
|
-
rb_define_global_const("
|
239
|
-
rb_define_global_const("
|
240
|
-
rb_define_global_const("
|
241
|
-
rb_define_global_const("
|
242
|
-
rb_define_global_const("
|
243
|
-
rb_define_global_const("
|
244
|
-
rb_define_global_const("ADDRESS_POSTAL_CODE", UINT2NUM(
|
245
|
-
rb_define_global_const("
|
246
|
-
rb_define_global_const("ADDRESS_ALL", UINT2NUM(
|
247
|
-
}
|
232
|
+
rb_define_global_const("ADDRESS_NONE", UINT2NUM(LIBPOSTAL_ADDRESS_NONE));
|
233
|
+
rb_define_global_const("ADDRESS_ANY", UINT2NUM(LIBPOSTAL_ADDRESS_ANY));
|
234
|
+
rb_define_global_const("ADDRESS_NAME", UINT2NUM(LIBPOSTAL_ADDRESS_NAME));
|
235
|
+
rb_define_global_const("ADDRESS_HOUSE_NUMBER", UINT2NUM(LIBPOSTAL_ADDRESS_HOUSE_NUMBER));
|
236
|
+
rb_define_global_const("ADDRESS_STREET", UINT2NUM(LIBPOSTAL_ADDRESS_STREET));
|
237
|
+
rb_define_global_const("ADDRESS_UNIT", UINT2NUM(LIBPOSTAL_ADDRESS_UNIT));
|
238
|
+
rb_define_global_const("ADDRESS_LEVEL", UINT2NUM(LIBPOSTAL_ADDRESS_LEVEL));
|
239
|
+
rb_define_global_const("ADDRESS_STAIRCASE", UINT2NUM(LIBPOSTAL_ADDRESS_STAIRCASE));
|
240
|
+
rb_define_global_const("ADDRESS_ENTRANCE", UINT2NUM(LIBPOSTAL_ADDRESS_ENTRANCE));
|
241
|
+
rb_define_global_const("ADDRESS_CATEGORY", UINT2NUM(LIBPOSTAL_ADDRESS_CATEGORY));
|
242
|
+
rb_define_global_const("ADDRESS_NEAR", UINT2NUM(LIBPOSTAL_ADDRESS_NEAR));
|
243
|
+
rb_define_global_const("ADDRESS_TOPONYM", UINT2NUM(LIBPOSTAL_ADDRESS_TOPONYM));
|
244
|
+
rb_define_global_const("ADDRESS_POSTAL_CODE", UINT2NUM(LIBPOSTAL_ADDRESS_POSTAL_CODE));
|
245
|
+
rb_define_global_const("ADDRESS_PO_BOX", UINT2NUM(LIBPOSTAL_ADDRESS_PO_BOX));
|
246
|
+
rb_define_global_const("ADDRESS_ALL", UINT2NUM(LIBPOSTAL_ADDRESS_ALL));
|
248
247
|
|
248
|
+
}
|
data/ext/parser/parser.c
CHANGED
@@ -74,8 +74,8 @@ VALUE rb_parse_address(int argc, VALUE *argv, VALUE self) {
|
|
74
74
|
|
75
75
|
char *address = RSTRING_PTR(input);
|
76
76
|
|
77
|
-
|
78
|
-
|
77
|
+
libpostal_address_parser_response_t *parsed;
|
78
|
+
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
|
79
79
|
if (rb_language != Qnil) {
|
80
80
|
options.language = RSTRING_PTR(rb_language);
|
81
81
|
}
|
@@ -84,7 +84,7 @@ VALUE rb_parse_address(int argc, VALUE *argv, VALUE self) {
|
|
84
84
|
options.country = RSTRING_PTR(rb_country);
|
85
85
|
}
|
86
86
|
|
87
|
-
if ((parsed =
|
87
|
+
if ((parsed = libpostal_parse_address(address, options))) {
|
88
88
|
size_t n = parsed->num_components;
|
89
89
|
VALUE rb_parse_result = rb_ary_new2(n);
|
90
90
|
|
@@ -96,7 +96,7 @@ VALUE rb_parse_address(int argc, VALUE *argv, VALUE self) {
|
|
96
96
|
rb_ary_store(rb_parse_result, i, rb_component);
|
97
97
|
}
|
98
98
|
|
99
|
-
|
99
|
+
libpostal_address_parser_response_destroy(parsed);
|
100
100
|
|
101
101
|
return rb_parse_result;
|
102
102
|
}
|
data/lib/ruby_postal/expand.rb
CHANGED
@@ -6,7 +6,12 @@ module Postal
|
|
6
6
|
if not address
|
7
7
|
return []
|
8
8
|
end
|
9
|
-
|
9
|
+
if address.respond_to?(:encode)
|
10
|
+
address = address.encode("UTF-8")
|
11
|
+
end
|
12
|
+
expand_result = CExpand.expand_address address, options
|
13
|
+
expand_result.map{|s| s.force_encoding("UTF-8")}
|
14
|
+
|
10
15
|
end
|
11
16
|
end
|
12
17
|
end
|
data/lib/ruby_postal/parser.rb
CHANGED
@@ -7,7 +7,10 @@ module Postal
|
|
7
7
|
return []
|
8
8
|
end
|
9
9
|
parse_result = CParser.parse_address address, options
|
10
|
-
|
10
|
+
if address.respond_to?(:encode)
|
11
|
+
address = address.encode("UTF-8")
|
12
|
+
end
|
13
|
+
parse_result.map{|s, c| {:label => c, :value => s.force_encoding("UTF-8")}}
|
11
14
|
end
|
12
15
|
end
|
13
16
|
end
|
data/lib/ruby_postal/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_postal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Al Barrentine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|