rangeclient 0.0.16 → 0.0.19

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
- SHA1:
3
- metadata.gz: 2dc88890b0298178808480c76d63469cbc6ca1ff
4
- data.tar.gz: 6e77c662eefeef87c7483f76a33e4733027c3d3c
2
+ SHA256:
3
+ metadata.gz: a792c858319fda71de0b824b3a7783657c643d538d0ac66df22af819f92de6f0
4
+ data.tar.gz: a54cfff00491cfa3c7a9c5592e063cd03aefde6723aea7af026462e7f4eeb250
5
5
  SHA512:
6
- metadata.gz: 0a248cfd863d1ab76a9a1b72cd06a5076c9d0b40d0155e9988835cd19dd99e4f14176df1dd838726801f02bebfe2a4a704ac7fa7120b33bd7e6429554506ee34
7
- data.tar.gz: 0d0b1e393b39451122a8eb37c6e0f7a9da331ec041f53dc5d4e771d279c94b699e2d6243a6bc80108d9cf6781c50d8de44ffce264c0f05666db6321e5fb317bf
6
+ metadata.gz: 0763352a40f4254a055d5576e4151e06ff7dfef37b5ca71bac84a3a5dc3abb0bc6db40c4fe30cabd4fa65567227a549f68d2b0dc97367d69a53e6573c4d70715
7
+ data.tar.gz: f21f1b175c991b31639a09784ce19278934585827d4eb4d345cd769fed89b0b5c2f1b6ec7d07b4219a8bf75d48a104ae0b38bac76618ae906bdde5e19d2da2a0
data/bin/er CHANGED
@@ -1,6 +1,5 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
 
3
- require 'rubygems'
4
3
  require 'rangeclient'
5
4
 
6
5
  require 'optparse'
@@ -10,13 +9,13 @@ options = {
10
9
  }
11
10
  optparse = OptionParser.new do |opts|
12
11
  opts.on('-e', '--expand', 'Print one element per line') do |arg|
13
- options[:expand] = arg
12
+ options[:expand] = arg
14
13
  end
15
14
  opts.on('-c', '--count', 'Print the count of range elements, not the range itself') do |arg|
16
- options[:count] = arg
15
+ options[:count] = arg
17
16
  end
18
17
  opts.on('-s', '--sort', 'Sort expanded output') do |arg|
19
- options[:sorted] = arg
18
+ options[:sorted] = arg
20
19
  end
21
20
  opts.on('-v', '--vip range:80', 'Which host or host:port to query') do |arg|
22
21
  host, port = arg.split(':', 2)
@@ -24,7 +23,13 @@ optparse = OptionParser.new do |opts|
24
23
  options[:port] = port unless port.nil?
25
24
  end
26
25
  opts.on('-p', '--port 80', 'Port to use when connecting') do |arg|
27
- options[:port] = arg
26
+ options[:port] = arg
27
+ end
28
+ opts.on('--[no-]ssl', 'Enable SSL') do |ssl|
29
+ options[:ssl] = ssl
30
+ end
31
+ opts.on('--ca-file FILE', 'PEM-formatted CA certificates to validate against when SSL is enabled') do |cafile|
32
+ options[:ca_file] = cafile
28
33
  end
29
34
  opts.on('-t', '--timeout TIMEOUT', "Wait this long for a response") do |arg|
30
35
  options[:timeout] = arg.to_i
data/bin/range-compress CHANGED
@@ -1,6 +1,5 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
 
3
- require 'rubygems'
4
3
  require 'rangeclient'
5
4
  require 'pp'
6
5
 
data/bin/range_diff CHANGED
@@ -1,6 +1,5 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
 
3
- require 'rubygems'
4
3
  require 'rangeclient'
5
4
 
6
5
  first_range = ARGV.shift
data/bin/range_split CHANGED
@@ -1,9 +1,9 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/env ruby
2
+
2
3
  # given a range and N buckets, slice the range
3
4
  # into N buckets, attempting even bucket distribution
4
5
  # based on hostname
5
6
 
6
- require 'rubygems'
7
7
  require 'rangeclient'
8
8
 
9
9
  range_arg = ARGV.shift;
data/lib/rangeclient.rb CHANGED
@@ -7,7 +7,7 @@ require 'uri'
7
7
  class Range::Client
8
8
  attr_accessor :host, :port, :timeout, :rangeexception
9
9
 
10
- class QueryException < Exception
10
+ class QueryException < StandardError
11
11
  end
12
12
 
13
13
  # used to split hostnames into component parts for compression
@@ -29,15 +29,21 @@ class Range::Client
29
29
  @ssl = ENV['RANGE_SSL'] =~ (/(1|true)/i)
30
30
  @ssl = options[:ssl] if options.member?(:ssl)
31
31
 
32
+ @ca_file = ENV['RANGE_CA_FILE'] if ENV.has_key?('RANGE_CA_FILE')
33
+ @ca_file = options[:ca_file] if options.member?(:ca_file)
34
+
32
35
  @timeout = 60
33
36
  @timeout = options[:timeout] if options.member?(:timeout)
34
37
  end
35
38
 
36
39
  def expand(arg)
37
- escaped_arg = URI.escape arg
40
+ escaped_arg = URI.encode_www_form_component arg
38
41
  http = Net::HTTP.new(@host, @port)
39
42
  http.read_timeout = @timeout
40
- http.use_ssl = @ssl
43
+ if @ssl
44
+ http.use_ssl = true
45
+ http.ca_file = @ca_file
46
+ end
41
47
  req = Net::HTTP::Get.new('/range/list?' + escaped_arg)
42
48
  resp = http.request(req)
43
49
  raise QueryException.new(resp.body) unless resp.is_a?(Net::HTTPSuccess)
@@ -85,7 +91,7 @@ class Range::Client
85
91
  if r=~ /,/
86
92
  r = "{#{r}}"
87
93
  end
88
- result << "#{r}.#{domain}"
94
+ result << "#{r}.#{domain}"
89
95
  end
90
96
  return result.join ","
91
97
  end
@@ -135,7 +141,7 @@ class Range::Client
135
141
  count += 1
136
142
  next
137
143
  end
138
-
144
+
139
145
  if prev_n
140
146
  if count > 0
141
147
  result << _get_group(prev_prefix, prev_digits, count, prev_suffix)
@@ -181,7 +187,7 @@ class Range::Client
181
187
  prefix = "" if prefix.nil?
182
188
  group = sprintf("%s%0*d..%s",
183
189
  prefix,
184
- digits.to_s.length,
190
+ digits.to_s.length,
185
191
  digits.to_i, # sometimes has leading zeroes
186
192
  _ignore_common_prefix(digits, (digits.to_i + count).to_s)
187
193
  )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rangeclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.16
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Miller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-26 00:00:00.000000000 Z
11
+ date: 2022-07-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Use with range from https://github.com/square/libcrange
14
14
  email:
@@ -49,10 +49,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  - !ruby/object:Gem::Version
50
50
  version: 1.3.6
51
51
  requirements: []
52
- rubyforge_project:
53
- rubygems_version: 2.4.4
52
+ rubygems_version: 3.3.5
54
53
  signing_key:
55
54
  specification_version: 4
56
55
  summary: Simple range client for ruby.
57
56
  test_files: []
58
- has_rdoc: