my_api_client 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gem_comet.yml +6 -0
- data/.rubocop_todo.yml +1 -1
- data/Gemfile.lock +3 -9
- data/README.jp.md +1 -1
- data/lib/generators/generator_helper.rb +14 -0
- data/lib/generators/rails/USAGE +1 -1
- data/lib/generators/rails/api_client_generator.rb +6 -6
- data/lib/generators/rails/templates/api_client.rb.erb +3 -4
- data/lib/generators/rspec/USAGE +1 -1
- data/lib/generators/rspec/api_client_generator.rb +5 -6
- data/lib/generators/rspec/templates/api_client_spec.rb.erb +1 -2
- data/lib/my_api_client/error_handling.rb +1 -1
- data/lib/my_api_client/params/params.rb +1 -0
- data/lib/my_api_client/version.rb +1 -1
- data/my_api_client.gemspec +0 -1
- metadata +4 -17
- data/bin/release +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cff6147b021565de2bbace815aad8f2f5f46429c206837a1c703474973c3e9e5
|
4
|
+
data.tar.gz: b64a9ecfcdbbe6b9b850650201df5eb36f9ff3c081d5f0426a4eeee03c5bac48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec4a16df9a544a84658a5df6953c0cb141ef8d8867091723fe6a538c5b77fd3ad2da3f0d1afff1eee7eae394692dbc99785d426005196089c181938614c6cb30
|
7
|
+
data.tar.gz: 624c0d500e344920206beeaaecbe9c24f1020850ab0181aca38499d474a7171335a8b4d85ab29317778880b98e052f9d90f4f08fa4a4d85fe915aaf636368d04
|
data/.gem_comet.yml
ADDED
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2019-
|
3
|
+
# on 2019-07-16 23:31:21 +0000 using RuboCop version 0.73.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
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.7.0)
|
5
5
|
activesupport (>= 4.2.0)
|
6
6
|
jsonpath
|
7
7
|
sawyer
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
docile (1.3.2)
|
29
29
|
faraday (0.15.4)
|
30
30
|
multipart-post (>= 1.2, < 3)
|
31
|
-
hashdiff (0.
|
31
|
+
hashdiff (1.0.0)
|
32
32
|
i18n (1.6.0)
|
33
33
|
concurrent-ruby (~> 1.0)
|
34
34
|
jaro_winkler (1.5.3)
|
@@ -40,14 +40,9 @@ GEM
|
|
40
40
|
minitest (5.11.3)
|
41
41
|
multi_json (1.13.1)
|
42
42
|
multipart-post (2.1.1)
|
43
|
-
octokit (4.14.0)
|
44
|
-
sawyer (~> 0.8.0, >= 0.5.3)
|
45
43
|
parallel (1.17.0)
|
46
44
|
parser (2.6.3.0)
|
47
45
|
ast (~> 2.4.0)
|
48
|
-
pr_comet (0.2.0)
|
49
|
-
octokit
|
50
|
-
rainbow
|
51
46
|
pry (0.12.2)
|
52
47
|
coderay (~> 1.1.0)
|
53
48
|
method_source (~> 0.9.0)
|
@@ -72,7 +67,7 @@ GEM
|
|
72
67
|
rspec-support (3.8.2)
|
73
68
|
rspec_junit_formatter (0.4.1)
|
74
69
|
rspec-core (>= 2, < 4, != 2.12.0)
|
75
|
-
rubocop (0.
|
70
|
+
rubocop (0.73.0)
|
76
71
|
jaro_winkler (~> 1.5.1)
|
77
72
|
parallel (~> 1.10)
|
78
73
|
parser (>= 2.6)
|
@@ -111,7 +106,6 @@ DEPENDENCIES
|
|
111
106
|
bugsnag (>= 6.11.0)
|
112
107
|
bundler (~> 1.16)
|
113
108
|
my_api_client!
|
114
|
-
pr_comet
|
115
109
|
pry-byebug
|
116
110
|
rake (~> 10.0)
|
117
111
|
rspec
|
data/README.jp.md
CHANGED
@@ -24,7 +24,7 @@ gem 'my_api_client'
|
|
24
24
|
Ruby on Rails を利用している場合は `generator` 機能を利用できます。
|
25
25
|
|
26
26
|
```sh
|
27
|
-
$ rails g api_client path/to/resource
|
27
|
+
$ rails g api_client path/to/resource get:path/to/resource
|
28
28
|
|
29
29
|
create app/api_clients/application_api_client.rb
|
30
30
|
create app/api_clients/path/to/resource_api_client.rb
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MyApiClient
|
4
|
+
# The helper module for source generators
|
5
|
+
module GeneratorHelper
|
6
|
+
def yeild_request_arguments
|
7
|
+
requests.each do |request|
|
8
|
+
http_method, pathname = request.split(':')
|
9
|
+
action = "#{http_method}_#{pathname.tr('/', '_')}"
|
10
|
+
yield action, http_method, pathname
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/generators/rails/USAGE
CHANGED
@@ -2,7 +2,7 @@ Description:
|
|
2
2
|
Generate a new api client class files.
|
3
3
|
|
4
4
|
Example:
|
5
|
-
`rails g api_client path/to/resource
|
5
|
+
`rails g api_client path/to/resource get:path/to/resource`
|
6
6
|
|
7
7
|
This will create:
|
8
8
|
create app/api_clients/application_api_client.rb
|
@@ -1,19 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../generator_helper'
|
4
|
+
|
3
5
|
module Rails
|
4
6
|
# rails g api_client
|
5
7
|
class ApiClientGenerator < Rails::Generators::NamedBase
|
8
|
+
include MyApiClient::GeneratorHelper
|
9
|
+
|
6
10
|
source_root File.expand_path('templates', __dir__)
|
7
11
|
check_class_collision suffix: 'ApiClient'
|
8
12
|
|
9
|
-
argument :endpoint,
|
10
|
-
type: :string,
|
11
|
-
default: 'https://example.com',
|
12
|
-
banner: '{schema and hostname}'
|
13
13
|
argument :requests,
|
14
14
|
type: :array,
|
15
|
-
default: %w[
|
16
|
-
banner: '{
|
15
|
+
default: %w[get:path/to/resource post:path/to/resource],
|
16
|
+
banner: '{method}:{path} {method}:{path}'
|
17
17
|
|
18
18
|
def generate_root_class
|
19
19
|
file_path = File.join('app/api_clients', 'application_api_client.rb')
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class <%= "#{class_name}ApiClient" %> < ::ApplicationApiClient
|
4
|
-
endpoint '
|
4
|
+
endpoint '{ endpoint }'
|
5
5
|
|
6
6
|
# error_handling json: { '$.errors.code': 10 } do |params, logger|
|
7
7
|
# # Behavior when detected an error.
|
@@ -10,9 +10,8 @@ class <%= "#{class_name}ApiClient" %> < ::ApplicationApiClient
|
|
10
10
|
def initialize
|
11
11
|
end
|
12
12
|
|
13
|
-
<%
|
14
|
-
|
15
|
-
# <%= "#{http_method.upcase} #{endpoint}/#{pathname}" %>
|
13
|
+
<% yeild_request_arguments do |action, http_method, pathname| -%>
|
14
|
+
# <%= "#{http_method.upcase} #{pathname}" %>
|
16
15
|
#
|
17
16
|
# @return [Sawyer::Resource] Description of the API response
|
18
17
|
# @raise [MyApiClient::Error] Description of the error
|
data/lib/generators/rspec/USAGE
CHANGED
@@ -2,7 +2,7 @@ Description:
|
|
2
2
|
Generate a new api client spec files.
|
3
3
|
|
4
4
|
Example:
|
5
|
-
rails g rspec:api_client path/to/resource
|
5
|
+
rails g rspec:api_client path/to/resource get:path/to/resource`
|
6
6
|
|
7
7
|
This will create:
|
8
8
|
create spec/api_clients/path/to/resource_api_client_spec.rb
|
@@ -1,21 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'generators/rspec'
|
4
|
+
require_relative '../generator_helper'
|
4
5
|
|
5
6
|
module Rspec
|
6
7
|
module Generators
|
7
8
|
# rails g rspec:api_client
|
8
9
|
class ApiClientGenerator < Base
|
10
|
+
include MyApiClient::GeneratorHelper
|
11
|
+
|
9
12
|
source_root File.expand_path('templates', __dir__)
|
10
13
|
|
11
|
-
argument :endpoint,
|
12
|
-
type: :string,
|
13
|
-
default: 'https://example.com',
|
14
|
-
banner: '{schema and hostname}'
|
15
14
|
argument :requests,
|
16
15
|
type: :array,
|
17
|
-
default: %w[
|
18
|
-
banner: '{
|
16
|
+
default: %w[get:path/to/resource post:path/to/resource],
|
17
|
+
banner: '{method}:{path} {method}:{path}'
|
19
18
|
|
20
19
|
class_option :api_client_specs, type: :boolean, default: true
|
21
20
|
|
@@ -5,8 +5,7 @@ require 'rails_helper'
|
|
5
5
|
RSpec.describe <%= "#{class_name}ApiClient" %>, <%= type_metatag(:api_client) %> do
|
6
6
|
let(:api_client) { described_class.new }
|
7
7
|
|
8
|
-
<%
|
9
|
-
<% action, http_method, pathname = request.split(':') -%>
|
8
|
+
<% yeild_request_arguments do |action, http_method, pathname| -%>
|
10
9
|
describe '#<%= action %>' do
|
11
10
|
end
|
12
11
|
<% end -%>
|
data/my_api_client.gemspec
CHANGED
@@ -27,7 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_dependency 'sawyer'
|
28
28
|
|
29
29
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
30
|
-
spec.add_development_dependency 'pr_comet'
|
31
30
|
spec.add_development_dependency 'pry-byebug'
|
32
31
|
spec.add_development_dependency 'rake', '~> 10.0'
|
33
32
|
spec.add_development_dependency 'rspec'
|
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.7.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-07-
|
11
|
+
date: 2019-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.16'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pr_comet
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: pry-byebug
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -229,6 +215,7 @@ extra_rdoc_files: []
|
|
229
215
|
files:
|
230
216
|
- ".circleci/config.yml"
|
231
217
|
- ".envrc.skeleton"
|
218
|
+
- ".gem_comet.yml"
|
232
219
|
- ".gitignore"
|
233
220
|
- ".rspec"
|
234
221
|
- ".rubocop.yml"
|
@@ -241,12 +228,12 @@ files:
|
|
241
228
|
- README.md
|
242
229
|
- Rakefile
|
243
230
|
- bin/console
|
244
|
-
- bin/release
|
245
231
|
- bin/setup
|
246
232
|
- gemfiles/rails_4.2.gemfile
|
247
233
|
- gemfiles/rails_5.0.gemfile
|
248
234
|
- gemfiles/rails_5.1.gemfile
|
249
235
|
- gemfiles/rails_5.2.gemfile
|
236
|
+
- lib/generators/generator_helper.rb
|
250
237
|
- lib/generators/rails/USAGE
|
251
238
|
- lib/generators/rails/api_client_generator.rb
|
252
239
|
- lib/generators/rails/templates/api_client.rb.erb
|
data/bin/release
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
# usage: bin/release VERSION
|
5
|
-
|
6
|
-
require 'bundler/setup'
|
7
|
-
require 'pr_comet'
|
8
|
-
|
9
|
-
VERSION_FORMAT = /\A\d+\.\d+\.\d+(\.(pre|beta|rc)\d?)?\z/.freeze
|
10
|
-
version = ARGV[0]
|
11
|
-
pr_comet = PrComet.new(base: 'master', branch: "update/v#{version}")
|
12
|
-
|
13
|
-
# Verifying
|
14
|
-
abort 'usage: bin/release VERSION' if version.nil?
|
15
|
-
abort 'A version must be like a `1.2.3`' unless version =~ VERSION_FORMAT
|
16
|
-
|
17
|
-
# Modify a version file
|
18
|
-
pr_comet.commit ':comet: Update version' do
|
19
|
-
File.write('lib/my_api_client/version.rb', <<~VERSION)
|
20
|
-
# frozen_string_literal: true
|
21
|
-
|
22
|
-
module MyApiClient
|
23
|
-
VERSION = '#{version}'
|
24
|
-
end
|
25
|
-
VERSION
|
26
|
-
end
|
27
|
-
|
28
|
-
# Bundle Update
|
29
|
-
pr_comet.commit ':comet: Run $ bundle update' do
|
30
|
-
`bundle update`
|
31
|
-
end
|
32
|
-
|
33
|
-
# Create a pull request
|
34
|
-
pr_comet.create!(title: "Update v#{version}", body: '')
|