iprange 0.0.2 → 0.0.4

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
- SHA1:
3
- metadata.gz: 4cf4818d4ba6e945d3d11f15edd860b7586bf815
4
- data.tar.gz: 10995790fd132aa1bc7100f71b4ddb9f155e75f1
2
+ SHA256:
3
+ metadata.gz: af5afe44bc65284d1801beab8b3dacf81773b151c535eaf354a4e6f3d3f241c3
4
+ data.tar.gz: f99758acb9dbaeb69f70cd0f23290f361244f28c27fe5180ec51d80385969512
5
5
  SHA512:
6
- metadata.gz: 0d4ffb3db2965f645f80c92b77fb77b2623cb34c2fbd485426d652cc39678e04d3a173d5dc867825e36613a2bc4c03aeac95c925204ac6bedc79edb318daf273
7
- data.tar.gz: f9d801b8bd54dedb193ba169b7aa738bfe1af0fd94fcd10d87135c5359195120eca1c1252664753de46d02b25bbb12035e4bacdf0fb288b1c18548a976bcc35b
6
+ metadata.gz: 465610649a517b9516533cae8080b52f13333efbec0433cbf30b3d63e82984d49a33d3098ca375f93875efd46a321f67e0882c49603a80537278a7cee47400d9
7
+ data.tar.gz: 774d3e8c2c618709bd2f56b76251b0cabb048ff6b58b6a632711b5a43365020ad39a3d73c4b4fdf4bd1038cd2ce42ddf7818958795b544653d5453130dadb49f
data/README.md CHANGED
@@ -32,7 +32,7 @@ If your intervals do not, you can try the tag v0.0.1, which uses sorted sets ins
32
32
 
33
33
  ## Contributing
34
34
 
35
- 1. Fork it ( http://github.com/jbochi/iprange/fork )
35
+ 1. Fork it ( http://github.com/globocom/iprange/fork )
36
36
  2. Create your feature branch (`git checkout -b my-new-feature`)
37
37
  3. Commit your changes (`git commit -am 'Add some feature'`)
38
38
  4. Push to the branch (`git push origin my-new-feature`)
@@ -10,15 +10,21 @@ module IPRange
10
10
  end
11
11
 
12
12
  def remove(range)
13
- @redis.irem(@redis_key, range)
14
- @redis.del(metadata_key(range))
13
+ @redis.pipelined do
14
+ @redis.irem(@redis_key, range)
15
+ @redis.del(metadata_key(range))
16
+ end
15
17
  end
16
18
 
17
19
  def add(range, metadata={})
18
20
  ipaddr_range = IPAddr.new(range).to_range
19
- @redis.iadd(@redis_key, ipaddr_range.first.to_i, ipaddr_range.last.to_i, range)
21
+ range = "#{metadata[:key]}:#{range}" if metadata[:key]
20
22
  hash = metadata_key(range)
21
- @redis.mapped_hmset(hash, metadata) unless metadata.empty?
23
+
24
+ @redis.pipelined do
25
+ @redis.iadd(@redis_key, ipaddr_range.first.to_i, ipaddr_range.last.to_i, range)
26
+ @redis.mapped_hmset(hash, metadata) unless metadata.empty?
27
+ end
22
28
  end
23
29
 
24
30
  def find(ip)
@@ -1,3 +1,3 @@
1
1
  module Iprange
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -66,6 +66,21 @@ describe IPRange::Range do
66
66
  end
67
67
  end
68
68
 
69
+ describe "when a range is added with extra key" do
70
+ after :each do
71
+ range = IPRange::Range.new()
72
+ range.remove("router1:192.168.0.1/24")
73
+ end
74
+
75
+ it "should find it with the key" do
76
+ range = IPRange::Range.new
77
+ range.add("192.168.0.1/24", key: "router1")
78
+
79
+ response = range.find("192.168.0.20")
80
+ expect(response[:range]).to eq("router1:192.168.0.1/24")
81
+ end
82
+ end
83
+
69
84
  describe "when there is multiple ranges with overlap" do
70
85
  subject do
71
86
  IPRange::Range.new
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iprange
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juarez Bochi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-07 00:00:00.000000000 Z
11
+ date: 2020-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
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: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.5'
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: '1.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Save IP ranges on Redis for fast lookup using interval sets.
@@ -73,8 +73,8 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - .gitignore
77
- - .rspec
76
+ - ".gitignore"
77
+ - ".rspec"
78
78
  - Gemfile
79
79
  - LICENSE.txt
80
80
  - README.md
@@ -102,17 +102,16 @@ require_paths:
102
102
  - lib
103
103
  required_ruby_version: !ruby/object:Gem::Requirement
104
104
  requirements:
105
- - - '>='
105
+ - - ">="
106
106
  - !ruby/object:Gem::Version
107
107
  version: '0'
108
108
  required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - '>='
110
+ - - ">="
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  requirements: []
114
- rubyforge_project:
115
- rubygems_version: 2.0.14
114
+ rubygems_version: 3.0.3
116
115
  signing_key:
117
116
  specification_version: 4
118
117
  summary: IP ranges on Redis