erroneous-api 0.0.2

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.
@@ -0,0 +1,33 @@
1
+ require 'ey_api_hmac'
2
+ require 'uri'
3
+ module ErroneousAPI
4
+ class Client
5
+
6
+ def initialize(base_url)
7
+ @base_url = base_url
8
+ end
9
+
10
+ def mock!(backend)
11
+ self.connection.backend = backend
12
+ end
13
+
14
+ def connection
15
+ @connection ||= EY::ApiHMAC::BaseConnection.new
16
+ end
17
+
18
+ def parse_deploy_fail(text)
19
+ connection.post(URI.join(@base_url, '/parse_deploy_fail').to_s, {:deploy_log => text}) do |json_response, location_header|
20
+ Response.new(json_response)
21
+ end
22
+ end
23
+
24
+ class Response
25
+ attr_accessor :lines, :summary, :details
26
+ def initialize(json_response)
27
+ @lines = json_response['lines']
28
+ @summary = json_response['summary']
29
+ @details = json_response['details']
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,13 @@
1
+ module ErroneousAPI
2
+ class Fake
3
+ def self.parse_deploy_fail(log_text)
4
+ lines = log_text.split("\n")
5
+ bad_line = lines.detect{|l| l.match(/ERROR/)}
6
+ {
7
+ :lines => [lines.index(bad_line) + 1],
8
+ :summary => "you had ERROR.",
9
+ :details => "retry by doing this thing that takes multiple sentences to descibe. bla. bla.",
10
+ }
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ require 'sinatra/base'
2
+
3
+ module ErroneousAPI
4
+ class Server < Sinatra::Base
5
+ enable :raise_errors
6
+ disable :dump_errors
7
+ disable :show_exceptions
8
+
9
+ class << self
10
+ attr_accessor :mapper
11
+ end
12
+
13
+ post '/parse_deploy_fail' do
14
+ deploy_log = JSON.parse(request.body.read)["deploy_log"]
15
+ content_type :json
16
+ result = Server.mapper.parse_deploy_fail(deploy_log)
17
+ {
18
+ :lines => (result[:lines] or raise "Expected parse_deploy_fail to return which :lines (empty array allowed)").to_a,
19
+ :details => (result[:details] or raise "Expected parse_deploy_fail to return the :details (empty string allowed)"),
20
+ :summary => (result[:summary] or raise "Expected parse_deploy_fail to return the :summary (empty string allowed)")
21
+ }.to_json
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module ErroneousAPI
2
+ VERSION = '0.0.2'
3
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: erroneous-api
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Jacob Burkhart
14
+ - Shai Rosenfeld
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2012-07-31 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: json
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: ey_api_hmac
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ description: "An API Client for the Engine Yard Deploy-Log-Parsing-Service: Erroneous"
50
+ email:
51
+ - cloud-engineering@engineyard.com
52
+ executables: []
53
+
54
+ extensions: []
55
+
56
+ extra_rdoc_files: []
57
+
58
+ files:
59
+ - lib/erroneous-api/client.rb
60
+ - lib/erroneous-api/fake.rb
61
+ - lib/erroneous-api/server.rb
62
+ - lib/erroneous-api/version.rb
63
+ homepage:
64
+ licenses: []
65
+
66
+ post_install_message:
67
+ rdoc_options: []
68
+
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
89
+ requirements: []
90
+
91
+ rubyforge_project:
92
+ rubygems_version: 1.8.24
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: "An API Client for the Engine Yard Deploy-Log-Parsing-Service, code name: \"Erroneous\"."
96
+ test_files: []
97
+