offshore 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/offshore/client/host.rb +8 -5
- data/lib/offshore/server/middleware.rb +17 -6
- data/lib/offshore/server/snapshot.rb +1 -1
- data/lib/offshore/version.rb +1 -1
- data/lib/offshore.rb +12 -0
- metadata +2 -2
data/lib/offshore/client/host.rb
CHANGED
@@ -21,8 +21,8 @@ module Offshore
|
|
21
21
|
def base_uri
|
22
22
|
with_http = host
|
23
23
|
with_http = "http://#{host}" unless (host =~ /^https?:/) == 0
|
24
|
-
|
25
|
-
"#{with_http}
|
24
|
+
with_http << ":#{port}" if port
|
25
|
+
"#{with_http}"
|
26
26
|
end
|
27
27
|
|
28
28
|
def connection
|
@@ -30,7 +30,10 @@ module Offshore
|
|
30
30
|
connection_class = Faraday.respond_to?(:new) ? ::Faraday : ::Faraday::Connection
|
31
31
|
|
32
32
|
timeout_seconds = 5*60 # 5 minutes
|
33
|
-
|
33
|
+
options = {:timeout => timeout_seconds}
|
34
|
+
options[:ssl] = {:verify => false}
|
35
|
+
|
36
|
+
@connection = connection_class.new(base_uri, options) do |builder|
|
34
37
|
builder.use Faraday::Request::UrlEncoded if defined?(Faraday::Request::UrlEncoded)
|
35
38
|
builder.adapter Faraday.default_adapter
|
36
39
|
end
|
@@ -49,9 +52,9 @@ module Offshore
|
|
49
52
|
else
|
50
53
|
begin
|
51
54
|
hash = MultiJson.decode(http_response.body)
|
52
|
-
message = "Error in offshore connection (#{append_path}): #{hash}"
|
55
|
+
message = "Error in offshore connection (#{append_path}): #{http_response.status},\n#{hash}"
|
53
56
|
rescue
|
54
|
-
message = "Error in offshore connection (#{append_path}): #{http_response.status}"
|
57
|
+
message = "Error in offshore connection (#{append_path}): #{http_response.status}\n#{hash}"
|
55
58
|
end
|
56
59
|
raise message
|
57
60
|
end
|
@@ -5,13 +5,13 @@ module Offshore
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def init_server
|
8
|
-
Offshore::Database.init # has
|
8
|
+
Offshore::Database.init # has its own singleton code
|
9
9
|
end
|
10
10
|
|
11
11
|
def init_thread
|
12
12
|
return if @init_thread
|
13
13
|
@init_thread = true
|
14
|
-
|
14
|
+
|
15
15
|
# TODO: move this to a config block
|
16
16
|
if defined?(Rails)
|
17
17
|
begin
|
@@ -29,20 +29,31 @@ module Offshore
|
|
29
29
|
|
30
30
|
|
31
31
|
def call(env)
|
32
|
-
if (env
|
33
|
-
offshore_call(
|
32
|
+
if offshore_request?(env)
|
33
|
+
offshore_call(env)
|
34
34
|
else
|
35
35
|
@app.call(env)
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
def offshore_request?(env)
|
40
|
+
return false unless Offshore.enabled?
|
41
|
+
!!offshore_method(env)
|
42
|
+
end
|
43
|
+
|
44
|
+
def offshore_method(env)
|
45
|
+
env["PATH_INFO"] =~ /^\/offshore_tests\/(.*)/
|
46
|
+
$1
|
47
|
+
end
|
38
48
|
|
39
|
-
def offshore_call(
|
49
|
+
def offshore_call(env)
|
40
50
|
status = 500
|
41
51
|
headers = {}
|
52
|
+
method = offshore_method(env)
|
42
53
|
hash = {"error" => "Unknown method: #{method}"}
|
43
54
|
|
44
55
|
Logger.info("Offshore Tests Action: #{method}")
|
45
|
-
|
56
|
+
|
46
57
|
begin
|
47
58
|
case method
|
48
59
|
when "factory_create", "suite_start", "suite_stop", "test_start", "test_stop"
|
@@ -12,7 +12,7 @@ module Offshore
|
|
12
12
|
raise "Only supported in Rails for now" unless defined?(Rails)
|
13
13
|
|
14
14
|
yml = Rails.root.join("config", "database.yml")
|
15
|
-
hash = YAML.load(ERB.new(File.read(yml)).result)[
|
15
|
+
hash = YAML.load(ERB.new(File.read(yml)).result)['test']
|
16
16
|
|
17
17
|
@config = {}
|
18
18
|
['username', 'password', 'host', 'port', 'database', 'collation', 'charset'].each do |key|
|
data/lib/offshore/version.rb
CHANGED
data/lib/offshore.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: offshore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
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: 2013-
|
12
|
+
date: 2013-02-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|