auger 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.4
1
+ 1.3.5
data/bin/aug CHANGED
@@ -59,6 +59,7 @@ cfg =
59
59
  ## pretty-print Result object
60
60
  module Auger
61
61
  class Result
62
+
62
63
  def format
63
64
  output =
64
65
  case self.outcome
@@ -74,6 +75,13 @@ module Auger
74
75
  case self.status
75
76
  when FalseClass, NilClass then :red
76
77
  when Exception then :magenta
78
+ when Status then
79
+ case self.status.value
80
+ when :ok then :green
81
+ when :warn then :yellow
82
+ when :exception then :magenta
83
+ else :red
84
+ end
77
85
  else :green
78
86
  end
79
87
 
@@ -6,7 +6,9 @@ require 'auger/connection'
6
6
  require 'auger/request'
7
7
  require 'auger/test'
8
8
  require 'auger/result'
9
+ require 'auger/status'
9
10
 
11
+ ## plugins
10
12
  require 'auger/plugin/dns.rb'
11
13
  require 'auger/plugin/http.rb'
12
14
  require 'auger/plugin/redis.rb'
@@ -62,6 +62,7 @@ module Auger
62
62
 
63
63
  class HttpRequest < Auger::Request
64
64
  attr_accessor :method, :headers, :user, :password, :data
65
+ alias_method :url, :arg
65
66
 
66
67
  def initialize(url)
67
68
  @method ||= :get # default
@@ -87,8 +88,8 @@ module Auger
87
88
  @password = password
88
89
  end
89
90
 
90
- def run(http)
91
- request = Net::HTTP::const_get(@method.capitalize).new(@arg) # e.g. Net::HTTP::Get
91
+ def run(http, url)
92
+ request = Net::HTTP::const_get(@method.capitalize).new(url) # e.g. Net::HTTP::Get
92
93
  request.basic_auth(@user, @password || '') if @user
93
94
  @headers.each { |k,v| request[k] = v }
94
95
  request.set_form_data(@data)
@@ -1,7 +1,7 @@
1
1
  module Auger
2
2
 
3
3
  class Request
4
- attr_accessor :tests, :before_tests_proc, :arg
4
+ attr_accessor :tests, :before_tests_proc, :before_request_proc, :arg
5
5
 
6
6
  def self.load(arg, &block)
7
7
  request = new(arg)
@@ -23,6 +23,15 @@ module Auger
23
23
  Auger::Result.new(*args)
24
24
  end
25
25
 
26
+ ## called within test block to return a Status object
27
+ def Status(*args)
28
+ Auger::Status.new(*args)
29
+ end
30
+
31
+ def before_request(&block)
32
+ @before_request_proc = block
33
+ end
34
+
26
35
  ## callback to be run after request, but before tests
27
36
  def before_tests(&block)
28
37
  @before_tests_proc = block
@@ -32,7 +41,10 @@ module Auger
32
41
  def do_run(conn)
33
42
  return conn if conn.is_a? Exception
34
43
  begin
35
- response = self.run(conn)
44
+ arg = @arg
45
+ arg = self.before_request_proc.call(conn) if self.before_request_proc
46
+
47
+ response = self.run(conn, arg)
36
48
  response = self.before_tests_proc.call(response) if self.before_tests_proc
37
49
  response
38
50
  rescue => e
@@ -0,0 +1,18 @@
1
+ module Auger
2
+
3
+ class Status
4
+ VALUES = [:ok, :warn, :error, :exception]
5
+ attr_accessor :value
6
+
7
+ def initialize(value)
8
+ raise ArgumentError, "illegal status value" unless VALUES.include? value
9
+ @value = value
10
+ end
11
+
12
+ def to_s
13
+ @value.to_s
14
+ end
15
+
16
+ end
17
+
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auger
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-06-27 00:00:00.000000000 Z
13
+ date: 2012-07-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json
@@ -125,6 +125,7 @@ files:
125
125
  - lib/auger/request.rb
126
126
  - lib/auger/result.rb
127
127
  - lib/auger/server.rb
128
+ - lib/auger/status.rb
128
129
  - lib/auger/test.rb
129
130
  - lib/auger/version.rb
130
131
  homepage: https://rubygems.org/gems/auger