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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49610599e5a78ccf1f77a901315904dccd78bca7
4
- data.tar.gz: 7bbb1504d73a9e7c3d448240ca42f440c3f5f14d
3
+ metadata.gz: 60cfbb5e43d24bc0083a8d10b6e3bfa869571627
4
+ data.tar.gz: b070d8060d8bc859446d41ad2b33d618b9d4f3c7
5
5
  SHA512:
6
- metadata.gz: 5efeb18cad885f699ac5dce945f3681f4b0b185d1935c8b0b130d62082bd6ab4c4b786a4c540b38ef880289c95b89090221f5aa181b2273fe0edfec43d4bf422
7
- data.tar.gz: 8ef207e5e8195dc9dc992267373b13f95d9ee68aaef61c7e86275126eb6dcba953d8662cf2e51ae52ddfd908d312f292723d1e2443da5d6022ec0503b5867ed7
6
+ metadata.gz: c6492df74c7622ac03b3ccb599ae4d284fdca8a2a33451e4d74bdd9245edee10751ef4eb2fed4b2c2a198d9ef2ce7afdd08345af8f5c71795fc576446702b3d3
7
+ data.tar.gz: 916cbddbd9b8e5eaef90269d0d4635771248fb642ff2eb6c85fd2f6892dd1794c085d4fc8150ee07cb38b5c14f5312e8f519fb6dae306fc1be4305f910a8d037
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maremma (1.0.1)
4
+ maremma (1.0.2)
5
5
  activesupport (~> 4.2, >= 4.2.5)
6
6
  builder (~> 3.2, >= 3.2.2)
7
7
  excon (~> 0.45.0)
data/README.md CHANGED
@@ -23,7 +23,8 @@ gem install maremma
23
23
 
24
24
  ## Usage
25
25
  ```ruby
26
- Maremma.get(url)
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, content_type: 'json', data: {}, headers: {}, **options)
23
- conn = faraday_conn(content_type, options)
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
- # make sure we use a 'Host' header
29
- headers['Host'] = URI.parse(url).host
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, content_type: 'json', headers: {}, **options)
40
- conn = faraday_conn(content_type, options)
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
- # make sure we use a 'Host' header
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)
@@ -1,3 +1,3 @@
1
1
  module Maremma
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
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.2
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-28 00:00:00.000000000 Z
11
+ date: 2015-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday