ipcat 1.2.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e7013b044000ae1d642d1abbd5dfc4c5efcebde
4
- data.tar.gz: c6be24f04c10186fa6ccd8cb47fa302afba3f220
3
+ metadata.gz: 6c2b737d8f34461a1e622df44e70d022c8f43ec2
4
+ data.tar.gz: 1d05d71f1a1e9090707f76a36f9be9a62890b2c6
5
5
  SHA512:
6
- metadata.gz: 3a4a644cbb352ab232b149c140bacc7cb49fcaaba49b7e4a74fbfc45208af67f967bdc4426dd3aa5a5098cff20565597ac14208b4e7d30e2fc8d0326b136d45d
7
- data.tar.gz: 04c7fd63d6978afec254a972c3462f9f77464b6ad3d9755538a7b63d0d215fa37c75e281d5240a5a32f92e37f623766554f8d3e594b94c45c7bd70fa6d81f99e
6
+ metadata.gz: 0ad9494ed282c6499b2bca0fe382709af77cb157e75196a98f04ff56f326d0ab519c3aed43797d006c05b75c7bc52999085068d36406998ab867870e85a09841
7
+ data.tar.gz: d12e6d35e96ec4ccb6a8afb1ea68f95e4683a9ae7043e2064236885edadb848e78e52642e98bf5621699944ccb7626ad4a4e0b0ea2d96ddc6616910b50c0ed2a
data/data/datacenters CHANGED
Binary file
data/lib/ipcat/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class IPCat
2
- VERSION = '1.2.2'
2
+ VERSION = '2.0.0'
3
3
  end
data/lib/ipcat.rb CHANGED
@@ -10,7 +10,8 @@ require 'ipcat/version'
10
10
  class IPCat
11
11
  class << self
12
12
  def datacenter?(ip)
13
- bsearch(ip_to_integer(ip))
13
+ ip_as_int = ip_to_integer(ip)
14
+ ranges.bsearch {|range| range <=> ip_as_int }
14
15
  end
15
16
  alias_method :classify, :datacenter?
16
17
 
@@ -30,8 +31,7 @@ class IPCat
30
31
  reset_ranges!
31
32
 
32
33
  require 'open-uri'
33
- open(path).readlines.each do |line|
34
- next if line =~/\s*#/ # Skip comments
34
+ open(path).readlines[1..-1].each do |line|
35
35
  first, last, name, url = line.split(',')
36
36
  self.ranges << IPRange.new(first, last, name, url).freeze
37
37
  end
@@ -49,21 +49,6 @@ class IPCat
49
49
  rescue
50
50
  load_csv!
51
51
  end
52
-
53
- # Assume ranges is an array of comparable objects
54
- def bsearch(needle, haystack=ranges, first=0, last=ranges.size-1)
55
- return nil if last < first # not found, or empty range
56
-
57
- cur = first + (last - first)/2
58
- case haystack[cur] <=> needle
59
- when -1 # needle is larger than cur value
60
- bsearch(needle, haystack, cur+1, last)
61
- when 1 # needle is smaller than cur value
62
- bsearch(needle, haystack, first, cur-1)
63
- when 0
64
- haystack[cur]
65
- end
66
- end
67
52
  end
68
53
  end
69
54
 
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ipcat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Suggs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-21 00:00:00.000000000 Z
11
+ date: 2014-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.4.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: 'A ruby port of the ipcat library: https://github.com/client9/ipcat/'
@@ -44,12 +44,12 @@ executables: []
44
44
  extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
+ - README.md
48
+ - Rakefile
49
+ - data/datacenters
50
+ - lib/ipcat.rb
47
51
  - lib/ipcat/iprange.rb
48
52
  - lib/ipcat/version.rb
49
- - lib/ipcat.rb
50
- - data/datacenters
51
- - Rakefile
52
- - README.md
53
53
  - spec/benchmark_spec.rb
54
54
  - spec/ipcat_iprange_spec.rb
55
55
  - spec/ipcat_spec.rb
@@ -59,22 +59,22 @@ licenses: []
59
59
  metadata: {}
60
60
  post_install_message:
61
61
  rdoc_options:
62
- - --charset=UTF-8
62
+ - "--charset=UTF-8"
63
63
  require_paths:
64
64
  - lib
65
65
  required_ruby_version: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - '>='
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 1.9.3
69
+ version: 2.0.0
70
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - '>='
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 2.0.14
77
+ rubygems_version: 2.2.2
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: dataset for categorizing IP addresses in ruby
@@ -83,3 +83,4 @@ test_files:
83
83
  - spec/ipcat_iprange_spec.rb
84
84
  - spec/ipcat_spec.rb
85
85
  - spec/spec_helper.rb
86
+ has_rdoc: