my_api_client 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +35 -35
- data/Gemfile.lock +2 -2
- data/lib/my_api_client/error_handling.rb +1 -1
- data/lib/my_api_client/errors.rb +1 -0
- data/lib/my_api_client/params/params.rb +43 -0
- data/lib/my_api_client/params/request.rb +23 -0
- data/lib/my_api_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb13e4cf8d1a3d9b3a1bbb5154b695493384c1d94377d8260f0ababa59d42c55
|
4
|
+
data.tar.gz: 52df7eb8caa4ad533ce6130078da94da6ff59924efbb5f52c441225114c03fcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b073a7464c97c5d2b9181cb0ed5e1de4296a808a0668d3bb9bf1357f4bad591a24c30ff7935e88383a934fe6867bca86878b673ca51898678ec057e36404413d
|
7
|
+
data.tar.gz: 7bba09a981e3e71a5de194a84cae6fb19cafa3631b283e1f778072837a354db67b555d80f13329b8895496de886393494155427ad0a8050d97b9a36b61171015
|
data/.circleci/config.yml
CHANGED
@@ -4,12 +4,22 @@
|
|
4
4
|
#
|
5
5
|
version: 2.1
|
6
6
|
|
7
|
+
references:
|
8
|
+
- &ruby_version
|
9
|
+
ruby_version:
|
10
|
+
type: enum
|
11
|
+
enum: ['2.4', '2.5', '2.6']
|
12
|
+
default: '2.4'
|
13
|
+
- &rails_version
|
14
|
+
rails_version:
|
15
|
+
type: enum
|
16
|
+
enum: ['4.2', '5.0', '5.1', '5.2']
|
17
|
+
default: '4.2'
|
18
|
+
|
7
19
|
executors:
|
8
20
|
default:
|
9
21
|
parameters:
|
10
|
-
ruby_version
|
11
|
-
type: enum
|
12
|
-
enum: ['2.4', '2.5', '2.6']
|
22
|
+
<<: *ruby_version
|
13
23
|
docker:
|
14
24
|
- image: circleci/ruby:<< parameters.ruby_version >>-node-browsers
|
15
25
|
working_directory: ~/repo
|
@@ -25,26 +35,28 @@ commands:
|
|
25
35
|
setup_bundle:
|
26
36
|
description: Setup Bundle
|
27
37
|
parameters:
|
28
|
-
|
29
|
-
type: string
|
38
|
+
<<: *ruby_version
|
30
39
|
steps:
|
31
40
|
- restore_cache:
|
32
41
|
keys:
|
33
|
-
- v1-dependencies
|
42
|
+
- v1-dependencies-<< parameters.ruby_version >>-{{ checksum "Gemfile.lock" }}
|
34
43
|
- v1-dependencies-
|
35
44
|
- run:
|
36
45
|
name: Bundle Install
|
37
46
|
command: |
|
38
47
|
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
39
|
-
- run:
|
40
|
-
name: Modify ActiveSupport Version
|
41
|
-
command: |
|
42
|
-
cp gemfiles/rails_<< parameters.rails_version >>.gemfile Gemfile
|
43
|
-
bundle update activesupport
|
44
48
|
- save_cache:
|
45
49
|
paths:
|
46
50
|
- ./vendor/bundle
|
47
|
-
key: v1-dependencies
|
51
|
+
key: v1-dependencies-<< parameters.ruby_version >>-{{ checksum "Gemfile.lock" }}
|
52
|
+
modify_active_support_version:
|
53
|
+
description: Modify ActiveSupport Version
|
54
|
+
parameters:
|
55
|
+
<<: *rails_version
|
56
|
+
steps:
|
57
|
+
- run: |
|
58
|
+
cp gemfiles/rails_<< parameters.rails_version >>.gemfile Gemfile
|
59
|
+
bundle update activesupport
|
48
60
|
run_rspec:
|
49
61
|
description: 'Run RSpec'
|
50
62
|
steps:
|
@@ -104,22 +116,20 @@ commands:
|
|
104
116
|
bundle exec rake release --trace
|
105
117
|
setup:
|
106
118
|
description: Setup for Job Working
|
107
|
-
parameters:
|
108
|
-
rails_version:
|
109
|
-
type: string
|
110
119
|
steps:
|
111
120
|
- checkout
|
112
|
-
- setup_bundle
|
113
|
-
rails_version: << parameters.rails_version >>
|
121
|
+
- setup_bundle
|
114
122
|
build:
|
115
123
|
description: Build the RubyGem
|
116
124
|
parameters:
|
117
|
-
|
118
|
-
|
125
|
+
<<: *ruby_version
|
126
|
+
<<: *rails_version
|
119
127
|
steps:
|
120
128
|
- checkout
|
121
129
|
- download_cc_test_reporter
|
122
130
|
- setup_bundle:
|
131
|
+
ruby_version: << parameters.ruby_version >>
|
132
|
+
- modify_active_support_version:
|
123
133
|
rails_version: << parameters.rails_version >>
|
124
134
|
- run_rspec
|
125
135
|
- rake_build
|
@@ -127,47 +137,37 @@ commands:
|
|
127
137
|
jobs:
|
128
138
|
build:
|
129
139
|
parameters:
|
130
|
-
ruby_version
|
131
|
-
|
132
|
-
enum: ['2.4', '2.5', '2.6']
|
133
|
-
rails_version:
|
134
|
-
type: enum
|
135
|
-
enum: ['4.2', '5.0', '5.1', '5.2']
|
140
|
+
<<: *ruby_version
|
141
|
+
<<: *rails_version
|
136
142
|
executor:
|
137
143
|
name: default
|
138
144
|
ruby_version: << parameters.ruby_version >>
|
139
145
|
steps:
|
140
146
|
- build:
|
147
|
+
ruby_version: << parameters.ruby_version >>
|
141
148
|
rails_version: << parameters.rails_version >>
|
142
149
|
rubocop:
|
143
150
|
executor:
|
144
151
|
name: default
|
145
|
-
ruby_version: '2.4'
|
146
152
|
steps:
|
147
|
-
- setup
|
148
|
-
rails_version: '4.2'
|
153
|
+
- setup
|
149
154
|
- rubocop
|
150
155
|
yardoc:
|
151
156
|
executor:
|
152
157
|
name: default
|
153
|
-
ruby_version: '2.4'
|
154
158
|
steps:
|
155
|
-
- setup
|
156
|
-
rails_version: '4.2'
|
159
|
+
- setup
|
157
160
|
- yardoc
|
158
161
|
rubocop_challenge:
|
159
162
|
executor:
|
160
163
|
name: default
|
161
|
-
ruby_version: '2.4'
|
162
164
|
steps:
|
163
165
|
- rubocop_challenge
|
164
166
|
release:
|
165
167
|
executor:
|
166
168
|
name: default
|
167
|
-
ruby_version: '2.4'
|
168
169
|
steps:
|
169
|
-
- setup
|
170
|
-
rails_version: '5.2'
|
170
|
+
- setup
|
171
171
|
- release
|
172
172
|
|
173
173
|
workflows:
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
my_api_client (0.
|
4
|
+
my_api_client (0.2.0)
|
5
5
|
activesupport (>= 4.2.0)
|
6
6
|
jsonpath
|
7
7
|
sawyer
|
@@ -26,7 +26,7 @@ GEM
|
|
26
26
|
docile (1.3.1)
|
27
27
|
faraday (0.15.4)
|
28
28
|
multipart-post (>= 1.2, < 3)
|
29
|
-
hashdiff (0.
|
29
|
+
hashdiff (0.4.0)
|
30
30
|
i18n (1.6.0)
|
31
31
|
concurrent-ruby (~> 1.0)
|
32
32
|
jaro_winkler (1.5.2)
|
data/lib/my_api_client/errors.rb
CHANGED
@@ -15,12 +15,55 @@ module MyApiClient
|
|
15
15
|
@response = response
|
16
16
|
end
|
17
17
|
|
18
|
+
# Generate metadata for bugsnag.
|
19
|
+
# It will integrate request and response params.
|
20
|
+
# Blank parameter will be omitted.
|
21
|
+
#
|
22
|
+
# @return [Hash] Metadata for bugsnag
|
23
|
+
def to_bugsnag
|
24
|
+
request_metadata.merge(response_metadata)
|
25
|
+
end
|
26
|
+
|
18
27
|
# Returns contents as string for to be readable for human
|
19
28
|
#
|
20
29
|
# @return [String] Contents as string
|
21
30
|
def inspect
|
22
31
|
{ request: request, response: response }.inspect
|
23
32
|
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# Generate metadata from request params.
|
37
|
+
# It will be added prefix "request_".
|
38
|
+
#
|
39
|
+
# @return [Hash] Metadata for bugsnag
|
40
|
+
def request_metadata
|
41
|
+
if request.present?
|
42
|
+
request.to_bugsnag.each_with_object({}) do |(key, value), memo|
|
43
|
+
memo[:"request_#{key}"] = value
|
44
|
+
end
|
45
|
+
else
|
46
|
+
{}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Generate metadata from response params.
|
51
|
+
# It will be added prefix "response_".
|
52
|
+
#
|
53
|
+
# @return [Hash] Metadata for bugsnag
|
54
|
+
def response_metadata
|
55
|
+
if response.present?
|
56
|
+
data = response.data
|
57
|
+
body = data.respond_to?(:to_h) ? data.to_h : data
|
58
|
+
{
|
59
|
+
response_status: response.status,
|
60
|
+
response_headers: response.headers,
|
61
|
+
response_body: body,
|
62
|
+
}.compact
|
63
|
+
else
|
64
|
+
{}
|
65
|
+
end
|
66
|
+
end
|
24
67
|
end
|
25
68
|
end
|
26
69
|
end
|
@@ -6,6 +6,13 @@ module MyApiClient
|
|
6
6
|
class Request
|
7
7
|
attr_reader :method, :pathname, :headers, :query, :body
|
8
8
|
|
9
|
+
# Description of #initialize
|
10
|
+
#
|
11
|
+
# @param method [Symbol] describe_method_here
|
12
|
+
# @param pathname [String] describe_pathname_here
|
13
|
+
# @param headers [Hash, nil] describe_headers_here
|
14
|
+
# @param query [Hash, nil] describe_query_here
|
15
|
+
# @param body [Hash, nil] describe_body_here
|
9
16
|
def initialize(method, pathname, headers, query, body)
|
10
17
|
@method = method
|
11
18
|
@pathname = pathname
|
@@ -14,10 +21,26 @@ module MyApiClient
|
|
14
21
|
@body = body
|
15
22
|
end
|
16
23
|
|
24
|
+
# Description of #to_sawyer_args
|
25
|
+
#
|
26
|
+
# @return [Array<Object>] Arguments for Sawyer::Agent#call
|
17
27
|
def to_sawyer_args
|
18
28
|
[method, pathname, body, { headers: headers, query: query }]
|
19
29
|
end
|
20
30
|
|
31
|
+
# Generate metadata for bugsnag.
|
32
|
+
# Blank parameter will be omitted.
|
33
|
+
#
|
34
|
+
# @return [Hash] Metadata for bugsnag
|
35
|
+
def to_bugsnag
|
36
|
+
{
|
37
|
+
line: "#{method.upcase} #{pathname}",
|
38
|
+
headers: headers,
|
39
|
+
query: query,
|
40
|
+
body: body,
|
41
|
+
}.compact
|
42
|
+
end
|
43
|
+
|
21
44
|
# Returns contents as string for to be readable for human
|
22
45
|
#
|
23
46
|
# @return [String] Contents as string
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ryz310
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|