eipiai 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3caaef63d30433d05c9c5dff0b84ca61f641f1b8
4
- data.tar.gz: 274f803c8f29821db1379cfeb87b3ad78642d828
3
+ metadata.gz: 9c5396f773589fbc8a0dfc3703e987cc832894ce
4
+ data.tar.gz: 751a5734b70ee80075fe96cb92850e8f2e385724
5
5
  SHA512:
6
- metadata.gz: cb59e4936e0cfeb9c76e6e86aba56122866a729641c780e08dc5dc6599937fc3dafc24ff02a3071fdbdd869e84330217915b412535b1fa84288c49f2c18f6a67
7
- data.tar.gz: 4e0b204b1adc63678bbd9c2a854f25d3a6f6bcf0c39936486ca722e2e6e8d2da20554a46d3a59fb63b9ed2e026811cfc8ebd2648911a73c89a5012e04ff5952e
6
+ metadata.gz: f9c4ba3fbcb33ed689a47d0877be428800fd6f4323b021a4e999ed57e9691d84657013df9e6467c677f618b7cf6939204e5e0f3903ee618ea2b83dbe72a28761
7
+ data.tar.gz: 3a8e2b999c7d9ff0ce7a377a0c3a7511056f87a267df030cfcc8aa1d1bd5a117dec2bf92a15282ebb19eb69ef1da0323774bec316a80c46731cdb0f19cfdab21
data/CHANGELOG.md CHANGED
@@ -1,12 +1,19 @@
1
1
  # CHANGELOG
2
2
 
3
- ## [unreleased](https://github.com/blendle/eipiai/tree/unreleased) (2016-05-04)
4
- [Full Changelog](https://github.com/blendle/eipiai/compare/v0.7.0...unreleased)
3
+ ## [v0.8.0](https://github.com/blendle/eipiai/tree/v0.8.0) (2016-06-02)
4
+ [Full Changelog](https://github.com/blendle/eipiai/compare/v0.7.0...v0.8.0)
5
5
 
6
6
  **Closed issues:**
7
7
 
8
+ - Add caching headers to `service\_available?` [\#20](https://github.com/blendle/eipiai/issues/20)
8
9
  - make HealthCheck a singleton [\#19](https://github.com/blendle/eipiai/issues/19)
9
10
 
11
+ **Merged pull requests:**
12
+
13
+ - Some more caching tweaks [\#27](https://github.com/blendle/eipiai/pull/27) ([JeanMertz](https://github.com/JeanMertz))
14
+ - Caching headers [\#25](https://github.com/blendle/eipiai/pull/25) ([JeanMertz](https://github.com/JeanMertz))
15
+ - rename/order files more logically [\#24](https://github.com/blendle/eipiai/pull/24) ([JeanMertz](https://github.com/JeanMertz))
16
+
10
17
  ## [v0.7.0](https://github.com/blendle/eipiai/tree/v0.7.0) (2016-05-03)
11
18
  [Full Changelog](https://github.com/blendle/eipiai/compare/v0.6.0...v0.7.0)
12
19
 
@@ -220,7 +220,7 @@ Feature: Working with singular resources (GET, POST, PUT, DELETE)
220
220
  "_errors": [
221
221
  {
222
222
  "id": "InvalidJson",
223
- "message": "invalid json"
223
+ "message": "Invalid json"
224
224
  }
225
225
  ]
226
226
  }
@@ -207,7 +207,7 @@ Feature: Working with singular resources (GET, POST, PUT, DELETE)
207
207
  "_errors": [
208
208
  {
209
209
  "id": "InvalidJson",
210
- "message": "invalid json"
210
+ "message": "Invalid json"
211
211
  }
212
212
  ]
213
213
  }
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ require 'active_support/core_ext/hash/compact'
2
3
  require 'eipiai/representers/base'
3
4
 
4
5
  module Eipiai
@@ -253,9 +253,9 @@ module Eipiai
253
253
  'no-cache, no-store, must-revalidate, private'
254
254
  end
255
255
 
256
- def json_error_body(errors)
256
+ def json_error_body(*errors)
257
257
  response.headers['Content-Type'] = 'application/json'
258
- response.body = FormattedErrors.parse(errors).to_json
258
+ response.body = FormattedErrors.parse(*errors).to_json
259
259
  true
260
260
  end
261
261
 
@@ -7,33 +7,15 @@
7
7
  module FormattedErrors
8
8
  class << self
9
9
  def parse(*errors)
10
- # First check for array, don't switch these lines as the hash is converted to
11
- # an array
12
- errors = errors.flatten(1) if errors.length == 1 && errors.first.is_a?(Array)
13
- errors = errors.first if errors.length == 1 && errors.first.is_a?(Hash)
14
-
15
- errors = errors.map do |key, value|
16
- parse_single(key, **value || {})
17
- end
18
-
19
- { _errors: errors }
10
+ { _errors: errors.map { |e| error(e.respond_to?(:to_a) ? e.to_a.flatten : [e]) } }
20
11
  end
21
12
 
22
13
  private
23
14
 
24
- def parse_single(error, **properties)
25
- {
26
- id: capitalize(error.to_s),
27
- message: humanize(error.to_s)
28
- }.merge(properties)
29
- end
30
-
31
- def capitalize(string)
32
- string.split('_').map(&:capitalize).join
33
- end
15
+ def error(array)
16
+ error, properties = array
34
17
 
35
- def humanize(string)
36
- string.split('_').join(' ').downcase
18
+ { id: error.to_s.tr('.', '_').classify, message: error.to_s.humanize }.merge(properties || {})
37
19
  end
38
20
  end
39
21
  end
@@ -4,5 +4,5 @@
4
4
  # The current version of the Eipiai library.
5
5
  #
6
6
  module Eipiai
7
- VERSION = '0.8.0'
7
+ VERSION = '0.8.1'
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eipiai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Mertz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-02 00:00:00.000000000 Z
11
+ date: 2016-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport