mokevnin / ipgeobase Goto Github PK
View Code? Open in Web Editor NEWГеография российских и украинских IP-адресов. Поиск местонахождения (города) IP-адреса
География российских и украинских IP-адресов. Поиск местонахождения (города) IP-адреса
Hi,
when using Ipgeobase.lookup(some_ip) get error:
Fatal error: Space required after the Public Identifier at :1.
Fatal error: SystemLiteral " or ' expected at :1.
Fatal error: SYSTEM or PUBLIC, the URI is missing at :1.
LibXML::XML::Error: Fatal error: SYSTEM or PUBLIC, the URI is missing at :1.
Good night!
When using ip_meta.city get the error: ActionView::Template::Error (incompatible character encodings: UTF-8 and Windows-1251).
In rails console:
irb(main):002:0> ip_meta = Ipgeobase.lookup('213.243.126.139')
=> #<Ipgeobase::IpMetaData:0x00000004f9bd30 @city="Москва", @Country="RU", @region="Москва", @district="Центральный федеральный округ", @lat=55.755787, @lng=37.617634>
irb(main):003:0> ip_meta.city
=> "\xCC\xEE\xF1\xEA\xE2\xE0"
irb(main):004:0> ip_meta.country
=> "RU"
irb(main):005:0> ip_meta.region
=> "\xCC\xEE\xF1\xEA\xE2\xE0"
irb(main):006:0> ip_meta.district
=> "Центральный федеральный округ"
This is fixed in ip_meta_data.rb so:
def city
Iconv.iconv('utf-8', 'utf-8', @city).first
end
def region
Iconv.iconv('utf-8', 'utf-8', @region).first
end
Maybe now changed the encoding in the database?
Thanks for the gem!
Alexander Ponikarovsky
With MRI 1.9.3:
/Users/Kir/.rvm/gems/ruby-1.9.3-p0@mysite/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:251:in `block in require': iconv will be deprecated in the future, use String#encode instead.
В RSpec'ах запускаю вот такую канитель:
require 'spec_helper'
describe City do
before(:each) do
load "#{Rails.root}/db/seeds/00_cities.rb"
WebMock.allow_net_connect!
end
after(:each) { WebMock.disable_net_connect! }
it 'should choose city if right IP' do
RIGHT_IPS.each do |city|
city[:ips].each do |ip|
City.choose(Ipgeobase.lookup(ip).city).name.should == city[:name]
end
end
end
RIGHT_IPS = [
{ name: 'Санкт-Петербург', ips: %w(87.249.56.7 217.170.80.4) },
{ name: 'Москва', ips: %w(46.174.48.38 195.34.27.6 195.46.169.93 212.248.6.1) }
]
end
Выдаёт uninitialized constant Ipgeobase::IpMetaData::Iconv
.
Пробовал с версиями 0.1.0 и 0.1.1. ruby 2.1, rails 4.0
Good day! Спасибо за гем! 😄
Would you accept a PR with a (simple) cache/memoizing and tests?
/cc @mokevnin
Являюсь разработчиком на Rails из Томска, встала задача разработки межрегионального сайта, решил автоматизировать выбор города по ip, и был очень удивлен, найдя готовый gem !) Большое спасибо!))))
Looks like the metadata returned from the server is quite limited right now. Maybe other parameters needed?
Зарелизьте, пожалуста, новую версию с
Судя по всему, 2.1.0 не дружит с этим gem'ом, и приходится писать такую колбасу в Gemfile
gem 'ipgeobase', git: '[email protected]:mokevnin/ipgeobase.git', ref: '3126c85'
What about adding some simple unit tests?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.