grac 2.5.0 → 3.0.0

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: dc8d442348cefff5c227ad66c293e43c4cba8c60
4
- data.tar.gz: 29c51894a8b8c99fc68647fbca5cd1b5273949cd
3
+ metadata.gz: 916f6671cff0b7712c90a00f6775ee05d4bf8636
4
+ data.tar.gz: 70ffc2800c0c0b936d7d94e80ea6ece0e7e8af9b
5
5
  SHA512:
6
- metadata.gz: 5f28f165b1e1ed3237e70ca6c8e8e89a4c09205ba774218e8ef694a4975e399834396dd6d17cadbbb645f2fe794ecaaea69b3011f39442c7209a1de95c636dc3
7
- data.tar.gz: 828571dfc5a27c87023c86d2cc254194181d25c06c3744ef3f7820870ef03c910a69cc927ffaf717bcf2075c68acc972277880f66d2af8639969efb1300a66c9
6
+ metadata.gz: 49ad9f2608734ff7d75a9bbf0e658c9bc4300ae6aa6a172c511f3c7ffe6f282e06a69fa5e96898f9a228ca4f552417e190b65b0fcff93b6c2418f4be367d5586
7
+ data.tar.gz: 0e2aaa5c0299332ba8c1bebf562a5bed723d4f630b67a3afc7c7da8951dfc9fefa8755a0d9d328e6e181cdd4b48975a665549fdd979fed2610def29135cffd44
data/lib/grac/client.rb CHANGED
@@ -22,29 +22,13 @@ module Grac
22
22
  "User-Agent" => "Grac v#{Grac::VERSION}",
23
23
  "Content-Type" => "application/json;charset=utf-8"
24
24
  }.merge(options[:headers] || {}),
25
- :postprocessing => {},
25
+ :postprocessing => options[:postprocessing] || {},
26
26
  :middleware => options[:middleware] || []
27
27
  }
28
-
29
- if options[:postprocessing]
30
- options[:postprocessing]
31
- .each_with_object(postprocessing = {}) do |(pattern, transformation), obj|
32
- if pattern.kind_of?(Regexp)
33
- obj[pattern] = transformation
34
- else
35
- obj[Regexp.new(pattern)] = transformation
36
- end
37
- end
38
-
39
- @options[:postprocessing] = postprocessing
40
- end
41
-
42
28
  @options.freeze
43
-
44
29
  [:params, :headers, :postprocessing, :middleware].each do |k|
45
30
  @options[k].freeze
46
31
  end
47
-
48
32
  @uri.freeze
49
33
  end
50
34
 
@@ -190,11 +174,12 @@ module Grac
190
174
  if data.kind_of?(Hash)
191
175
  data.each do |key, value|
192
176
  processing = nil
193
- regexp = @options[:postprocessing].keys.detect { |pattern| pattern =~ key }
194
-
195
- if !regexp.nil?
196
- processing = @options[:postprocessing][regexp]
177
+ @options[:postprocessing].each do |regex, action|
178
+ if /#{regex}/ =~ key
179
+ processing = action
180
+ end
197
181
  end
182
+
198
183
  data[key] = postprocessing(value, processing)
199
184
  end
200
185
  elsif data.kind_of?(Array)
@@ -212,7 +197,7 @@ module Grac
212
197
  # We don't want spaces to be encoded as plus sign - a plus sign can be ambiguous in a URL and
213
198
  # either represent a plus sign or a space.
214
199
  # CGI::escape replaces all plus signs with their percent-encoding representation, so all
215
- # remaining plus signs are spaces. Replacing these with a space's percent encoding makes the
200
+ # remaining plus signs are spaces. Replacing these with a space's percent encoding makes the
216
201
  # encoding unambiguous.
217
202
  CGI::escape(value).gsub('+', '%20')
218
203
  end
data/lib/grac/response.rb CHANGED
@@ -1,5 +1,6 @@
1
- require 'oj'
1
+ require 'json'
2
2
  require 'forwardable'
3
+
3
4
  require_relative './exception'
4
5
 
5
6
  module Grac
@@ -25,8 +26,8 @@ module Grac
25
26
  end
26
27
 
27
28
  def parsed_json
28
- Oj.load(body)
29
- rescue Oj::ParseError, EncodingError
29
+ JSON.parse(body)
30
+ rescue JSON::ParserError
30
31
  raise Exception::InvalidContent.new(body, 'json')
31
32
  end
32
33
 
data/lib/grac/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Grac
2
- VERSION = "2.5.0"
2
+ VERSION = "3.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grac
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Schoknecht
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-28 00:00:00.000000000 Z
11
+ date: 2018-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.8'
33
+ version: '3.7'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.8'
40
+ version: '3.7'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: builder
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.2'
55
- - !ruby/object:Gem::Dependency
56
- name: benchmark-ips
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '2.7'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '2.7'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rack-test
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,34 +66,20 @@ dependencies:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
68
  version: '0.7'
83
- - !ruby/object:Gem::Dependency
84
- name: oj
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 3.6.13
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 3.6.13
97
69
  - !ruby/object:Gem::Dependency
98
70
  name: typhoeus
99
71
  requirement: !ruby/object:Gem::Requirement
100
72
  requirements:
101
73
  - - "~>"
102
74
  - !ruby/object:Gem::Version
103
- version: 0.6.9
75
+ version: '1'
104
76
  type: :runtime
105
77
  prerelease: false
106
78
  version_requirements: !ruby/object:Gem::Requirement
107
79
  requirements:
108
80
  - - "~>"
109
81
  - !ruby/object:Gem::Version
110
- version: 0.6.9
82
+ version: '1'
111
83
  description: Generic REST API Client
112
84
  email:
113
85
  - tobias.schoknecht@barzahlen.de
@@ -140,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
112
  version: '0'
141
113
  requirements: []
142
114
  rubyforge_project:
143
- rubygems_version: 2.4.8
115
+ rubygems_version: 2.2.2
144
116
  signing_key:
145
117
  specification_version: 4
146
118
  summary: Very generic client for REST API with basic error handling