vantage 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/lib/vantage/cli.rb CHANGED
@@ -11,16 +11,18 @@ module Vantage
11
11
  def run!
12
12
  ARGV.options do |o|
13
13
  urls = []
14
+ point = 'aws-us-east-1'
14
15
 
15
16
  o.set_summary_indent(" ")
16
17
  o.banner ="Usage: #{File.basename(__FILE__)} [OPTIONS]"
17
18
  o.on('-u', '--urls URLS', Array, 'List of urls to check') { |list| urls = list }
19
+ o.on('-p', '--point POINT', String, 'Vantage point to check from. Default to aws-us-east-1.') { |p| point = p }
18
20
  o.parse!
19
21
 
20
22
  abort("Error: --urls is required\n\n#{o}") if urls.empty?
21
23
 
22
24
  checks = urls.map { |u| { "url" => u } }
23
- json = Vantage::Client.new.check("checks" => checks)
25
+ json = Vantage::Client.new.check("checks" => checks, "point" => point)
24
26
  results = OkJson.decode(json)
25
27
  results.each { |r| emit(r) }
26
28
  end
@@ -1,14 +1,13 @@
1
1
  module Vantage
2
2
  class Client
3
3
  def check(data={})
4
- endpoint = Vantage::Config.endpoint
5
- uri = URI(endpoint)
4
+ endpoint = Vantage::Config.endpoint(data['point'])
6
5
 
7
- req = Net::HTTP::Post.new(uri.to_s.gsub("#{uri.user}:#{uri.password}@",""))
6
+ req = Net::HTTP::Post.new(endpoint.to_s.gsub("#{endpoint.user}:#{endpoint.password}@",""))
8
7
  req.body = OkJson.encode(data["checks"])
9
- req.basic_auth uri.user, uri.password
8
+ req.basic_auth endpoint.user, endpoint.password
10
9
 
11
- Net::HTTP.start(uri.host, uri.port) { |http| http.request(req) }.body
10
+ Net::HTTP.start(endpoint.host, endpoint.port) { |http| http.request(req) }.body
12
11
  end
13
12
  end
14
13
  end
@@ -2,8 +2,14 @@ module Vantage
2
2
  module Config
3
3
  extend self
4
4
 
5
- def endpoint
6
- "http://anon:anon@vantage-point.herokuapp.com/checks"
5
+ def endpoint_base
6
+ URI("http://anon:anon@points.vantage.io/checks")
7
7
  end
8
+
9
+ def endpoint(name)
10
+ uri = endpoint_base
11
+ uri.host = "#{name}.#{uri.host}"
12
+ uri
13
+ end
8
14
  end
9
15
  end
@@ -1,3 +1,3 @@
1
1
  module Vantage
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vantage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-26 00:00:00.000000000 Z
12
+ date: 2012-05-27 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: An example cli for vantage.io
15
15
  email:
@@ -57,4 +57,3 @@ signing_key:
57
57
  specification_version: 3
58
58
  summary: An example cli for vantage.io
59
59
  test_files: []
60
- has_rdoc: