ip_to_country 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ip_to_country.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  require "ip_to_country/engine"
3
3
  require "ip_to_country/loader"
4
+ require "ip_to_country/request"
4
5
 
5
6
  module IpToCountry
6
7
  end
@@ -66,4 +66,4 @@ module IpToCountry
66
66
  end
67
67
 
68
68
  end
69
- end
69
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding : utf-8 -*-
2
+ # Code adapted from geocoder(https://github.com/alexreisner/geocoder)
3
+
4
+ module IpToCountry
5
+ module Request
6
+
7
+ def geoip
8
+ unless defined?(@geoip)
9
+ if env.has_key?('HTTP_X_REAL_IP')
10
+ @geoip = IpToCountry::Geoip.by_ip(env['HTTP_X_REAL_IP'])
11
+ elsif env.has_key?('HTTP_X_FORWARDED_FOR')
12
+ @geoip = IpToCountry::Geoip.by_ip(env['HTTP_X_FORWARDED_FOR'].split(/\s*,\s*/)[0])
13
+ else
14
+ @geoip = IpToCountry::Geoip.by_ip(ip)
15
+ end
16
+ end
17
+ @geoip
18
+ end
19
+
20
+ end
21
+ end
22
+
23
+ if defined?(Rack) && defined?(Rack::Request)
24
+ Rack::Request.send :include, IpToCountry::Request
25
+ end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module IpToCountry
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
@@ -3125,3 +3125,649 @@ Unable to load geoip, underlying cause No such file to load -- geoip
3125
3125
  DROP TABLE geoips_tempo;
3126
3126
  
3127
3127
   (1.0ms) ROLLBACK
3128
+ Connecting to database specified by database.yml
3129
+  (0.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
3130
+ Migrating to CreateGeoips (1)
3131
+ Unable to load geoip, underlying cause No such file to load -- geoip
3132
+
3133
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:317:in `rescue in depend_on'
3134
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:312:in `depend_on'
3135
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:225:in `require_dependency'
3136
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:767:in `try_to_load_dependency'
3137
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:782:in `block in require_fixture_classes'
3138
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `each'
3139
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `require_fixture_classes'
3140
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:762:in `fixtures'
3141
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:27:in `<class:TestCase>'
3142
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:24:in `<top (required)>'
3143
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `require'
3144
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `<top (required)>'
3145
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `require'
3146
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
3147
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `each'
3148
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `block in <main>'
3149
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `select'
3150
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `<main>'
3151
+  (0.4ms) ALTER TABLE "schema_migrations" DISABLE TRIGGER ALL;ALTER TABLE "geoips" DISABLE TRIGGER ALL
3152
+  (2.0ms) BEGIN
3153
+ Fixture Delete (0.6ms) DELETE FROM "geoips"
3154
+ Fixture Insert (0.5ms) INSERT INTO "geoips" ("ip_from_string", "ip_to_string", "ip_from", "ip_to", "country_code", "country_name") VALUES ('192.168.1.1', '192.168.1.20', 3232235777, 3232235794, 'wd', 'wonderland')
3155
+  (13.3ms) COMMIT
3156
+  (0.2ms) ALTER TABLE "schema_migrations" ENABLE TRIGGER ALL;ALTER TABLE "geoips" ENABLE TRIGGER ALL
3157
+  (0.2ms) BEGIN
3158
+ IpToCountry::Geoip Load (1.2ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 3232235778) and ip_to = (select min(ip_to)
3159
+ from geoips where ip_to >= 3232235778)) LIMIT 1
3160
+  (0.2ms) ROLLBACK
3161
+  (0.1ms) BEGIN
3162
+  (0.1ms) ROLLBACK
3163
+  (0.1ms) BEGIN
3164
+  (0.1ms) ROLLBACK
3165
+  (0.1ms) BEGIN
3166
+  (0.5ms) ROLLBACK
3167
+  (0.1ms) BEGIN
3168
+  (46.2ms) DROP TABLE IF EXISTS geoips_tempo;
3169
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3170
+
3171
+  (0.7ms) ROLLBACK
3172
+  (0.1ms) BEGIN
3173
+  (0.3ms) ROLLBACK
3174
+  (0.1ms) BEGIN
3175
+  (93.1ms)  DROP TABLE IF EXISTS geoips_tempo;
3176
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3177
+ 
3178
+  (2.6ms) ALTER TABLE geoips RENAME TO tmp;
3179
+ ALTER TABLE geoips_tempo RENAME TO geoips;
3180
+ ALTER TABLE tmp RENAME TO geoips_tempo;
3181
+ DROP TABLE geoips_tempo;
3182
+
3183
+ IpToCountry::Geoip Load (1.0ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 35037184) and ip_to = (select min(ip_to)
3184
+ from geoips where ip_to >= 35037184)) LIMIT 1
3185
+  (0.9ms) ROLLBACK
3186
+  (0.1ms) BEGIN
3187
+  (0.2ms) ROLLBACK
3188
+  (0.1ms) BEGIN
3189
+  (20.5ms) DROP TABLE IF EXISTS geoips_tempo;
3190
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3191
+
3192
+  (1.4ms)  ALTER TABLE geoips RENAME TO tmp;
3193
+ ALTER TABLE geoips_tempo RENAME TO geoips;
3194
+ ALTER TABLE tmp RENAME TO geoips_tempo;
3195
+ DROP TABLE geoips_tempo;
3196
+ 
3197
+  (1.3ms) ROLLBACK
3198
+ Connecting to database specified by database.yml
3199
+  (0.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
3200
+ Migrating to CreateGeoips (1)
3201
+ Unable to load geoip, underlying cause No such file to load -- geoip
3202
+
3203
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:317:in `rescue in depend_on'
3204
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:312:in `depend_on'
3205
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:225:in `require_dependency'
3206
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:767:in `try_to_load_dependency'
3207
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:782:in `block in require_fixture_classes'
3208
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `each'
3209
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `require_fixture_classes'
3210
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:762:in `fixtures'
3211
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:27:in `<class:TestCase>'
3212
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:24:in `<top (required)>'
3213
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `require'
3214
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `<top (required)>'
3215
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `require'
3216
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
3217
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `each'
3218
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `block in <main>'
3219
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `select'
3220
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `<main>'
3221
+  (0.3ms) ALTER TABLE "schema_migrations" DISABLE TRIGGER ALL;ALTER TABLE "geoips" DISABLE TRIGGER ALL
3222
+  (0.1ms) BEGIN
3223
+ Fixture Delete (0.5ms) DELETE FROM "geoips"
3224
+ Fixture Insert (0.6ms) INSERT INTO "geoips" ("ip_from_string", "ip_to_string", "ip_from", "ip_to", "country_code", "country_name") VALUES ('192.168.1.1', '192.168.1.20', 3232235777, 3232235794, 'wd', 'wonderland')
3225
+  (12.0ms) COMMIT
3226
+  (0.3ms) ALTER TABLE "schema_migrations" ENABLE TRIGGER ALL;ALTER TABLE "geoips" ENABLE TRIGGER ALL
3227
+  (0.2ms) BEGIN
3228
+ IpToCountry::Geoip Load (1.3ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 3232235778) and ip_to = (select min(ip_to)
3229
+ from geoips where ip_to >= 3232235778)) LIMIT 1
3230
+  (0.2ms) ROLLBACK
3231
+  (0.1ms) BEGIN
3232
+  (0.1ms) ROLLBACK
3233
+  (0.1ms) BEGIN
3234
+  (0.1ms) ROLLBACK
3235
+  (0.1ms) BEGIN
3236
+  (0.1ms) ROLLBACK
3237
+  (0.1ms) BEGIN
3238
+  (58.6ms) DROP TABLE IF EXISTS geoips_tempo;
3239
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3240
+
3241
+  (0.7ms) ROLLBACK
3242
+  (0.1ms) BEGIN
3243
+  (0.1ms) ROLLBACK
3244
+  (0.0ms) BEGIN
3245
+  (39.4ms)  DROP TABLE IF EXISTS geoips_tempo;
3246
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3247
+ 
3248
+  (1.6ms) ALTER TABLE geoips RENAME TO tmp;
3249
+ ALTER TABLE geoips_tempo RENAME TO geoips;
3250
+ ALTER TABLE tmp RENAME TO geoips_tempo;
3251
+ DROP TABLE geoips_tempo;
3252
+
3253
+ IpToCountry::Geoip Load (0.8ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 35037184) and ip_to = (select min(ip_to)
3254
+ from geoips where ip_to >= 35037184)) LIMIT 1
3255
+  (0.6ms) ROLLBACK
3256
+  (0.1ms) BEGIN
3257
+  (0.1ms) ROLLBACK
3258
+  (0.1ms) BEGIN
3259
+  (27.7ms) DROP TABLE IF EXISTS geoips_tempo;
3260
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3261
+
3262
+  (1.9ms)  ALTER TABLE geoips RENAME TO tmp;
3263
+ ALTER TABLE geoips_tempo RENAME TO geoips;
3264
+ ALTER TABLE tmp RENAME TO geoips_tempo;
3265
+ DROP TABLE geoips_tempo;
3266
+ 
3267
+  (1.2ms) ROLLBACK
3268
+ Connecting to database specified by database.yml
3269
+  (0.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
3270
+ Migrating to CreateGeoips (1)
3271
+ Unable to load geoip, underlying cause No such file to load -- geoip
3272
+
3273
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:317:in `rescue in depend_on'
3274
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:312:in `depend_on'
3275
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:225:in `require_dependency'
3276
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:767:in `try_to_load_dependency'
3277
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:782:in `block in require_fixture_classes'
3278
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `each'
3279
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `require_fixture_classes'
3280
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:762:in `fixtures'
3281
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:27:in `<class:TestCase>'
3282
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:24:in `<top (required)>'
3283
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `require'
3284
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `<top (required)>'
3285
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `require'
3286
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
3287
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `each'
3288
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `block in <main>'
3289
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `select'
3290
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `<main>'
3291
+ Connecting to database specified by database.yml
3292
+  (0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
3293
+ Migrating to CreateGeoips (1)
3294
+ Unable to load geoip, underlying cause No such file to load -- geoip
3295
+
3296
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:317:in `rescue in depend_on'
3297
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:312:in `depend_on'
3298
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:225:in `require_dependency'
3299
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:767:in `try_to_load_dependency'
3300
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:782:in `block in require_fixture_classes'
3301
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `each'
3302
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `require_fixture_classes'
3303
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:762:in `fixtures'
3304
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:27:in `<class:TestCase>'
3305
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:24:in `<top (required)>'
3306
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `require'
3307
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `<top (required)>'
3308
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `require'
3309
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
3310
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `each'
3311
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `block in <main>'
3312
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `select'
3313
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `<main>'
3314
+ Connecting to database specified by database.yml
3315
+  (0.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
3316
+ Migrating to CreateGeoips (1)
3317
+ Unable to load geoip, underlying cause No such file to load -- geoip
3318
+
3319
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:317:in `rescue in depend_on'
3320
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:312:in `depend_on'
3321
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:225:in `require_dependency'
3322
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:767:in `try_to_load_dependency'
3323
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:782:in `block in require_fixture_classes'
3324
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `each'
3325
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `require_fixture_classes'
3326
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:762:in `fixtures'
3327
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:27:in `<class:TestCase>'
3328
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:24:in `<top (required)>'
3329
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `require'
3330
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `<top (required)>'
3331
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `require'
3332
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
3333
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `each'
3334
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `block in <main>'
3335
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `select'
3336
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `<main>'
3337
+  (0.3ms) ALTER TABLE "schema_migrations" DISABLE TRIGGER ALL;ALTER TABLE "geoips" DISABLE TRIGGER ALL
3338
+  (0.2ms) BEGIN
3339
+ Fixture Delete (0.6ms) DELETE FROM "geoips"
3340
+ Fixture Insert (0.7ms) INSERT INTO "geoips" ("ip_from_string", "ip_to_string", "ip_from", "ip_to", "country_code", "country_name") VALUES ('192.168.1.1', '192.168.1.20', 3232235777, 3232235794, 'wd', 'wonderland')
3341
+  (55.6ms) COMMIT
3342
+  (0.1ms) ALTER TABLE "schema_migrations" ENABLE TRIGGER ALL;ALTER TABLE "geoips" ENABLE TRIGGER ALL
3343
+  (0.1ms) BEGIN
3344
+ IpToCountry::Geoip Load (1.2ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 3232235778) and ip_to = (select min(ip_to)
3345
+ from geoips where ip_to >= 3232235778)) LIMIT 1
3346
+  (0.2ms) ROLLBACK
3347
+  (0.1ms) BEGIN
3348
+  (0.1ms) ROLLBACK
3349
+  (0.1ms) BEGIN
3350
+  (0.1ms) ROLLBACK
3351
+  (0.1ms) BEGIN
3352
+  (0.1ms) ROLLBACK
3353
+  (0.1ms) BEGIN
3354
+  (49.0ms) DROP TABLE IF EXISTS geoips_tempo;
3355
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3356
+
3357
+  (0.7ms) ROLLBACK
3358
+  (0.1ms) BEGIN
3359
+  (0.2ms) ROLLBACK
3360
+  (0.1ms) BEGIN
3361
+  (62.8ms)  DROP TABLE IF EXISTS geoips_tempo;
3362
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3363
+ 
3364
+  (1.8ms) ALTER TABLE geoips RENAME TO tmp;
3365
+ ALTER TABLE geoips_tempo RENAME TO geoips;
3366
+ ALTER TABLE tmp RENAME TO geoips_tempo;
3367
+ DROP TABLE geoips_tempo;
3368
+
3369
+ IpToCountry::Geoip Load (0.8ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 35037184) and ip_to = (select min(ip_to)
3370
+ from geoips where ip_to >= 35037184)) LIMIT 1
3371
+  (0.6ms) ROLLBACK
3372
+  (0.1ms) BEGIN
3373
+  (0.1ms) ROLLBACK
3374
+  (0.1ms) BEGIN
3375
+  (25.2ms) DROP TABLE IF EXISTS geoips_tempo;
3376
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3377
+
3378
+  (1.7ms)  ALTER TABLE geoips RENAME TO tmp;
3379
+ ALTER TABLE geoips_tempo RENAME TO geoips;
3380
+ ALTER TABLE tmp RENAME TO geoips_tempo;
3381
+ DROP TABLE geoips_tempo;
3382
+ 
3383
+  (1.5ms) ROLLBACK
3384
+ Connecting to database specified by database.yml
3385
+  (0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
3386
+ Migrating to CreateGeoips (1)
3387
+ Unable to load geoip, underlying cause No such file to load -- geoip
3388
+
3389
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:317:in `rescue in depend_on'
3390
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:312:in `depend_on'
3391
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:225:in `require_dependency'
3392
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:767:in `try_to_load_dependency'
3393
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:782:in `block in require_fixture_classes'
3394
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `each'
3395
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `require_fixture_classes'
3396
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:762:in `fixtures'
3397
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:27:in `<class:TestCase>'
3398
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:24:in `<top (required)>'
3399
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `require'
3400
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `<top (required)>'
3401
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `require'
3402
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
3403
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `each'
3404
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `block in <main>'
3405
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `select'
3406
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `<main>'
3407
+  (0.3ms) ALTER TABLE "schema_migrations" DISABLE TRIGGER ALL;ALTER TABLE "geoips" DISABLE TRIGGER ALL
3408
+  (0.1ms) BEGIN
3409
+ Fixture Delete (0.5ms) DELETE FROM "geoips"
3410
+ Fixture Insert (2.4ms) INSERT INTO "geoips" ("ip_from_string", "ip_to_string", "ip_from", "ip_to", "country_code", "country_name") VALUES ('192.168.1.1', '192.168.1.20', 3232235777, 3232235794, 'wd', 'wonderland')
3411
+  (25.0ms) COMMIT
3412
+  (0.1ms) ALTER TABLE "schema_migrations" ENABLE TRIGGER ALL;ALTER TABLE "geoips" ENABLE TRIGGER ALL
3413
+  (0.1ms) BEGIN
3414
+ IpToCountry::Geoip Load (1.2ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 3232235778) and ip_to = (select min(ip_to)
3415
+ from geoips where ip_to >= 3232235778)) LIMIT 1
3416
+  (0.2ms) ROLLBACK
3417
+  (0.1ms) BEGIN
3418
+  (0.1ms) ROLLBACK
3419
+  (0.1ms) BEGIN
3420
+  (0.1ms) ROLLBACK
3421
+  (0.1ms) BEGIN
3422
+  (0.1ms) ROLLBACK
3423
+  (0.1ms) BEGIN
3424
+  (40.3ms) DROP TABLE IF EXISTS geoips_tempo;
3425
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3426
+
3427
+  (0.7ms) ROLLBACK
3428
+  (0.1ms) BEGIN
3429
+  (0.2ms) ROLLBACK
3430
+  (0.1ms) BEGIN
3431
+  (38.2ms)  DROP TABLE IF EXISTS geoips_tempo;
3432
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3433
+ 
3434
+  (1.7ms) ALTER TABLE geoips RENAME TO tmp;
3435
+ ALTER TABLE geoips_tempo RENAME TO geoips;
3436
+ ALTER TABLE tmp RENAME TO geoips_tempo;
3437
+ DROP TABLE geoips_tempo;
3438
+
3439
+ IpToCountry::Geoip Load (0.9ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 35037184) and ip_to = (select min(ip_to)
3440
+ from geoips where ip_to >= 35037184)) LIMIT 1
3441
+  (0.8ms) ROLLBACK
3442
+  (0.1ms) BEGIN
3443
+  (0.2ms) ROLLBACK
3444
+  (0.1ms) BEGIN
3445
+  (33.8ms) DROP TABLE IF EXISTS geoips_tempo;
3446
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3447
+
3448
+  (1.4ms)  ALTER TABLE geoips RENAME TO tmp;
3449
+ ALTER TABLE geoips_tempo RENAME TO geoips;
3450
+ ALTER TABLE tmp RENAME TO geoips_tempo;
3451
+ DROP TABLE geoips_tempo;
3452
+ 
3453
+  (0.7ms) ROLLBACK
3454
+ IpToCountry::Geoip Load (12.3ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 1254684475) and ip_to = (select min(ip_to)
3455
+ from geoips where ip_to >= 1254684475)) LIMIT 1
3456
+ IpToCountry::Geoip Load (0.8ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 1254684475) and ip_to = (select min(ip_to)
3457
+ from geoips where ip_to >= 1254684475)) LIMIT 1
3458
+ IpToCountry::Geoip Load (0.7ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 1254684475) and ip_to = (select min(ip_to)
3459
+ from geoips where ip_to >= 1254684475)) LIMIT 1
3460
+ IpToCountry::Geoip Load (2.8ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 1254684475) and ip_to = (select min(ip_to)
3461
+ from geoips where ip_to >= 1254684475)) LIMIT 1
3462
+ Connecting to database specified by database.yml
3463
+  (2.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
3464
+ Migrating to CreateGeoips (1)
3465
+ Unable to load geoip, underlying cause No such file to load -- geoip
3466
+
3467
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:317:in `rescue in depend_on'
3468
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:312:in `depend_on'
3469
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:225:in `require_dependency'
3470
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:767:in `try_to_load_dependency'
3471
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:782:in `block in require_fixture_classes'
3472
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `each'
3473
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `require_fixture_classes'
3474
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:762:in `fixtures'
3475
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:27:in `<class:TestCase>'
3476
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:24:in `<top (required)>'
3477
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `require'
3478
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `<top (required)>'
3479
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `require'
3480
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
3481
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `each'
3482
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `block in <main>'
3483
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `select'
3484
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `<main>'
3485
+  (0.3ms) ALTER TABLE "schema_migrations" DISABLE TRIGGER ALL;ALTER TABLE "geoips" DISABLE TRIGGER ALL
3486
+  (0.2ms) BEGIN
3487
+ Fixture Delete (0.7ms) DELETE FROM "geoips"
3488
+ Fixture Insert (0.6ms) INSERT INTO "geoips" ("ip_from_string", "ip_to_string", "ip_from", "ip_to", "country_code", "country_name") VALUES ('192.168.1.1', '192.168.1.20', 3232235777, 3232235794, 'wd', 'wonderland')
3489
+  (29.0ms) COMMIT
3490
+  (1.3ms) ALTER TABLE "schema_migrations" ENABLE TRIGGER ALL;ALTER TABLE "geoips" ENABLE TRIGGER ALL
3491
+  (0.2ms) BEGIN
3492
+ IpToCountry::Geoip Load (1.2ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 3232235778) and ip_to = (select min(ip_to)
3493
+ from geoips where ip_to >= 3232235778)) LIMIT 1
3494
+  (0.2ms) ROLLBACK
3495
+  (0.1ms) BEGIN
3496
+  (0.1ms) ROLLBACK
3497
+  (0.1ms) BEGIN
3498
+  (0.1ms) ROLLBACK
3499
+  (0.1ms) BEGIN
3500
+  (0.1ms) ROLLBACK
3501
+  (0.1ms) BEGIN
3502
+  (100.5ms) DROP TABLE IF EXISTS geoips_tempo;
3503
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3504
+
3505
+  (0.6ms) ROLLBACK
3506
+  (0.0ms) BEGIN
3507
+  (0.3ms) ROLLBACK
3508
+  (0.1ms) BEGIN
3509
+  (52.2ms)  DROP TABLE IF EXISTS geoips_tempo;
3510
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3511
+ 
3512
+  (1.8ms) ALTER TABLE geoips RENAME TO tmp;
3513
+ ALTER TABLE geoips_tempo RENAME TO geoips;
3514
+ ALTER TABLE tmp RENAME TO geoips_tempo;
3515
+ DROP TABLE geoips_tempo;
3516
+
3517
+ IpToCountry::Geoip Load (0.8ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 35037184) and ip_to = (select min(ip_to)
3518
+ from geoips where ip_to >= 35037184)) LIMIT 1
3519
+  (0.9ms) ROLLBACK
3520
+  (0.1ms) BEGIN
3521
+  (0.1ms) ROLLBACK
3522
+  (0.1ms) BEGIN
3523
+  (23.2ms) DROP TABLE IF EXISTS geoips_tempo;
3524
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3525
+
3526
+  (2.6ms)  ALTER TABLE geoips RENAME TO tmp;
3527
+ ALTER TABLE geoips_tempo RENAME TO geoips;
3528
+ ALTER TABLE tmp RENAME TO geoips_tempo;
3529
+ DROP TABLE geoips_tempo;
3530
+ 
3531
+  (1.2ms) ROLLBACK
3532
+ IpToCountry::Geoip Load (18.3ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 1254684475) and ip_to = (select min(ip_to)
3533
+ from geoips where ip_to >= 1254684475)) LIMIT 1
3534
+ IpToCountry::Geoip Load (0.9ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 1254684475) and ip_to = (select min(ip_to)
3535
+ from geoips where ip_to >= 1254684475)) LIMIT 1
3536
+ IpToCountry::Geoip Load (0.8ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 1254684475) and ip_to = (select min(ip_to)
3537
+ from geoips where ip_to >= 1254684475)) LIMIT 1
3538
+ IpToCountry::Geoip Load (0.8ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 1254684475) and ip_to = (select min(ip_to)
3539
+ from geoips where ip_to >= 1254684475)) LIMIT 1
3540
+ Connecting to database specified by database.yml
3541
+  (0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
3542
+ Migrating to CreateGeoips (1)
3543
+ Unable to load geoip, underlying cause No such file to load -- geoip
3544
+
3545
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:317:in `rescue in depend_on'
3546
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:312:in `depend_on'
3547
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:225:in `require_dependency'
3548
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:767:in `try_to_load_dependency'
3549
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:782:in `block in require_fixture_classes'
3550
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `each'
3551
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `require_fixture_classes'
3552
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:762:in `fixtures'
3553
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:27:in `<class:TestCase>'
3554
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:24:in `<top (required)>'
3555
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `require'
3556
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `<top (required)>'
3557
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `require'
3558
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
3559
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `each'
3560
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `block in <main>'
3561
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `select'
3562
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `<main>'
3563
+  (0.3ms) ALTER TABLE "schema_migrations" DISABLE TRIGGER ALL;ALTER TABLE "geoips" DISABLE TRIGGER ALL
3564
+  (0.2ms) BEGIN
3565
+ Fixture Delete (0.6ms) DELETE FROM "geoips"
3566
+ Fixture Insert (1.0ms) INSERT INTO "geoips" ("ip_from_string", "ip_to_string", "ip_from", "ip_to", "country_code", "country_name") VALUES ('192.168.1.1', '192.168.1.20', 3232235777, 3232235794, 'wd', 'wonderland')
3567
+  (17.1ms) COMMIT
3568
+  (0.3ms) ALTER TABLE "schema_migrations" ENABLE TRIGGER ALL;ALTER TABLE "geoips" ENABLE TRIGGER ALL
3569
+  (0.2ms) BEGIN
3570
+ IpToCountry::Geoip Load (1.2ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 3232235778) and ip_to = (select min(ip_to)
3571
+ from geoips where ip_to >= 3232235778)) LIMIT 1
3572
+  (0.2ms) ROLLBACK
3573
+  (0.1ms) BEGIN
3574
+  (0.1ms) ROLLBACK
3575
+  (0.1ms) BEGIN
3576
+  (0.1ms) ROLLBACK
3577
+  (0.1ms) BEGIN
3578
+  (0.1ms) ROLLBACK
3579
+  (0.1ms) BEGIN
3580
+  (40.6ms) DROP TABLE IF EXISTS geoips_tempo;
3581
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3582
+
3583
+  (0.7ms) ROLLBACK
3584
+  (0.1ms) BEGIN
3585
+  (0.2ms) ROLLBACK
3586
+  (0.1ms) BEGIN
3587
+  (38.7ms)  DROP TABLE IF EXISTS geoips_tempo;
3588
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3589
+ 
3590
+  (1.8ms) ALTER TABLE geoips RENAME TO tmp;
3591
+ ALTER TABLE geoips_tempo RENAME TO geoips;
3592
+ ALTER TABLE tmp RENAME TO geoips_tempo;
3593
+ DROP TABLE geoips_tempo;
3594
+
3595
+ IpToCountry::Geoip Load (0.9ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 35037184) and ip_to = (select min(ip_to)
3596
+ from geoips where ip_to >= 35037184)) LIMIT 1
3597
+  (0.7ms) ROLLBACK
3598
+  (0.1ms) BEGIN
3599
+  (0.4ms) ROLLBACK
3600
+  (0.1ms) BEGIN
3601
+  (18.1ms) DROP TABLE IF EXISTS geoips_tempo;
3602
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3603
+
3604
+  (1.5ms)  ALTER TABLE geoips RENAME TO tmp;
3605
+ ALTER TABLE geoips_tempo RENAME TO geoips;
3606
+ ALTER TABLE tmp RENAME TO geoips_tempo;
3607
+ DROP TABLE geoips_tempo;
3608
+ 
3609
+  (0.7ms) ROLLBACK
3610
+ IpToCountry::Geoip Load (1.3ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 1254684475) and ip_to = (select min(ip_to)
3611
+ from geoips where ip_to >= 1254684475)) LIMIT 1
3612
+ IpToCountry::Geoip Load (1.1ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 1254684475) and ip_to = (select min(ip_to)
3613
+ from geoips where ip_to >= 1254684475)) LIMIT 1
3614
+ IpToCountry::Geoip Load (2.5ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 1254684475) and ip_to = (select min(ip_to)
3615
+ from geoips where ip_to >= 1254684475)) LIMIT 1
3616
+ IpToCountry::Geoip Load (1.3ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 1254684475) and ip_to = (select min(ip_to)
3617
+ from geoips where ip_to >= 1254684475)) LIMIT 1
3618
+ Connecting to database specified by database.yml
3619
+  (0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
3620
+ Migrating to CreateGeoips (1)
3621
+ Unable to load geoip, underlying cause No such file to load -- geoip
3622
+
3623
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:317:in `rescue in depend_on'
3624
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:312:in `depend_on'
3625
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:225:in `require_dependency'
3626
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:767:in `try_to_load_dependency'
3627
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:782:in `block in require_fixture_classes'
3628
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `each'
3629
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `require_fixture_classes'
3630
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:762:in `fixtures'
3631
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:27:in `<class:TestCase>'
3632
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:24:in `<top (required)>'
3633
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `require'
3634
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `<top (required)>'
3635
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `require'
3636
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
3637
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `each'
3638
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `block in <main>'
3639
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `select'
3640
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `<main>'
3641
+  (0.4ms) ALTER TABLE "schema_migrations" DISABLE TRIGGER ALL;ALTER TABLE "geoips" DISABLE TRIGGER ALL
3642
+  (0.2ms) BEGIN
3643
+ Fixture Delete (0.4ms) DELETE FROM "geoips"
3644
+ Fixture Insert (0.7ms) INSERT INTO "geoips" ("ip_from_string", "ip_to_string", "ip_from", "ip_to", "country_code", "country_name") VALUES ('192.168.1.1', '192.168.1.20', 3232235777, 3232235794, 'wd', 'wonderland')
3645
+  (20.8ms) COMMIT
3646
+  (0.2ms) ALTER TABLE "schema_migrations" ENABLE TRIGGER ALL;ALTER TABLE "geoips" ENABLE TRIGGER ALL
3647
+  (0.2ms) BEGIN
3648
+ IpToCountry::Geoip Load (1.2ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 3232235778) and ip_to = (select min(ip_to)
3649
+ from geoips where ip_to >= 3232235778)) LIMIT 1
3650
+  (0.2ms) ROLLBACK
3651
+  (0.1ms) BEGIN
3652
+  (0.1ms) ROLLBACK
3653
+  (0.1ms) BEGIN
3654
+  (0.1ms) ROLLBACK
3655
+  (0.1ms) BEGIN
3656
+  (0.2ms) ROLLBACK
3657
+  (0.1ms) BEGIN
3658
+  (52.9ms) DROP TABLE IF EXISTS geoips_tempo;
3659
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3660
+
3661
+  (0.8ms) ROLLBACK
3662
+  (0.1ms) BEGIN
3663
+  (0.1ms) ROLLBACK
3664
+  (0.0ms) BEGIN
3665
+  (25.1ms)  DROP TABLE IF EXISTS geoips_tempo;
3666
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3667
+ 
3668
+  (1.7ms) ALTER TABLE geoips RENAME TO tmp;
3669
+ ALTER TABLE geoips_tempo RENAME TO geoips;
3670
+ ALTER TABLE tmp RENAME TO geoips_tempo;
3671
+ DROP TABLE geoips_tempo;
3672
+
3673
+ IpToCountry::Geoip Load (0.9ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 35037184) and ip_to = (select min(ip_to)
3674
+ from geoips where ip_to >= 35037184)) LIMIT 1
3675
+  (0.7ms) ROLLBACK
3676
+  (0.0ms) BEGIN
3677
+  (0.2ms) ROLLBACK
3678
+  (0.1ms) BEGIN
3679
+  (40.2ms) DROP TABLE IF EXISTS geoips_tempo;
3680
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3681
+
3682
+  (1.5ms)  ALTER TABLE geoips RENAME TO tmp;
3683
+ ALTER TABLE geoips_tempo RENAME TO geoips;
3684
+ ALTER TABLE tmp RENAME TO geoips_tempo;
3685
+ DROP TABLE geoips_tempo;
3686
+ 
3687
+  (0.7ms) ROLLBACK
3688
+ IpToCountry::Geoip Load (4.9ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 3232235778) and ip_to = (select min(ip_to)
3689
+ from geoips where ip_to >= 3232235778)) LIMIT 1
3690
+ IpToCountry::Geoip Load (0.8ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 3232235778) and ip_to = (select min(ip_to)
3691
+ from geoips where ip_to >= 3232235778)) LIMIT 1
3692
+ IpToCountry::Geoip Load (0.8ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 3232235778) and ip_to = (select min(ip_to)
3693
+ from geoips where ip_to >= 3232235778)) LIMIT 1
3694
+ IpToCountry::Geoip Load (0.8ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 1254684475) and ip_to = (select min(ip_to)
3695
+ from geoips where ip_to >= 1254684475)) LIMIT 1
3696
+ Connecting to database specified by database.yml
3697
+  (0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
3698
+ Migrating to CreateGeoips (1)
3699
+ Unable to load geoip, underlying cause No such file to load -- geoip
3700
+
3701
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:317:in `rescue in depend_on'
3702
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:312:in `depend_on'
3703
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:225:in `require_dependency'
3704
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:767:in `try_to_load_dependency'
3705
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:782:in `block in require_fixture_classes'
3706
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `each'
3707
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:779:in `require_fixture_classes'
3708
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/activerecord-3.2.13/lib/active_record/fixtures.rb:762:in `fixtures'
3709
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:27:in `<class:TestCase>'
3710
+ /home/vince/Projets/ip_to_country/test/test_helper.rb:24:in `<top (required)>'
3711
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `require'
3712
+ /home/vince/Projets/ip_to_country/test/geoip_test.rb:2:in `<top (required)>'
3713
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `require'
3714
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
3715
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `each'
3716
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:9:in `block in <main>'
3717
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `select'
3718
+ /home/vince/.rvm/gems/ruby-1.9.3-head/gems/rake-10.0.4/lib/rake/rake_test_loader.rb:4:in `<main>'
3719
+  (0.3ms) ALTER TABLE "schema_migrations" DISABLE TRIGGER ALL;ALTER TABLE "geoips" DISABLE TRIGGER ALL
3720
+  (0.2ms) BEGIN
3721
+ Fixture Delete (0.6ms) DELETE FROM "geoips"
3722
+ Fixture Insert (0.9ms) INSERT INTO "geoips" ("ip_from_string", "ip_to_string", "ip_from", "ip_to", "country_code", "country_name") VALUES ('192.168.1.1', '192.168.1.20', 3232235777, 3232235794, 'wd', 'wonderland')
3723
+  (24.4ms) COMMIT
3724
+  (0.1ms) ALTER TABLE "schema_migrations" ENABLE TRIGGER ALL;ALTER TABLE "geoips" ENABLE TRIGGER ALL
3725
+  (0.1ms) BEGIN
3726
+ IpToCountry::Geoip Load (1.2ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 3232235778) and ip_to = (select min(ip_to)
3727
+ from geoips where ip_to >= 3232235778)) LIMIT 1
3728
+  (0.2ms) ROLLBACK
3729
+  (0.1ms) BEGIN
3730
+  (0.1ms) ROLLBACK
3731
+  (0.1ms) BEGIN
3732
+  (0.1ms) ROLLBACK
3733
+  (0.1ms) BEGIN
3734
+  (0.1ms) ROLLBACK
3735
+  (0.1ms) BEGIN
3736
+  (101.1ms) DROP TABLE IF EXISTS geoips_tempo;
3737
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3738
+
3739
+  (0.6ms) ROLLBACK
3740
+  (0.1ms) BEGIN
3741
+  (0.1ms) ROLLBACK
3742
+  (0.1ms) BEGIN
3743
+  (28.7ms)  DROP TABLE IF EXISTS geoips_tempo;
3744
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3745
+ 
3746
+  (1.6ms) ALTER TABLE geoips RENAME TO tmp;
3747
+ ALTER TABLE geoips_tempo RENAME TO geoips;
3748
+ ALTER TABLE tmp RENAME TO geoips_tempo;
3749
+ DROP TABLE geoips_tempo;
3750
+
3751
+ IpToCountry::Geoip Load (0.8ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 35037184) and ip_to = (select min(ip_to)
3752
+ from geoips where ip_to >= 35037184)) LIMIT 1
3753
+  (0.7ms) ROLLBACK
3754
+  (0.1ms) BEGIN
3755
+  (0.2ms) ROLLBACK
3756
+  (0.1ms) BEGIN
3757
+  (36.3ms) DROP TABLE IF EXISTS geoips_tempo;
3758
+ CREATE TABLE geoips_tempo AS SELECT * FROM geoips WHERE ip_from = -1;
3759
+
3760
+  (1.4ms)  ALTER TABLE geoips RENAME TO tmp;
3761
+ ALTER TABLE geoips_tempo RENAME TO geoips;
3762
+ ALTER TABLE tmp RENAME TO geoips_tempo;
3763
+ DROP TABLE geoips_tempo;
3764
+ 
3765
+  (1.6ms) ROLLBACK
3766
+ IpToCountry::Geoip Load (18.0ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 3232235778) and ip_to = (select min(ip_to)
3767
+ from geoips where ip_to >= 3232235778)) LIMIT 1
3768
+ IpToCountry::Geoip Load (0.9ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 3232235778) and ip_to = (select min(ip_to)
3769
+ from geoips where ip_to >= 3232235778)) LIMIT 1
3770
+ IpToCountry::Geoip Load (0.8ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 3232235778) and ip_to = (select min(ip_to)
3771
+ from geoips where ip_to >= 3232235778)) LIMIT 1
3772
+ IpToCountry::Geoip Load (0.8ms) SELECT "geoips".* FROM "geoips" WHERE (ip_from = (select max(ip_from) from geoips where ip_from <= 3232235778) and ip_to = (select min(ip_to)
3773
+ from geoips where ip_to >= 3232235778)) LIMIT 1
data/test/loader_test.rb CHANGED
@@ -3,14 +3,14 @@ require 'test_helper'
3
3
 
4
4
  class LoaderTest < ActiveSupport::TestCase
5
5
 
6
- test "ip populate workflow" do
6
+ def test_populate!
7
7
  IpToCountry::Loader.expects(download_and_unzip_ips: true, create_tempo_table: true,
8
8
  load_csv_in_tempo_table: true, rename_tempo_into_geoip: true,
9
9
  clean_tmp_files: true)
10
10
  assert(IpToCountry::Loader.populate!)
11
11
  end
12
12
 
13
- test "it download and unzip csv with ip address" do
13
+ def test_download_and_unzip_ips
14
14
  setup_download_and_extract
15
15
 
16
16
  IpToCountry::Loader.expects(:system).with("wget -N #{IpToCountry::Loader::ARCHIVE_SOURCE}")
@@ -21,12 +21,12 @@ class LoaderTest < ActiveSupport::TestCase
21
21
  teardown_download_and_extract
22
22
  end
23
23
 
24
- test "it creates a tempo table for ips" do
24
+ def test_create_tempo_table
25
25
  assert(IpToCountry::Loader.create_tempo_table)
26
26
  assert ActiveRecord::Base.connection.table_exists?('geoips_tempo')
27
27
  end
28
28
 
29
- test "it loads csv ips into tempo table" do
29
+ def test_load_csv_in_tempo_table
30
30
  setup_load_csv
31
31
  IpToCountry::Loader.create_tempo_table
32
32
  IpToCountry::Loader.load_csv_in_tempo_table
@@ -35,19 +35,17 @@ class LoaderTest < ActiveSupport::TestCase
35
35
  teardown_load_csv
36
36
  end
37
37
 
38
- test "it renames tempo table into geoips" do
38
+ def test_rename_tempo_into_geoip
39
39
  IpToCountry::Loader.create_tempo_table
40
40
  IpToCountry::Loader.rename_tempo_into_geoip
41
41
  refute ActiveRecord::Base.connection.table_exists?('geoips_tempo')
42
42
  end
43
43
 
44
- test "it remove temp files" do
44
+ def test_clean_tmp_files
45
45
  setup_file_remove
46
-
47
46
  IpToCountry::Loader.clean_tmp_files
48
47
  refute File.exists?('/tmp/test_ips.csv')
49
48
  refute File.exists?('/tmp/test_ips.zip')
50
-
51
49
  teardown_file_remove
52
50
  end
53
51
 
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ # Code adapted from geocoder(https://github.com/alexreisner/geocoder)
3
+
4
+ require 'test_helper'
5
+
6
+ class RequestTest < Test::Unit::TestCase
7
+ class MockRequest
8
+ include IpToCountry::Request
9
+ attr_accessor :env, :ip
10
+ def initialize(env={}, ip="")
11
+ @env = env
12
+ @ip = ip
13
+ end
14
+ end
15
+
16
+ def test_http_x_real_ip
17
+ req = MockRequest.new({"HTTP_X_REAL_IP" => "192.168.1.2"})
18
+ assert req.geoip.is_a?(IpToCountry::Geoip)
19
+ end
20
+
21
+ def test_http_x_forwarded_for_without_proxy
22
+ req = MockRequest.new({"HTTP_X_FORWARDED_FOR" => "192.168.1.2"})
23
+ assert req.geoip.is_a?(IpToCountry::Geoip)
24
+ end
25
+
26
+ def test_http_x_forwarded_for_with_proxy
27
+ req = MockRequest.new({"HTTP_X_FORWARDED_FOR" => "192.168.1.2, 192.168.1.7"})
28
+ assert req.geoip.is_a?(IpToCountry::Geoip)
29
+ end
30
+
31
+ def test_with_request_ip
32
+ req = MockRequest.new({}, "192.168.1.2")
33
+ assert req.geoip.is_a?(IpToCountry::Geoip)
34
+ end
35
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ip_to_country
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &13549180 !ruby/object:Gem::Requirement
16
+ requirement: &14328020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 3.2.12
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *13549180
24
+ version_requirements: *14328020
25
25
  description: Simple tool to find the country of an ip address.
26
26
  email:
27
27
  - vincent.pochet@gmail.com
@@ -33,6 +33,7 @@ files:
33
33
  - lib/ip_to_country/engine.rb
34
34
  - lib/ip_to_country/loader.rb
35
35
  - lib/ip_to_country/version.rb
36
+ - lib/ip_to_country/request.rb
36
37
  - lib/ip_to_country.rb
37
38
  - lib/generators/geoip/geoip_generator.rb
38
39
  - lib/generators/geoip/templates/migration.rb
@@ -47,6 +48,7 @@ files:
47
48
  - test/fixtures/geoips.yml
48
49
  - test/fixtures/ips/test_ips.csv
49
50
  - test/fixtures/ips/test_ips.zip
51
+ - test/request_test.rb
50
52
  - test/dummy/log/test.log
51
53
  - test/dummy/script/rails
52
54
  - test/dummy/public/favicon.ico
@@ -109,6 +111,7 @@ test_files:
109
111
  - test/fixtures/geoips.yml
110
112
  - test/fixtures/ips/test_ips.csv
111
113
  - test/fixtures/ips/test_ips.zip
114
+ - test/request_test.rb
112
115
  - test/dummy/log/test.log
113
116
  - test/dummy/script/rails
114
117
  - test/dummy/public/favicon.ico