maremma 1.0.2 → 1.0.3
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/lib/maremma.rb +16 -13
- data/lib/maremma/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 60cfbb5e43d24bc0083a8d10b6e3bfa869571627
|
|
4
|
+
data.tar.gz: b070d8060d8bc859446d41ad2b33d618b9d4f3c7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c6492df74c7622ac03b3ccb599ae4d284fdca8a2a33451e4d74bdd9245edee10751ef4eb2fed4b2c2a198d9ef2ce7afdd08345af8f5c71795fc576446702b3d3
|
|
7
|
+
data.tar.gz: 916cbddbd9b8e5eaef90269d0d4635771248fb642ff2eb6c85fd2f6892dd1794c085d4fc8150ee07cb38b5c14f5312e8f519fb6dae306fc1be4305f910a8d037
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -23,7 +23,8 @@ gem install maremma
|
|
|
23
23
|
|
|
24
24
|
## Usage
|
|
25
25
|
```ruby
|
|
26
|
-
Maremma.get
|
|
26
|
+
Maremma.get 'http://dlm.datacite.org/heartbeat' => {"services"=>{"mysql"=>"OK", "memcached"=>"OK", "redis"=>"OK", "sidekiq"=>"OK", "postfix"=>"failed"}, "version"=>"4.3", "status"=>"failed"}
|
|
27
|
+
Maremma.post 'http://example.com', data: { 'foo' => 'baz' }
|
|
27
28
|
```
|
|
28
29
|
|
|
29
30
|
## License
|
data/lib/maremma.rb
CHANGED
|
@@ -19,33 +19,36 @@ NETWORKABLE_EXCEPTIONS = [Faraday::ClientError,
|
|
|
19
19
|
TypeError]
|
|
20
20
|
|
|
21
21
|
module Maremma
|
|
22
|
-
def self.post(url,
|
|
23
|
-
|
|
22
|
+
def self.post(url, options={})
|
|
23
|
+
options[:content_type] ||= 'json'
|
|
24
|
+
options[:data] ||= {}
|
|
25
|
+
options[:headers] ||= {}
|
|
26
|
+
options[:headers]['Host'] = URI.parse(url).host
|
|
27
|
+
|
|
28
|
+
conn = faraday_conn(options[:content_type], options)
|
|
24
29
|
conn = auth_conn(conn, options)
|
|
25
30
|
|
|
26
31
|
conn.options[:timeout] = options[:timeout] || DEFAULT_TIMEOUT
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
response = conn.post url, {}, headers do |request|
|
|
32
|
-
request.body = data
|
|
33
|
+
response = conn.post url, {}, options[:headers] do |request|
|
|
34
|
+
request.body = options[:data]
|
|
33
35
|
end
|
|
34
36
|
parse_response(response.body)
|
|
35
37
|
rescue *NETWORKABLE_EXCEPTIONS => error
|
|
36
38
|
rescue_faraday_error(error)
|
|
37
39
|
end
|
|
38
40
|
|
|
39
|
-
def self.get(url,
|
|
40
|
-
|
|
41
|
+
def self.get(url, options={})
|
|
42
|
+
options[:content_type] ||= 'json'
|
|
43
|
+
options[:headers] ||= {}
|
|
44
|
+
options[:headers]['Host'] = URI.parse(url).host
|
|
45
|
+
|
|
46
|
+
conn = faraday_conn(options[:content_type], options)
|
|
41
47
|
conn = auth_conn(conn, options)
|
|
42
48
|
|
|
43
49
|
conn.options[:timeout] = options[:timeout] || DEFAULT_TIMEOUT
|
|
44
50
|
|
|
45
|
-
|
|
46
|
-
headers['Host'] = URI.parse(url).host
|
|
47
|
-
|
|
48
|
-
response = conn.get url, {}, headers
|
|
51
|
+
response = conn.get url, {}, options[:headers]
|
|
49
52
|
parse_response(response.body)
|
|
50
53
|
rescue *NETWORKABLE_EXCEPTIONS => error
|
|
51
54
|
rescue_faraday_error(error)
|
data/lib/maremma/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: maremma
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Martin Fenner
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-11-
|
|
11
|
+
date: 2015-11-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|