ipcat 2.0.21 → 2.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 128607107ec0662a3fa669eb945725fc0561466c031954c4f1e5383ebf151dce
4
- data.tar.gz: 5227424a89485a5a5609bd59644921eba35a8865b4ffd4b4a3b360fba87b7fe6
3
+ metadata.gz: d3240f08c9b89182e5a0eefd5118ec465cbcdec12f30e6a27f60ee3087401be5
4
+ data.tar.gz: 48c2314773d06ec67d8e5cca4a801a4de99ade8d6d7089b6622c7cc921ed047a
5
5
  SHA512:
6
- metadata.gz: 1b9d07d76fd125bcb6cde416e2b177ffe875f872fc8617912200c1aa8e1157a6fd10d533cc5909597d04a482c0c6eb30b61c64a7f4a17c483e1fe15322334536
7
- data.tar.gz: 0c60a4e6823615569cadf8868a445777140d4c8ddc26eee4a08b002e2d29468704cf94c8501d293482305830488dd572787205cdcfae19ed4ad8a2c7b2827b6f
6
+ metadata.gz: 3dc28f74b6488a7cd6aabab399363151855ac03ebe65f5dece83dc92b6a8eb8e324e15e7af818686ce7237e68e71d7d7581c94a961708f2b9fad59b11987ee57
7
+ data.tar.gz: 8192c6b5cc928fc9e1cfc05a3362b796114a4e95b2097096674bc5040afd9faaf0dd4948602bafa7c6e6c9323c5b2be62ba7d55217026b673f6183e0157e0499
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # ipcat-ruby
2
2
 
3
- A ruby port of the [ipcat](https://github.com/client9/ipcat) library to classify IP addresses from known datacenters
3
+ A ruby port of the [ipcat](https://github.com/rale/ipcat) library to classify IP addresses from known datacenters
4
4
 
5
- [![Build Status](https://travis-ci.org/kickstarter/ipcat-ruby.svg?branch=master)](https://travis-ci.org/kickstarter/ipcat-ruby)
6
- [![Code Climate](https://img.shields.io/codeclimate/github/kickstarter/ipcat-ruby.svg?style=flat)](https://codeclimate.com/github/kickstarter/ipcat-ruby)
5
+ [![gem](https://img.shields.io/gem/v/ipcat?color=crimson&logo=rubygems&logoColor=eee&style=flat)](https://rubygems.org/gems/ipcat)
6
+ [![minitest](https://github.com/kickstarter/ipcat-ruby/actions/workflows/minitest.yml/badge.svg)](https://github.com/kickstarter/ipcat-ruby/actions/workflows/minitest.yml)
7
7
 
8
8
  ## Installation
9
9
 
data/Rakefile CHANGED
@@ -11,15 +11,10 @@ Rake::TestTask.new do |t|
11
11
  t.pattern = 'spec/*_spec.rb'
12
12
  end
13
13
 
14
- task default: :test
15
-
16
- desc 'Regenerate data/datacenters'
17
- task :generate_dataset do
18
- $LOAD_PATH.unshift './lib'
19
- require 'ipcat'
20
- IPCat.load_csv!
21
- File.open('data/datacenters', 'w') { |f| f << Marshal.dump(IPCat.ranges) }
22
- end
14
+ task :default => :test
15
+
16
+ # Ensure tests pass before building gem
17
+ task :build => :test
23
18
 
24
19
  desc 'Run benchmark'
25
20
  task :bench do
@@ -32,3 +27,81 @@ task :bench do
32
27
  end
33
28
  end
34
29
  end
30
+
31
+ namespace :data do
32
+ desc 'Automated task to open PR on dataset changes'
33
+ task :autorev => %i[data/datacenters lib/ipcat/version.rb CHANGELOG.md], :order_only => :update do |t|
34
+ files = t.prereqs.join(' ')
35
+ sh %{git diff --quiet data/datacenters} do |ok|
36
+ unless ok
37
+ # Get PR ready…
38
+ main_branch = ENV['GIT_MAIN_BRANCH'] || 'main'
39
+ remote = ENV['GIT_REMOTE'] || 'origin'
40
+ new_branch = "auto/update-dataset-#{Time.now.utc.to_i}"
41
+ title = "[autorev] ipcat v#{IPCat::VERSION}"
42
+ body = "Update datacenters file and bump patch version."
43
+
44
+ # Checkout new branch, commit rev'd files, push and open PR
45
+ sh %{git checkout -b #{new_branch}}
46
+ sh %{git add #{files}}
47
+ sh %{git commit -m "#{title}\n\n#{body}"}
48
+ sh %{git push #{remote} #{new_branch}}
49
+ sh %{gh pr create -B #{main_branch} -b #{body.inspect} -H #{new_branch} -t #{title.inspect}}
50
+ else
51
+ puts "data/datacenters is up-to-date."
52
+ end
53
+ end
54
+ end
55
+
56
+ desc 'Regenerate data/datacenters'
57
+ task :generate => %i[update data/datacenters]
58
+
59
+ desc 'Update git submodules'
60
+ task :update do
61
+ sh %{git submodule update}
62
+ end
63
+ end
64
+
65
+ ##
66
+ # Add CHANGELOG.md entry
67
+ file 'CHANGELOG.md' => 'lib/ipcat/version.rb' do |f|
68
+ # Inject changelog entry
69
+ changelog = [
70
+ "## v#{IPCat::VERSION} - #{Time.now.strftime('%d %B %Y')}\n",
71
+ "\n",
72
+ "- Update datacenters\n",
73
+ "\n",
74
+ ]
75
+ body = File.read(f.name).lines.insert(4, *changelog).join
76
+
77
+ # Write to disk
78
+ File.open(f.name, 'w') { |f| f.write(body) }
79
+ end
80
+
81
+ ##
82
+ # Bump IPCat::VERSION
83
+ file 'lib/ipcat/version.rb' => 'data/datacenters' do |f|
84
+ # Get current version numbers
85
+ major, minor, patch = IPCat::VERSION.split(/\./)
86
+ this_v = "#{major}.#{minor}.#{patch}"
87
+ next_v = "#{major}.#{minor}.#{patch.to_i + 1}"
88
+
89
+ # Bump patch number
90
+ search = /VERSION = '#{this_v}'/
91
+ replace = "VERSION = '#{next_v}'"
92
+ body = File.read(f.name).sub(search, replace)
93
+
94
+ # Write to disk
95
+ File.open(f.name, 'w') { |v| v.write(body) }
96
+
97
+ # Update IPCat::VERSION silently
98
+ IPCat.send :remove_const, :VERSION
99
+ IPCat.const_set :VERSION, next_v
100
+ end
101
+
102
+ ##
103
+ # Generate data/datacenters binary
104
+ file 'data/datacenters' => '.gitsubmodules/rale/ipcat/datacenters.csv' do |f|
105
+ IPCat.load_csv!(path = f.prereqs.first)
106
+ File.open(f.name, 'w') { |f| f << Marshal.dump(IPCat.ranges) }
107
+ end
data/data/datacenters CHANGED
Binary file
data/lib/ipcat/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class IPCat
4
- VERSION = '2.0.21'
4
+ VERSION = '2.0.23'
5
5
  end
data/lib/ipcat.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ##
4
4
  # IPCat
5
- # Ruby lib for https://github.com/client9/ipcat/
5
+ # Ruby lib for https://github.com/rale/ipcat/
6
6
 
7
7
  require 'ipaddr'
8
8
  require 'ipcat/iprange'
@@ -27,7 +27,7 @@ class IPCat
27
27
  @ranges = new_ranges
28
28
  end
29
29
 
30
- def load_csv!(path = 'https://raw.github.com/client9/ipcat/master/datacenters.csv')
30
+ def load_csv!(path = 'https://raw.githubusercontent.com/rale/ipcat/master/datacenters.csv')
31
31
  reset_ranges!
32
32
 
33
33
  require 'open-uri'
@@ -14,14 +14,14 @@ describe 'IPCat::IPRange' do
14
14
 
15
15
  describe '#initialize' do
16
16
  it 'should fail if last < first' do
17
- -> { IPCat::IPRange.new(2, 1) }.must_raise ArgumentError
17
+ expect { IPCat::IPRange.new(2, 1) }.must_raise ArgumentError
18
18
  end
19
19
  end
20
20
 
21
21
  describe '#<=> for integers' do
22
- it('should match first') { (range <=> range.first).must_equal 0 }
23
- it('should match last') { (range <=> range.last).must_equal 0 }
24
- it('should match first-1') { (range <=> range.first - 1).must_equal 1 }
25
- it('should match last+1') { (range <=> range.last + 1).must_equal(-1) }
22
+ it('should match first') { expect(range <=> range.first).must_equal 0 }
23
+ it('should match last') { expect(range <=> range.last).must_equal 0 }
24
+ it('should match first-1') { expect(range <=> range.first - 1).must_equal 1 }
25
+ it('should match last+1') { expect(range <=> range.last + 1).must_equal(-1) }
26
26
  end
27
27
  end
data/spec/ipcat_spec.rb CHANGED
@@ -11,14 +11,14 @@ describe 'IPCat' do
11
11
  end
12
12
 
13
13
  describe '#ranges' do
14
- it('has a range') { IPCat.ranges.size.must_equal 1 }
14
+ it('has a range') { expect(IPCat.ranges.size).must_equal 1 }
15
15
  end
16
16
 
17
17
  describe '#datacenter?' do
18
- it('should match 1.2.3.0') { IPCat.datacenter?('1.2.3.0').must_be_instance_of IPCat::IPRange }
19
- it('should match 1.2.3.1') { IPCat.datacenter?('1.2.3.1').must_be_instance_of IPCat::IPRange }
20
- it('should match 1.2.3.1') { IPCat.datacenter?('1.2.3.1').must_be_instance_of IPCat::IPRange }
21
- it('should not match 1.1.1.1') { IPCat.datacenter?('1.1.1.1').must_be_nil }
22
- it('should not match 2.2.2.2') { IPCat.datacenter?('2.2.2.2').must_be_nil }
18
+ it('should match 1.2.3.0') { expect(IPCat.datacenter?('1.2.3.0')).must_be_instance_of IPCat::IPRange }
19
+ it('should match 1.2.3.1') { expect(IPCat.datacenter?('1.2.3.1')).must_be_instance_of IPCat::IPRange }
20
+ it('should match 1.2.3.1') { expect(IPCat.datacenter?('1.2.3.1')).must_be_instance_of IPCat::IPRange }
21
+ it('should not match 1.1.1.1') { expect(IPCat.datacenter?('1.1.1.1')).must_be_nil }
22
+ it('should not match 2.2.2.2') { expect(IPCat.datacenter?('2.2.2.2')).must_be_nil }
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,44 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ipcat
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.21
4
+ version: 2.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Suggs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-08 00:00:00.000000000 Z
11
+ date: 2023-08-17 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
- version: 4.4.0
19
+ version: '5.14'
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
- version: 4.4.0
26
+ version: '5.14'
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
- version: '0'
33
+ version: '13.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
- version: '0'
41
- description: 'A ruby port of the ipcat library: https://github.com/client9/ipcat/'
40
+ version: '13.0'
41
+ description: 'A ruby port of the ipcat library: https://github.com/rale/ipcat/'
42
42
  email: aaron@ktheory.com
43
43
  executables: []
44
44
  extensions: []
@@ -74,8 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.7.6
77
+ rubygems_version: 3.4.8
79
78
  signing_key:
80
79
  specification_version: 4
81
80
  summary: dataset for categorizing IP addresses in ruby