ipcat 2.0.22 → 2.0.23

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
  SHA256:
3
- metadata.gz: 586f5adbfe57b16532b557414e3f64f82e555577cdf22359b46cb6dfd8c10f79
4
- data.tar.gz: 1b2229eec1b863890e8128ad9a149cf603aa9c846f712285d5c0f77290f5d1cc
3
+ metadata.gz: d3240f08c9b89182e5a0eefd5118ec465cbcdec12f30e6a27f60ee3087401be5
4
+ data.tar.gz: 48c2314773d06ec67d8e5cca4a801a4de99ade8d6d7089b6622c7cc921ed047a
5
5
  SHA512:
6
- metadata.gz: bfe2a2eddd94d32f951e25266eba740c7924c9d60e4d21e263982bddff38dac1c7478e73d525f0a0c47eb818b992d4b504692b526f07920056e9cbd82ccfe493
7
- data.tar.gz: 766d2403fa9da2c0caabdafd79225082cd39f5553d31aa3bc2fdc3ac4ae9b4f83af36e5c511ef3c8f59737d026a83ee6a4c5e15c0ea953be5f084c410ff466cd
6
+ metadata.gz: 3dc28f74b6488a7cd6aabab399363151855ac03ebe65f5dece83dc92b6a8eb8e324e15e7af818686ce7237e68e71d7d7581c94a961708f2b9fad59b11987ee57
7
+ data.tar.gz: 8192c6b5cc928fc9e1cfc05a3362b796114a4e95b2097096674bc5040afd9faaf0dd4948602bafa7c6e6c9323c5b2be62ba7d55217026b673f6183e0157e0499
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  A ruby port of the [ipcat](https://github.com/rale/ipcat) library to classify IP addresses from known datacenters
4
4
 
5
+ [![gem](https://img.shields.io/gem/v/ipcat?color=crimson&logo=rubygems&logoColor=eee&style=flat)](https://rubygems.org/gems/ipcat)
5
6
  [![minitest](https://github.com/kickstarter/ipcat-ruby/actions/workflows/minitest.yml/badge.svg)](https://github.com/kickstarter/ipcat-ruby/actions/workflows/minitest.yml)
6
7
 
7
8
  ## Installation
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
@@ -33,5 +28,80 @@ task :bench do
33
28
  end
34
29
  end
35
30
 
36
- # Ensure tests pass and dataset is generated before building
37
- task :build => %i[test generate_dataset]
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.22'
4
+ VERSION = '2.0.23'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ipcat
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.22
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: 2021-03-24 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
@@ -74,12 +74,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubygems_version: 3.0.3
77
+ rubygems_version: 3.4.8
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: dataset for categorizing IP addresses in ruby
81
81
  test_files:
82
- - spec/spec_helper.rb
83
- - spec/ipcat_spec.rb
84
82
  - spec/benchmark_spec.rb
83
+ - spec/spec_helper.rb
85
84
  - spec/ipcat_iprange_spec.rb
85
+ - spec/ipcat_spec.rb