ocean-rails 2.6.1 → 2.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ocean/api.rb +57 -57
- data/lib/ocean/version.rb +1 -1
- metadata +29 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70bf4729704338768d5f743d77131a57a3b5f727
|
4
|
+
data.tar.gz: 230ebe6ac4905c2ee3439fd2adc04a7561779847
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 679ce12c6732acf220721832b9ce61b6688f87533b9607f83c268a7d2648d5488714d963283856edff99564547db87a64f7a9c4c90786ea2aa378e95a4ff5a9f
|
7
|
+
data.tar.gz: edae51c49986ccf4e2533acad819fdbab3673e9baafb15c4b626c64f1e4a7958d23d10a7b70eff41239782c239d05190edd4b1f4f883e9e72bc77f44cf0c9cdf
|
data/lib/ocean/api.rb
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
1
|
+
#
|
2
|
+
# We need to monkey-patch Faraday to pull off PURGE and BAN
|
3
|
+
#
|
4
|
+
require 'faraday'
|
5
|
+
require 'faraday_middleware'
|
6
|
+
|
7
|
+
module Faraday #:nodoc: all
|
8
|
+
class Connection
|
9
|
+
|
10
|
+
METHODS << :purge
|
11
|
+
METHODS << :ban
|
12
|
+
|
13
|
+
# purge/ban(url, params, headers)
|
14
|
+
%w[purge ban].each do |method|
|
15
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
16
|
+
def #{method}(url = nil, params = nil, headers = nil)
|
17
|
+
run_request(:#{method}, url, nil, headers) { |request|
|
18
|
+
request.params.update(params) if params
|
19
|
+
yield request if block_given?
|
20
|
+
}
|
21
|
+
end
|
22
|
+
RUBY
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
27
|
|
28
28
|
require 'typhoeus'
|
29
29
|
|
@@ -119,37 +119,37 @@ class Api
|
|
119
119
|
# Returns the response in its entirety so that the caller can examine its status and body.
|
120
120
|
#
|
121
121
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
def self.call(host_url, http_method, resource_name, path, args_or_body={}, headers={})
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
end
|
122
|
+
def self.call(host_url, http_method, resource_name, path, args={}, headers={})
|
123
|
+
# Set up the connection parameters
|
124
|
+
conn = Faraday.new(host_url) do |c|
|
125
|
+
c.response :json, :content_type => /\bjson$/ # Convert the response body to JSON
|
126
|
+
c.adapter Faraday.default_adapter # Use net-http
|
127
|
+
end
|
128
|
+
api_version = version_for resource_name
|
129
|
+
path = "/#{api_version}#{path}"
|
130
|
+
# Make the call. TODO: retries?
|
131
|
+
response = conn.send(http_method, path, args, headers) do |request|
|
132
|
+
request.headers['Accept'] = 'application/json'
|
133
|
+
request.headers['Content-Type'] = 'application/json'
|
134
|
+
end
|
135
|
+
response
|
136
|
+
end
|
137
|
+
|
138
|
+
# def self.call(host_url, http_method, resource_name, path, args_or_body={}, headers={})
|
139
|
+
# # Set up the request
|
140
|
+
# url = "#{host_url}/#{version_for resource_name}#{path}"
|
141
|
+
# headers['Accept'] = "application/json"
|
142
|
+
# headers['Content-Type'] = "application/json"
|
143
|
+
# headers['User-Agent'] = "Ocean"
|
144
|
+
# request = Typhoeus::Request.new(url, method: http_method, headers: headers,
|
145
|
+
# params: args_or_body.is_a?(String) ? nil : args_or_body,
|
146
|
+
# body: args_or_body.is_a?(String) ? args_or_body : nil
|
147
|
+
# )
|
148
|
+
# # Run it
|
149
|
+
# response = request.run
|
150
|
+
# # Return the response
|
151
|
+
# Response.new(response)
|
152
|
+
# end
|
153
153
|
|
154
154
|
#
|
155
155
|
# Convenience method to make an internal +GET+ request to the Ocean Api. The +resource_name+
|
data/lib/ocean/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ocean-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Bengtson
|
@@ -10,6 +10,34 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2014-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: typhoeus
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|