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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0d43e63b273581e4224cd7f98f38d16d748bd18
4
- data.tar.gz: b71cabc0305c2d9809573fc14ee31f466195e210
3
+ metadata.gz: 4cfed3caf5e214289a39e94df25d5d4782bc6dc2
4
+ data.tar.gz: ca7b10563387b3cbc01f685cfe02c1f7cae7a600
5
5
  SHA512:
6
- metadata.gz: ea0532f9b5b70311ec87a0973fe2ea31d472b92e31a0532457bcb054d5ec7ea857df36454324055bfe35e252cd968d1b2ccc251c7adfdb6cda64c84fa5748748
7
- data.tar.gz: 691f320be3a9c9a2f6abcba2905f42318057cdaa99173418dd6e2f58343cb7963624f5d097e9bb1030844a0e97949539a100ca67cd93e9eaae1a5ba8f6cbb7e4
6
+ metadata.gz: db45f5012b38d971d86401df0eda768e32b4f4978e21b6a32e676f427afc106ca1ded4c8dc48be5e6b05d2a271a50a640e17015d1eb633c14e5c6e4bc31ae14c
7
+ data.tar.gz: 19bdd1a4ab16c554d2e894bd98b34be24dd406fe1c45f4f0d7017ae1156f27e64aacec7cca2571d1618dfa3b9b8a576de0cebabaac967206d2549fabac0597f9
@@ -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
- normalize_options_t options = get_libpostal_default_options();
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 < MAX_LANGUAGE_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 = expand_address(address, options, &num_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(ADDRESS_NONE));
233
- rb_define_global_const("ADDRESS_ANY", UINT2NUM(ADDRESS_ANY));
234
- rb_define_global_const("ADDRESS_NAME", UINT2NUM(ADDRESS_NAME));
235
- rb_define_global_const("ADDRESS_HOUSE_NUMBER", UINT2NUM(ADDRESS_HOUSE_NUMBER));
236
- rb_define_global_const("ADDRESS_STREET", UINT2NUM(ADDRESS_STREET));
237
- rb_define_global_const("ADDRESS_UNIT", UINT2NUM(ADDRESS_UNIT));
238
- rb_define_global_const("ADDRESS_LOCALITY", UINT2NUM(ADDRESS_LOCALITY));
239
- rb_define_global_const("ADDRESS_ADMIN1", UINT2NUM(ADDRESS_ADMIN1));
240
- rb_define_global_const("ADDRESS_ADMIN2", UINT2NUM(ADDRESS_ADMIN2));
241
- rb_define_global_const("ADDRESS_ADMIN3", UINT2NUM(ADDRESS_ADMIN3));
242
- rb_define_global_const("ADDRESS_ADMIN4", UINT2NUM(ADDRESS_ADMIN4));
243
- rb_define_global_const("ADDRESS_ADMIN_OTHER", UINT2NUM(ADDRESS_ADMIN_OTHER));
244
- rb_define_global_const("ADDRESS_POSTAL_CODE", UINT2NUM(ADDRESS_POSTAL_CODE));
245
- rb_define_global_const("ADDRESS_NEIGHBORHOOD", UINT2NUM(ADDRESS_NEIGHBORHOOD));
246
- rb_define_global_const("ADDRESS_ALL", UINT2NUM(ADDRESS_ALL));
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
+ }
@@ -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
- address_parser_response_t *parsed;
78
- address_parser_options_t options = get_libpostal_address_parser_default_options();
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 = parse_address(address, options))) {
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
- address_parser_response_destroy(parsed);
99
+ libpostal_address_parser_response_destroy(parsed);
100
100
 
101
101
  return rb_parse_result;
102
102
  }
@@ -6,7 +6,12 @@ module Postal
6
6
  if not address
7
7
  return []
8
8
  end
9
- CExpand.expand_address address, options
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
@@ -7,7 +7,10 @@ module Postal
7
7
  return []
8
8
  end
9
9
  parse_result = CParser.parse_address address, options
10
- parse_result.map{|s, c| {:label => c, :value => s}}
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
@@ -1,3 +1,3 @@
1
1
  module Postal
2
- VERSION = "0.3.2"
2
+ VERSION = "1.0.0"
3
3
  end
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.3.2
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: 2016-12-12 00:00:00.000000000 Z
11
+ date: 2017-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler