mmdb 0.1.3 → 0.1.4

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/ext/mmdb/mmdb.c +21 -19
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28afec18a26cb57a2d9274d5aca15b99e71036ab
4
- data.tar.gz: 8a1111e0382d6a033288143fcce6a66d6db6a208
3
+ metadata.gz: ddbd3f739b7ffac9b3e61811c4aa3edf5e8a55f7
4
+ data.tar.gz: bd71b111bd50ac7c88fad053377120c027f4a2c8
5
5
  SHA512:
6
- metadata.gz: a101f8fc21977db024fd74503f05030a91076a38375212c0315c7f2f0ddbee712d0be7684be84e900f71a7e3805ae2e313d4972116fc59798fce414a8c1108ea
7
- data.tar.gz: eeecbe7c806621a46815525190897ed2c8c4777b286d6feb0560f89d93b01c1d661bb08408d5786a1d8721f9c072401d8f169fb9b9bb9312b9abe6f43dc84964
6
+ metadata.gz: e6fe7e623f94fec0f4e45e0a7078cf7e3329b57826d46fddae0c1d939412f6a023e96affa116e93bb585b3e302032ca331ab3bff73161637630bb706cd230558
7
+ data.tar.gz: 1fac584cfb105ae76f5379414d87b7fd1cc3fd29f016e5132261b46e4cba9d58a3c265a66d83d1f384c6e35161fca175d3512edf42379d34c2c341da5f611aa7
data/ext/mmdb/mmdb.c CHANGED
@@ -17,20 +17,20 @@ static VALUE rb_sym_longitude;
17
17
  static VALUE rb_sym_postcode;
18
18
  static VALUE rb_sym_subdivisions;
19
19
 
20
- const static char *en = "en";
21
- const static char *names = "names";
22
- const static char *city = "city";
23
- const static char *country = "country";
24
- const static char *country_code = "country_code";
25
- const static char *continent = "continent";
26
- const static char *location = "location";
27
- const static char *latitude = "latitude";
28
- const static char *longitude = "longitude";
29
- const static char *postal = "postal";
30
- const static char *code = "code";
31
- const static char *iso_code = "iso_code";
32
- const static char *postcode = "postcode";
33
- const static char *subdivisions = "subdivisions";
20
+ static const char *en = "en";
21
+ static const char *names = "names";
22
+ static const char *city = "city";
23
+ static const char *country = "country";
24
+ static const char *country_code = "country_code";
25
+ static const char *continent = "continent";
26
+ static const char *location = "location";
27
+ static const char *latitude = "latitude";
28
+ static const char *longitude = "longitude";
29
+ static const char *postal = "postal";
30
+ static const char *code = "code";
31
+ static const char *iso_code = "iso_code";
32
+ static const char *postcode = "postcode";
33
+ static const char *subdivisions = "subdivisions";
34
34
 
35
35
  struct MaxMindDB {
36
36
  MMDB_s *mmdb;
@@ -145,13 +145,15 @@ maxminddb_lookup(VALUE self, VALUE ip) {
145
145
  VALUE ret;
146
146
  int gai_error, mmdb_error;
147
147
  struct MaxMindDB *ptr = MaxMindDB(self);
148
- MMDB_s *mmdb = ptr->mmdb;
148
+ MMDB_lookup_result_s lookuped;
149
+ MMDB_entry_data_s data;
150
+ MMDB_entry_s *entry;
149
151
 
150
152
  if (NIL_P(ip)) {
151
153
  return Qnil;
152
154
  }
153
155
 
154
- MMDB_lookup_result_s lookuped = MMDB_lookup_string(mmdb, StringValuePtr(ip), &gai_error, &mmdb_error);
156
+ lookuped = MMDB_lookup_string(ptr->mmdb, StringValuePtr(ip), &gai_error, &mmdb_error);
155
157
  if (gai_error) {
156
158
  rb_sys_fail(gai_strerror(gai_error));
157
159
  }
@@ -161,8 +163,7 @@ maxminddb_lookup(VALUE self, VALUE ip) {
161
163
 
162
164
  if (lookuped.found_entry) {
163
165
  ret = rb_hash_new();
164
- MMDB_entry_data_s data;
165
- MMDB_entry_s *entry = &lookuped.entry;
166
+ entry = &lookuped.entry;
166
167
 
167
168
  MMDB_get_value(entry, &data, city, names, en, NULL);
168
169
  maxminddb_set_result(ret, rb_sym_city, &data);
@@ -190,13 +191,14 @@ maxminddb_lookup(VALUE self, VALUE ip) {
190
191
  // subdivisions fields is basically array
191
192
  if (data.type == MMDB_DATA_TYPE_ARRAY) {
192
193
  VALUE ary = rb_ary_new();
194
+ int i;
193
195
  int n, data_size;
194
196
  int count = 0;
195
197
  n = data_size = data.data_size;
196
198
  number_of_digits(n, count);
197
199
  char index[count+1];
198
200
 
199
- for (int i = 0; i < data_size; i++) {
201
+ for (i = 0; i < data_size; i++) {
200
202
  sprintf(index, "%d", i);
201
203
  MMDB_get_value(entry, &data, subdivisions, index, names, en, NULL);
202
204
  if (data.has_data) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mmdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoppi