vantage 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/lib/vantage/cli.rb CHANGED
@@ -10,21 +10,29 @@ module Vantage
10
10
 
11
11
  def run!
12
12
  ARGV.options do |o|
13
+ list = false
13
14
  urls = []
14
- point = 'aws-us-east-1'
15
+ point = Vantage::Config.point_list.sample
15
16
 
16
17
  o.set_summary_indent(" ")
17
- o.banner ="Usage: #{File.basename(__FILE__)} [OPTIONS]"
18
+ o.banner = "Usage: vantage [OPTIONS]"
19
+ o.banner += "\nExample: vantage -u http://google.com,http://yahoo.com"
20
+ o.on('-l', '--list-points', 'List allowed vantage points') { list = true }
18
21
  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 }
22
+ o.on('-p', '--point POINT', String, 'Vantage point to check from. If not set, will use a random point') { |p| point = p }
20
23
  o.parse!
21
24
 
22
- abort("Error: --urls is required\n\n#{o}") if urls.empty?
23
-
24
- checks = urls.map { |u| { "url" => u } }
25
- json = Vantage::Client.new.check("checks" => checks, "point" => point)
26
- results = OkJson.decode(json)
27
- results.each { |r| emit(r) }
25
+ if list
26
+ puts Vantage::Config.point_list.join("\n")
27
+ else
28
+ abort("Error: --urls is required\n\n#{o}") if urls.empty?
29
+ abort("Error: specified point does not exist\n\n#{o}") unless Vantage::Config.point_list.include?(point)
30
+
31
+ checks = urls.map { |u| { "url" => u } }
32
+ json = Vantage::Client.new.check("checks" => checks, "point" => point)
33
+ results = OkJson.decode(json)
34
+ results.each { |r| emit(r) }
35
+ end
28
36
  end
29
37
  end
30
38
  end
@@ -2,6 +2,10 @@ module Vantage
2
2
  module Config
3
3
  extend self
4
4
 
5
+ def point_list
6
+ %w[aws-us-east-1 aws-us-west-2]
7
+ end
8
+
5
9
  def endpoint_base
6
10
  URI("http://anon:anon@points.vantage.io/checks")
7
11
  end
@@ -1,3 +1,3 @@
1
1
  module Vantage
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
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.6
4
+ version: 0.0.7
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-27 00:00:00.000000000Z
12
+ date: 2012-05-27 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: An example cli for vantage.io
15
15
  email:
@@ -57,3 +57,4 @@ signing_key:
57
57
  specification_version: 3
58
58
  summary: An example cli for vantage.io
59
59
  test_files: []
60
+ has_rdoc: