ip-ranges 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +5 -5
  2. data/Rakefile +1 -1
  3. data/lib/ip-ranges/range.rb +0 -27
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4b259f6d6fdd7a56ae0f743d4847dcaed64b4507
4
- data.tar.gz: 32c8d867812c27cf93144a5fb8c030e2ac1f23f1
5
2
  SHA512:
6
- metadata.gz: 9fe1d1356fcf54a2e53fb59809d881176bbfc743ee01af6ebe80776ef9a3dd7cd04b21cc5d6f8f1360f0f6f55fa3532448708dcf21bf173c3517a4c80ef69fe7
7
- data.tar.gz: 382d3042a30e8ae524dd311fcb20eda44f97cca341d84af27d51f074a86dcba7aa584aa2b2161fbbfc504a4633b82a30d0add5ef07414bf537e4e43d4d605d01
3
+ data.tar.gz: bfeb059f023c22d55817ad8cd86438de8c475921eca11f904f1a3bc5a3ce6126e93052698ee087bcd81ecb05ca7762471dbad11e9257947e6a044fff6323674a
4
+ metadata.gz: 6fb1bd68e97989cb3a11633cd504f58a5ae6b55e00149117d5b59fda3855c939528c3a0167b925fbdf449352d21a713a799f8d2a2a63930e8aaea3a151a90a84
5
+ SHA1:
6
+ data.tar.gz: feb4ac595ab5177d3ad824d375111c7d93bab982
7
+ metadata.gz: cf86626124601bd06170150e5b6ff1d26abca600
data/Rakefile CHANGED
@@ -36,7 +36,7 @@ spec = Gem::Specification.new do |s|
36
36
 
37
37
  # Change these as appropriate
38
38
  s.name = "ip-ranges"
39
- s.version = "0.2.0"
39
+ s.version = "0.3.0"
40
40
  s.summary = "Compare and manipulate ranges of IP numbers"
41
41
  s.author = "David Salgado"
42
42
  s.email = "david@digitalronin.com"
@@ -11,14 +11,6 @@ module IpRanges
11
11
  # Last IP number in the range, as an Ip object
12
12
  attr_accessor :last
13
13
 
14
- # Throttle (or don't) how fast we yield each_ip
15
- attr_accessor :throttle
16
- attr_accessor :sleep_time
17
-
18
- BATCHSIZE = 250
19
- PAUSE = 2
20
-
21
-
22
14
  SINGLE_IP = /^\d+\.\d+\.\d+\.\d+$/
23
15
  DOTTED_RANGE = /^(\d+\.\d+\.\d+\.\d+)\.\.(\d+\.\d+\.\d+\.\d+)$/
24
16
  CIDR_RANGE = %r[/]
@@ -41,10 +33,6 @@ module IpRanges
41
33
  # IpRanges::Range.new :range => '1.2.3.0/24' => a range containing 256 Ip numbers (1.2.3.0 .. 1.2.3.255)
42
34
  #
43
35
  def initialize(params)
44
- @throttle = params.fetch(:throttle, true)
45
- @sleep_time = params.fetch(:sleep_time, PAUSE)
46
- @batch_size = params.fetch(:batch_size, BATCHSIZE)
47
-
48
36
  string = params.fetch(:range).gsub(' ', '')
49
37
 
50
38
  case string
@@ -140,12 +128,10 @@ module IpRanges
140
128
 
141
129
  # Yields each IP in the range, in turn, as an Ip object.
142
130
  def each_ip
143
- @counter = 0 # for throttling
144
131
  ip = first
145
132
  while last >= ip
146
133
  yield ip.dup
147
134
  ip.increment
148
- throttle
149
135
  end
150
136
  end
151
137
 
@@ -154,18 +140,5 @@ module IpRanges
154
140
  def empty?
155
141
  @first.nil? && @last.nil?
156
142
  end
157
-
158
- def throttle
159
- @counter += 1
160
- if @counter % BATCHSIZE == 0
161
- take_a_nap if throttle
162
- end
163
- end
164
-
165
- def take_a_nap
166
- log "Counter: #{$counter}, sleeping for #{sleep_time} seconds" if $verbose
167
- sleep sleep_time
168
- end
169
-
170
143
  end
171
144
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ip-ranges
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Salgado