china_ad_ip 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/china_ad_ip/version.rb +1 -1
- data/lib/china_ad_ip.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c9308d7c16f1fd0d16c4454a9a77c654dc5bdcd
|
4
|
+
data.tar.gz: 482b0e42b7abe1634dc5fc93ee6a8334fd6884ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a9da6df919e5d79c814d7355a2582ab9ad9554031e8701884da023504ba71cbd8488fc1a767e935bfe9a57eacd6adf488bef2c32d6f33b531845985bdc29ebb
|
7
|
+
data.tar.gz: 161cdfc0ff74af14cbdac61f4a7169d0fe56ea007a7913882fd328c2905f8aa9bfbfda366439addac526f6b418bd9d546dc6bbaa8f7f5e0faefbb3c92e14a301
|
data/README.md
CHANGED
@@ -26,7 +26,7 @@ Or install it yourself as:
|
|
26
26
|
|
27
27
|
## Contributing
|
28
28
|
|
29
|
-
1. Fork it ( https://github.com/
|
29
|
+
1. Fork it ( https://github.com/suzhen/china_ad_ip/fork )
|
30
30
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
31
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
32
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/china_ad_ip/version.rb
CHANGED
data/lib/china_ad_ip.rb
CHANGED
@@ -52,8 +52,8 @@ module ChinaAdIp
|
|
52
52
|
raise(::ArgumentError, "not exists: #{path}")
|
53
53
|
else
|
54
54
|
if $locations.nil?
|
55
|
-
$locations = CSV.read(path)
|
56
|
-
$locations = Hash[$locations.map {|location|
|
55
|
+
$locations = CSV.read(path,:encoding=>"utf-8")
|
56
|
+
$locations = Hash[$locations.map {|location| id = location.shift; [id,location << !!id.match(/^1156/)] }]
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -67,7 +67,7 @@ module ChinaAdIp
|
|
67
67
|
|
68
68
|
index = dichotomy(ip_addr.to_i,$ip_sections.collect{|ip_section| ip_section[0]}.to_a)
|
69
69
|
|
70
|
-
$locations[$ip_sections[index][2]]
|
70
|
+
$locations[$ip_sections[index][2]]
|
71
71
|
else
|
72
72
|
raise(::ArgumentError, "not exists csv data")
|
73
73
|
end
|