ipgeobase_mongoid 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f0e5cbb09ad2be8ac852e6ea1e095ba7ce740856
4
+ data.tar.gz: 73494a90e0379e760c2e853bc4698e8f9159841d
5
+ SHA512:
6
+ metadata.gz: d90141814628009a088cd1ea9d18232a187a760fadf4a8f8a5feaf9ea76ac1e4bab145e981b8ae718f815f9e01bd49d577f6d523d0426d307287727c96cfa052
7
+ data.tar.gz: e02820ebe2dc60906dd5d4beea648d2609274df1e56a7fbaa7e240e147ff2370617bd5a296d6f52febd2a0ec87d464126c71316dfffd12d771ec82deb80611fd
data/.gitignore CHANGED
@@ -1 +1 @@
1
- /.idea
1
+ /tmp/*
@@ -0,0 +1 @@
1
+ ipgeobase
@@ -0,0 +1 @@
1
+ 2.0.0-p247
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in ipgeobase.gemspec
4
4
  gemspec
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ipgeobase_mongoid (1.0.0)
5
+ mongoid (>= 3.0, < 5.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (3.2.14)
11
+ activesupport (= 3.2.14)
12
+ builder (~> 3.0.0)
13
+ activesupport (3.2.14)
14
+ i18n (~> 0.6, >= 0.6.4)
15
+ multi_json (~> 1.0)
16
+ builder (3.0.4)
17
+ diff-lcs (1.2.4)
18
+ i18n (0.6.5)
19
+ mongoid (3.1.4)
20
+ activemodel (~> 3.2)
21
+ moped (~> 1.4)
22
+ origin (~> 1.0)
23
+ tzinfo (~> 0.3.22)
24
+ moped (1.5.1)
25
+ multi_json (1.7.9)
26
+ origin (1.1.0)
27
+ rspec (2.14.1)
28
+ rspec-core (~> 2.14.0)
29
+ rspec-expectations (~> 2.14.0)
30
+ rspec-mocks (~> 2.14.0)
31
+ rspec-core (2.14.5)
32
+ rspec-expectations (2.14.1)
33
+ diff-lcs (>= 1.1.3, < 2.0)
34
+ rspec-mocks (2.14.3)
35
+ tzinfo (0.3.37)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ bundler (>= 1.0.21)
42
+ ipgeobase_mongoid!
43
+ rspec (>= 2.14.0)
@@ -1,38 +1,48 @@
1
1
  = IPGeoBase
2
2
 
3
- Russia and Ukraine geoip lookup with DB from http://ipgeobase.ru for Mongoid 2
4
- Гем для работы с архивом с сайта http://ipgeobase.ru, содержащим базу местонахождений российских и украинских ip-адресов (с точностью до города) for Mongoid 2.
3
+ Russia and Ukraine geoip lookup with DB from http://ipgeobase.ru for Mongoid 3/4
4
+
5
+ WARNING: 1.0 breaks backward compatibility. For mongoid 2 use ~> 0
6
+
7
+ Гем для работы с архивом с сайта http://ipgeobase.ru, содержащим базу местонахождений российских и украинских ip-адресов (с точностью до города) для MongoDB (Mongoid 3/4).
5
8
 
6
9
  == Installation
7
10
 
8
11
  (1) Add to Gemfile:
9
- gem "ipgeobase_mongoid", require: 'ipgeobase'
12
+ gem "ipgeobase_mongoid"
10
13
  (2) Install required gems:
11
14
  bundle install
12
15
 
13
16
  == Upload new database
14
17
 
15
18
  * Update cities and regions. Downloads file if it's not present in tmp/cities.txt
16
- rake ipgeobase:cities
19
+ * city id's are not changed on DB update and can be used as foreign keys
20
+
21
+ rake ipgeobase:cities
17
22
 
18
23
  * Update geo ips. Downloads file if it's not present in tmp/cidr_optim.txt
19
- rake ipgeobase:ips
24
+
25
+ rake ipgeobase:ips
20
26
 
21
27
  == Methods
22
28
 
23
- После того, как выполнены все предыдущие шаги можно искать регион по IP адресу:
29
+ Search for city by IP (Russia and Ukraine only):
24
30
 
31
+ После того, как выполнены все предыдущие шаги можно искать город по IP адресу:
25
32
  Работает только для РФ и Украины.
26
33
 
27
- > Ipgeobase::find_region_by_ip('95.170.177.170')
28
- => #<IpgeobaseCity _id: 5059d68ee779891c72000201, _type: nil, geo_id: 1428, city: "Красноярск", region: "Красноярский край", district: "Сибирский федеральный округ", lat: 56.001251, lon: 92.88559, country_id: BSON::ObjectId('5059d68de779891c72000001')>
29
- > Ipgeobase::find_region_by_ip('95.170.177.170').city
30
- => "Красноярск"
31
- > Ipgeobase::find_region_by_ip('95.170.177.170').region
32
- => "Красноярский край"
33
- > Ipgeobase::find_region_by_ip('95.170.177.170').district
34
- => "Сибирский федеральный округ"
35
- > Ipgeobase::find_region_by_ip('95.170.177.170').country.name
36
- => "Россия"
37
- > Ipgeobase::find_region_by_ip('95.170.177.170').country.code
38
- => "RU"
34
+ > geo = Ipgeobase::find_region_by_ip('95.170.177.170')
35
+ > pp geo
36
+ => #<Ipgeobase::City _id: 5059d68ee779891c72000201, _type: nil, geo_id: 1428, city: "Красноярск",
37
+ region: "Красноярский край", district: "Сибирский федеральный округ", lat: 56.001251, lon: 92.88559,
38
+ country_id: BSON::ObjectId('5059d68de779891c72000001')>
39
+ > geo.city
40
+ => "Красноярск"
41
+ > geo.region
42
+ => "Красноярский край"
43
+ > geo.district
44
+ => "Сибирский федеральный округ"
45
+ > geo.country.name
46
+ => "Россия"
47
+ > geo.country.code
48
+ => "RU"
data/Rakefile CHANGED
@@ -1 +1,3 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ load File.join(File.dirname(__FILE__), 'lib', 'ipgeobase', 'tasks.rake')
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+ module Ipgeobase
3
+ class City
4
+ include Mongoid::Document
5
+
6
+ field :geo_id, type: Integer
7
+ index({geo_id: 1}, {unique: true})
8
+
9
+ field :city, type: String
10
+ field :region, type: String
11
+ field :district, type: String
12
+
13
+ field :lat, type: Float
14
+ field :lon, type: Float
15
+
16
+ belongs_to :country, class_name: 'Ipgeobase::Country'
17
+ has_many :ips, class_name: 'Ipgeobase::Ip'
18
+
19
+ validates_presence_of :city, :country, :geo_id
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ # coding: utf-8
2
+
3
+ module Ipgeobase
4
+ class Country
5
+ include Mongoid::Document
6
+
7
+ field :name, type: String
8
+ field :code, type: String
9
+
10
+ has_many :cities, class_name: 'Ipgeobase::City'
11
+
12
+ validates_presence_of :name
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # coding: utf-8
2
+
3
+ module Ipgeobase
4
+ class Ip
5
+ include Mongoid::Document
6
+
7
+ field :start_ip, type: Integer
8
+ index({start_ip: 1}, {unique: true})
9
+ field :end_ip, type: Integer
10
+
11
+ belongs_to :city, class_name: 'Ipgeobase::City'
12
+ validates_presence_of :start_ip, :end_ip, :city_id
13
+ end
14
+ end
@@ -9,8 +9,8 @@ Gem::Specification.new do |s|
9
9
  s.authors = ["GlebTv"]
10
10
  s.email = ["glebtv@gmail.com"]
11
11
  s.homepage = "https://github.com/rs-pro/ipgeobase_mongoid"
12
- s.description = "IPGeoBase.ru for mongoid 2"
13
- s.summary = "IPGeoBase.ru for mongoid 2"
12
+ s.description = "IPGeoBase.ru for mongoid 3/4"
13
+ s.summary = "IPGeoBase.ru for mongoid 3/4"
14
14
 
15
15
  s.rubyforge_project = "ipgeobase_mongoid"
16
16
 
@@ -19,6 +19,9 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_dependency "mongoid", '~> 2.4'
22
+ s.add_runtime_dependency('mongoid', [">= 3.0", "< 5.0"])
23
23
  s.required_ruby_version = '>= 1.9.2'
24
+
25
+ s.add_development_dependency(%q<rspec>, [">= 2.14.0"])
26
+ s.add_development_dependency(%q<bundler>, [">= 1.0.21"])
24
27
  end
@@ -1,35 +1,30 @@
1
1
  # coding: utf-8
2
2
 
3
3
  require "ipgeobase/version"
4
+ require 'ipaddr'
4
5
 
5
- module Ipgeobase
6
- if defined?(Rails) && defined?(Rails::Engine)
7
- class Engine < ::Rails::Engine
8
- end
6
+ if defined? Rails::Engine
7
+ require 'ipgeobase/engine'
8
+ end
9
9
 
10
- module Rails
11
- class Railtie < ::Rails::Railtie
12
- end
13
- end
14
- end
10
+ if defined? Rails::Railtie
11
+ require 'ipgeobase/railtie'
12
+ end
15
13
 
16
- def self.find_region_by_ip(user_ip)
17
- raise ArgumentError, "Must have a ip addres by template 0.0.0.0" unless user_ip =~ /^[\d\.]+$/
18
- long = ip2long(user_ip)
19
- ip = IpgeobaseIp.where(start_ip: { '$lte' => long }).order_by({ start_ip: -1 }).limit(1).first
20
- p ip
21
- if ip.nil?
22
- nil
23
- else
24
- ip.city
14
+ module Ipgeobase
15
+ class << self
16
+ def find_region_by_ip(user_ip)
17
+ long = ip2long(user_ip)
18
+ ip = Ipgeobase::Ip.where(start_ip: { '$lte' => long }).order_by({ start_ip: -1 }).limit(1).first
19
+ if ip.nil? or ip.end_ip < long
20
+ nil
21
+ else
22
+ ip.city
23
+ end
25
24
  end
26
- end
27
25
 
28
- def self.ip2long(ip)
29
- long = 0
30
- ip.split(/\./).reverse.each_with_index do |b, i|
31
- long += b.to_i << (8*i)
26
+ def ip2long(ip)
27
+ IPAddr.new(ip, Socket::AF_INET).to_i
32
28
  end
33
- long
34
29
  end
35
30
  end
@@ -0,0 +1,5 @@
1
+ module Ipgeobase
2
+ class Engine < ::Rails::Engine
3
+
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ module Ipgeobase
2
+ class Railtie < Rails::Railtie
3
+ rake_tasks do
4
+ load "ipgeobase/tasks.rake"
5
+ end
6
+ end
7
+ end
8
+
@@ -1,17 +1,19 @@
1
- # coding: utf-8
2
-
3
- module Ipgeobase
4
- module Task
5
- def self.obtain_content_by_filename(filename)
6
- file = ::Rails.root.join('tmp', filename)
7
- if File.file? file
8
- puts 'using local copy'
9
- `iconv -f cp1251 -t utf8 #{file}`
10
- else
11
- puts 'downloading database'
12
- url = 'http://ipgeobase.ru/files/db/Main/geo_files.tar.gz'
13
- `curl -0 #{url} | tar -xzO #{file} | iconv -f cp1251 -t utf8`
14
- end
15
- end
16
- end
17
- end
1
+ # coding: utf-8
2
+
3
+ module Ipgeobase
4
+ module Task
5
+ def self.obtain_content_by_filename(filename)
6
+ if defined? Rails
7
+ file = ::Rails.root.join('tmp', filename)
8
+ else
9
+ file = File.join(File.dirname(__FILE__), '..', '..', 'tmp', filename)
10
+ end
11
+ unless File.exist? file
12
+ puts 'downloading database'
13
+ url = 'http://ipgeobase.ru/files/db/Main/geo_files.tar.gz'
14
+ Kernel.system("curl #{url} | tar -xzOf - #{filename} | iconv -f cp1251 -t utf-8 > #{file}")
15
+ end
16
+ File.read(file)
17
+ end
18
+ end
19
+ end
@@ -5,10 +5,9 @@ require "ipgeobase/task"
5
5
  namespace :ipgeobase do
6
6
  desc "Update cities and regions. Downloads file if it's not present in tmp/cities.txt"
7
7
  task :cities => :environment do
8
- IpgeobaseIp.delete_all
9
- IpgeobaseCity.delete_all
10
- russia = IpgeobaseCountry.find_or_create_by(name: 'Россия', code: 'RU')
11
- ukraine = IpgeobaseCountry.find_or_create_by(name: 'Украина', code: 'UA')
8
+ puts 'updating cities'
9
+ russia = Ipgeobase::Country.find_or_create_by(name: 'Россия', code: 'RU')
10
+ ukraine = Ipgeobase::Country.find_or_create_by(name: 'Украина', code: 'UA')
12
11
  content = Ipgeobase::Task.obtain_content_by_filename('cities.txt')
13
12
  content.each_line do |c|
14
13
  options = c.split("\t")
@@ -17,24 +16,27 @@ namespace :ipgeobase do
17
16
  else
18
17
  russia
19
18
  end
20
- IpgeobaseCity.create!(geo_id: options[0], city: options[1], region: options[2], district: options[3], lat: options[4], lon: options[5], country: country)
19
+ city = Ipgeobase::City.find_or_initialize_by(geo_id: options[0])
20
+ city.assign_attributes(city: options[1], region: options[2], district: options[3], lat: options[4], lon: options[5], country: country)
21
+ city.save!
21
22
  end
22
23
  end
23
24
 
24
25
  desc "Update geo ips. Downloads file if it's not present in tmp/cidr_optim.txt"
25
26
  task :ips => :environment do
27
+ puts 'updating ips'
26
28
  content = Ipgeobase::Task.obtain_content_by_filename('cidr_optim.txt')
27
- IpgeobaseIp.delete_all
29
+ Ipgeobase::Ip.delete_all
28
30
  content.each_line do |c|
29
31
  options = c.split("\t")
30
32
  next if options.last.to_i.zero?
31
- city = IpgeobaseCity.where(geo_id: options.last.strip.to_i).first
33
+ city = Ipgeobase::City.where(geo_id: options.last.strip.to_i).first
32
34
  if city.nil?
33
35
  p "No city"
34
36
  p options
35
37
  next
36
38
  end
37
- IpgeobaseIp.create(:start_ip => options.first.to_i, :end_ip => options.second.to_i, city_id: city.id)
39
+ Ipgeobase::Ip.create(:start_ip => options.first.to_i, :end_ip => options.second.to_i, city_id: city.id)
38
40
  end
39
41
  end
40
42
  end
@@ -1,3 +1,3 @@
1
1
  module Ipgeobase
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -0,0 +1,2 @@
1
+ require 'ipgeobase'
2
+
@@ -0,0 +1,11 @@
1
+ # coding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Ipgeobase do
6
+ it 'finds city by ip' do
7
+ geo = Ipgeobase::find_region_by_ip('95.170.177.170')
8
+ geo.region.should eq 'Красноярский край'
9
+ geo.country.code.should eq 'RU'
10
+ end
11
+ end
@@ -0,0 +1,46 @@
1
+ # coding: utf-8
2
+
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+
6
+ require 'rspec'
7
+ require 'mongoid'
8
+ require 'ipgeobase'
9
+
10
+
11
+ # Requires supporting files with custom matchers and macros, etc,
12
+ # in ./support/ and its subdirectories.
13
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
14
+
15
+ Mongoid.configure do |config|
16
+ ENV["MONGOID_ENV"] = "test"
17
+ Mongoid.load!("spec/support/mongoid.yml")
18
+ end
19
+
20
+ require File.dirname(__FILE__) + '/../app/models/ipgeobase/city.rb'
21
+ require File.dirname(__FILE__) + '/../app/models/ipgeobase/country.rb'
22
+ require File.dirname(__FILE__) + '/../app/models/ipgeobase/ip.rb'
23
+
24
+ Ipgeobase::City.create_indexes
25
+ Ipgeobase::Ip.create_indexes
26
+
27
+ require 'rake'
28
+ app = Rake.application
29
+ app.init
30
+ # do this as many times as needed
31
+ # app.add_import 'lib/ipgeobase/tasks.rake'
32
+ # this loads the Rakefile and other imports
33
+ app.load_rakefile
34
+ app["ipgeobase:cities"].execute
35
+ moscow_id1 = Ipgeobase::City.where(city: 'Москва').first.id
36
+
37
+ app["ipgeobase:cities"].execute
38
+ moscow_id2 = Ipgeobase::City.where(city: 'Москва').first.id
39
+ # check that city ids are not changed on reimport
40
+ raise 'city id changed' if moscow_id1 != moscow_id2
41
+
42
+ app["ipgeobase:ips"].execute
43
+
44
+ RSpec.configure do |config|
45
+ config.mock_with :rspec
46
+ end
@@ -0,0 +1,8 @@
1
+ test:
2
+ sessions:
3
+ default:
4
+ database: ipgeobase
5
+ hosts:
6
+ - localhost:27017
7
+ options:
8
+ consistency: :strong
metadata CHANGED
@@ -1,33 +1,64 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ipgeobase_mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - GlebTv
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-09-19 00:00:00.000000000 Z
11
+ date: 2013-08-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: mongoid
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
- version: '2.4'
19
+ version: '3.0'
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
22
23
  type: :runtime
23
24
  prerelease: false
24
25
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
26
  requirements:
27
- - - ~>
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: 2.14.0
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '>='
45
+ - !ruby/object:Gem::Version
46
+ version: 2.14.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.0.21
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
28
59
  - !ruby/object:Gem::Version
29
- version: '2.4'
30
- description: IPGeoBase.ru for mongoid 2
60
+ version: 1.0.21
61
+ description: IPGeoBase.ru for mongoid 3/4
31
62
  email:
32
63
  - glebtv@gmail.com
33
64
  executables: []
@@ -35,39 +66,51 @@ extensions: []
35
66
  extra_rdoc_files: []
36
67
  files:
37
68
  - .gitignore
69
+ - .ruby-gemset
70
+ - .ruby-version
38
71
  - Gemfile
72
+ - Gemfile.lock
39
73
  - README.rdoc
40
74
  - Rakefile
41
- - app/models/ipgeobase_city.rb
42
- - app/models/ipgeobase_country.rb
43
- - app/models/ipgeobase_ip.rb
75
+ - app/models/ipgeobase/city.rb
76
+ - app/models/ipgeobase/country.rb
77
+ - app/models/ipgeobase/ip.rb
44
78
  - ipgeobase_mongoid.gemspec
45
79
  - lib/ipgeobase.rb
80
+ - lib/ipgeobase/engine.rb
81
+ - lib/ipgeobase/railtie.rb
46
82
  - lib/ipgeobase/task.rb
83
+ - lib/ipgeobase/tasks.rake
47
84
  - lib/ipgeobase/version.rb
48
- - lib/tasks/ipgeobase.rake
85
+ - lib/ipgeobase_mongoid.rb
86
+ - spec/ipgeobase_spec.rb
87
+ - spec/spec_helper.rb
88
+ - spec/support/mongoid.yml
89
+ - tmp/.gitkeep
49
90
  homepage: https://github.com/rs-pro/ipgeobase_mongoid
50
91
  licenses: []
92
+ metadata: {}
51
93
  post_install_message:
52
94
  rdoc_options: []
53
95
  require_paths:
54
96
  - lib
55
97
  required_ruby_version: !ruby/object:Gem::Requirement
56
- none: false
57
98
  requirements:
58
- - - ! '>='
99
+ - - '>='
59
100
  - !ruby/object:Gem::Version
60
101
  version: 1.9.2
61
102
  required_rubygems_version: !ruby/object:Gem::Requirement
62
- none: false
63
103
  requirements:
64
- - - ! '>='
104
+ - - '>='
65
105
  - !ruby/object:Gem::Version
66
106
  version: '0'
67
107
  requirements: []
68
108
  rubyforge_project: ipgeobase_mongoid
69
- rubygems_version: 1.8.22
109
+ rubygems_version: 2.0.6
70
110
  signing_key:
71
- specification_version: 3
72
- summary: IPGeoBase.ru for mongoid 2
73
- test_files: []
111
+ specification_version: 4
112
+ summary: IPGeoBase.ru for mongoid 3/4
113
+ test_files:
114
+ - spec/ipgeobase_spec.rb
115
+ - spec/spec_helper.rb
116
+ - spec/support/mongoid.yml
@@ -1,21 +0,0 @@
1
- # coding: utf-8
2
-
3
- class IpgeobaseCity
4
- include Mongoid::Document
5
-
6
- field :geo_id, type: Integer
7
- index :geo_id
8
-
9
- field :city, type: String
10
- field :region, type: String
11
- field :district, type: String
12
-
13
- field :lat, type: Float
14
- field :lon, type: Float
15
-
16
-
17
- belongs_to :country, class_name: 'IpgeobaseCountry'
18
- has_many :ips, class_name: 'IpgeobaseIp'
19
-
20
- validates_presence_of :city, :country, :geo_id
21
- end
@@ -1,12 +0,0 @@
1
- # coding: utf-8
2
-
3
- class IpgeobaseCountry
4
- include Mongoid::Document
5
-
6
- field :name, type: String
7
- field :code, type: String
8
-
9
- has_many :cities, class_name: 'IpgeobaseCity'
10
-
11
- validates_presence_of :name
12
- end
@@ -1,11 +0,0 @@
1
- # coding: utf-8
2
-
3
- class IpgeobaseIp
4
- include Mongoid::Document
5
-
6
- field :start_ip, type: Integer
7
- field :end_ip, type: Integer
8
-
9
- belongs_to :city, class_name: 'IpgeobaseCity'
10
- validates_presence_of :start_ip, :end_ip, :city_id
11
- end