my_api_client 0.15.0 → 0.19.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 +169 -95
- data/.dependabot/config.yml +2 -5
- data/.rubocop.yml +5 -1
- data/.rubocop_challenge.yml +1 -0
- data/.rubocop_todo.yml +53 -1
- data/CHANGELOG.md +171 -0
- data/Gemfile +0 -3
- data/Gemfile.lock +70 -64
- data/README.jp.md +97 -24
- data/bin/console +4 -0
- data/example/api_clients/application_api_client.rb +2 -10
- data/example/api_clients/my_rest_api_client.rb +9 -3
- data/gemfiles/{rails_4.2.gemfile → rails_6.1.gemfile} +1 -1
- data/lib/generators/rails/USAGE +1 -1
- data/lib/generators/rails/api_client_generator.rb +6 -0
- data/lib/generators/rails/templates/api_client.rb.erb +1 -1
- data/lib/generators/rails/templates/application_api_client.rb.erb +0 -11
- data/lib/generators/rspec/USAGE +1 -1
- data/lib/generators/rspec/api_client_generator.rb +6 -0
- data/lib/generators/rspec/templates/api_client_spec.rb.erb +23 -16
- data/lib/my_api_client.rb +5 -0
- data/lib/my_api_client/base.rb +4 -9
- data/lib/my_api_client/default_error_handlers.rb +64 -0
- data/lib/my_api_client/error_handling.rb +3 -4
- data/lib/my_api_client/error_handling/generator.rb +23 -7
- data/lib/my_api_client/errors.rb +1 -53
- data/lib/my_api_client/errors/api_limit_error.rb +6 -0
- data/lib/my_api_client/errors/client_error.rb +93 -0
- data/lib/my_api_client/errors/network_error.rb +43 -0
- data/lib/my_api_client/errors/server_error.rb +42 -0
- data/lib/my_api_client/params/params.rb +1 -3
- data/lib/my_api_client/request.rb +2 -2
- data/lib/my_api_client/request/basic.rb +1 -3
- data/lib/my_api_client/request/executor.rb +1 -1
- data/lib/my_api_client/version.rb +1 -1
- data/my_api/Gemfile.lock +89 -87
- data/my_api/app/controllers/pagination_controller.rb +1 -1
- data/my_api/spec/controllers/rest_controller_spec.rb +23 -5
- data/my_api_client.gemspec +2 -2
- data/rails_app/rails_5.2/.rspec +3 -0
- data/rails_app/rails_5.2/Gemfile +17 -0
- data/rails_app/rails_5.2/Gemfile.lock +174 -0
- data/rails_app/rails_5.2/README.md +24 -0
- data/rails_app/rails_5.2/Rakefile +8 -0
- data/rails_app/rails_5.2/app/controllers/application_controller.rb +4 -0
- data/rails_app/rails_5.2/app/jobs/application_job.rb +4 -0
- data/rails_app/rails_5.2/bin/bundle +5 -0
- data/rails_app/rails_5.2/bin/rails +6 -0
- data/rails_app/rails_5.2/bin/rake +6 -0
- data/rails_app/rails_5.2/bin/setup +27 -0
- data/rails_app/rails_5.2/bin/update +27 -0
- data/rails_app/rails_5.2/config.ru +7 -0
- data/rails_app/rails_5.2/config/application.rb +37 -0
- data/rails_app/rails_5.2/config/boot.rb +6 -0
- data/rails_app/rails_5.2/config/credentials.yml.enc +1 -0
- data/rails_app/rails_5.2/config/environment.rb +7 -0
- data/rails_app/rails_5.2/config/environments/development.rb +41 -0
- data/rails_app/rails_5.2/config/environments/production.rb +70 -0
- data/rails_app/rails_5.2/config/environments/test.rb +38 -0
- data/rails_app/rails_5.2/config/initializers/application_controller_renderer.rb +9 -0
- data/rails_app/rails_5.2/config/initializers/backtrace_silencers.rb +8 -0
- data/rails_app/rails_5.2/config/initializers/cors.rb +17 -0
- data/rails_app/rails_5.2/config/initializers/filter_parameter_logging.rb +6 -0
- data/rails_app/rails_5.2/config/initializers/inflections.rb +17 -0
- data/rails_app/rails_5.2/config/initializers/mime_types.rb +5 -0
- data/rails_app/rails_5.2/config/initializers/wrap_parameters.rb +11 -0
- data/rails_app/rails_5.2/config/locales/en.yml +33 -0
- data/rails_app/rails_5.2/config/routes.rb +5 -0
- data/rails_app/rails_5.2/config/spring.rb +8 -0
- data/rails_app/rails_5.2/public/robots.txt +1 -0
- data/rails_app/rails_5.2/spec/rails_helper.rb +14 -0
- data/rails_app/rails_5.2/spec/spec_helper.rb +13 -0
- data/rails_app/rails_6.0/.rspec +3 -0
- data/rails_app/rails_6.0/Gemfile +17 -0
- data/rails_app/rails_6.0/Gemfile.lock +190 -0
- data/rails_app/rails_6.0/README.md +24 -0
- data/rails_app/rails_6.0/Rakefile +8 -0
- data/rails_app/rails_6.0/app/controllers/application_controller.rb +4 -0
- data/rails_app/rails_6.0/app/jobs/application_job.rb +9 -0
- data/rails_app/rails_6.0/bin/rails +6 -0
- data/rails_app/rails_6.0/bin/rake +6 -0
- data/rails_app/rails_6.0/bin/setup +27 -0
- data/rails_app/rails_6.0/config.ru +7 -0
- data/rails_app/rails_6.0/config/application.rb +39 -0
- data/rails_app/rails_6.0/config/boot.rb +6 -0
- data/rails_app/rails_6.0/config/credentials.yml.enc +1 -0
- data/rails_app/rails_6.0/config/environment.rb +7 -0
- data/rails_app/rails_6.0/config/environments/development.rb +39 -0
- data/rails_app/rails_6.0/config/environments/production.rb +90 -0
- data/rails_app/rails_6.0/config/environments/test.rb +41 -0
- data/rails_app/rails_6.0/config/initializers/application_controller_renderer.rb +9 -0
- data/rails_app/rails_6.0/config/initializers/backtrace_silencers.rb +8 -0
- data/rails_app/rails_6.0/config/initializers/cors.rb +17 -0
- data/rails_app/rails_6.0/config/initializers/filter_parameter_logging.rb +6 -0
- data/rails_app/rails_6.0/config/initializers/inflections.rb +17 -0
- data/rails_app/rails_6.0/config/initializers/mime_types.rb +5 -0
- data/rails_app/rails_6.0/config/initializers/wrap_parameters.rb +11 -0
- data/rails_app/rails_6.0/config/locales/en.yml +33 -0
- data/rails_app/rails_6.0/config/routes.rb +5 -0
- data/rails_app/rails_6.0/config/spring.rb +8 -0
- data/rails_app/rails_6.0/public/robots.txt +1 -0
- data/rails_app/rails_6.0/spec/rails_helper.rb +14 -0
- data/rails_app/rails_6.0/spec/spec_helper.rb +13 -0
- data/rails_app/rails_6.1/.gitattributes +8 -0
- data/rails_app/rails_6.1/.gitignore +28 -0
- data/rails_app/rails_6.1/.rspec +3 -0
- data/rails_app/rails_6.1/Gemfile +17 -0
- data/rails_app/rails_6.1/Gemfile.lock +197 -0
- data/rails_app/rails_6.1/README.md +24 -0
- data/rails_app/rails_6.1/Rakefile +6 -0
- data/rails_app/rails_6.1/app/controllers/application_controller.rb +4 -0
- data/rails_app/rails_6.1/app/controllers/concerns/.keep +0 -0
- data/rails_app/rails_6.1/app/javascript/.keep +0 -0
- data/rails_app/rails_6.1/app/models/application_record.rb +5 -0
- data/rails_app/rails_6.1/app/models/concerns/.keep +0 -0
- data/rails_app/rails_6.1/bin/bundle +114 -0
- data/rails_app/rails_6.1/bin/rails +4 -0
- data/rails_app/rails_6.1/bin/rake +4 -0
- data/rails_app/rails_6.1/bin/setup +33 -0
- data/rails_app/rails_6.1/config.ru +6 -0
- data/rails_app/rails_6.1/config/application.rb +42 -0
- data/rails_app/rails_6.1/config/boot.rb +5 -0
- data/rails_app/rails_6.1/config/credentials.yml.enc +1 -0
- data/rails_app/rails_6.1/config/database.yml +25 -0
- data/rails_app/rails_6.1/config/environment.rb +7 -0
- data/rails_app/rails_6.1/config/environments/development.rb +59 -0
- data/rails_app/rails_6.1/config/environments/production.rb +97 -0
- data/rails_app/rails_6.1/config/environments/test.rb +51 -0
- data/rails_app/rails_6.1/config/initializers/application_controller_renderer.rb +9 -0
- data/rails_app/rails_6.1/config/initializers/backtrace_silencers.rb +10 -0
- data/rails_app/rails_6.1/config/initializers/cors.rb +17 -0
- data/rails_app/rails_6.1/config/initializers/filter_parameter_logging.rb +8 -0
- data/rails_app/rails_6.1/config/initializers/inflections.rb +17 -0
- data/rails_app/rails_6.1/config/initializers/mime_types.rb +5 -0
- data/rails_app/rails_6.1/config/initializers/wrap_parameters.rb +16 -0
- data/rails_app/rails_6.1/config/locales/en.yml +33 -0
- data/rails_app/rails_6.1/config/routes.rb +5 -0
- data/rails_app/rails_6.1/db/seeds.rb +8 -0
- data/rails_app/rails_6.1/lib/tasks/.keep +0 -0
- data/rails_app/rails_6.1/public/robots.txt +1 -0
- data/rails_app/rails_6.1/spec/rails_helper.rb +14 -0
- data/rails_app/rails_6.1/spec/spec_helper.rb +13 -0
- data/rails_app/rails_6.1/tmp/.keep +0 -0
- data/rails_app/rails_6.1/tmp/pids/.keep +0 -0
- data/rails_app/rails_6.1/vendor/.keep +0 -0
- metadata +119 -7
@@ -0,0 +1 @@
|
|
1
|
+
# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
ENV['RAILS_ENV'] ||= 'test'
|
5
|
+
require File.expand_path('../config/environment', __dir__)
|
6
|
+
abort('The Rails environment is running in production mode!') if Rails.env.production?
|
7
|
+
require 'rspec/rails'
|
8
|
+
require 'my_api_client/rspec'
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.use_active_record = false
|
12
|
+
config.infer_spec_type_from_file_location!
|
13
|
+
config.filter_rails_from_backtrace!
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.expect_with :rspec do |expectations|
|
5
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
6
|
+
end
|
7
|
+
|
8
|
+
config.mock_with :rspec do |mocks|
|
9
|
+
mocks.verify_partial_doubles = true
|
10
|
+
end
|
11
|
+
|
12
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
13
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
/db/*.sqlite3-*
|
13
|
+
|
14
|
+
# Ignore all logfiles and tempfiles.
|
15
|
+
/log/*
|
16
|
+
/tmp/*
|
17
|
+
!/log/.keep
|
18
|
+
!/tmp/.keep
|
19
|
+
|
20
|
+
# Ignore pidfiles, but keep the directory.
|
21
|
+
/tmp/pids/*
|
22
|
+
!/tmp/pids/
|
23
|
+
!/tmp/pids/.keep
|
24
|
+
|
25
|
+
.byebug_history
|
26
|
+
|
27
|
+
# Ignore master key for decrypting credentials and more.
|
28
|
+
/config/master.key
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
5
|
+
|
6
|
+
gem 'rails', '~> 6.1.0'
|
7
|
+
gem 'sqlite3', '~> 1.4'
|
8
|
+
gem 'my_api_client', path: '../..'
|
9
|
+
|
10
|
+
group :development, :test do
|
11
|
+
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
|
12
|
+
gem 'rspec-rails'
|
13
|
+
end
|
14
|
+
|
15
|
+
group :development do
|
16
|
+
gem 'listen', '~> 3.3'
|
17
|
+
end
|
@@ -0,0 +1,197 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../..
|
3
|
+
specs:
|
4
|
+
my_api_client (0.18.0)
|
5
|
+
activesupport (>= 5.2.0)
|
6
|
+
faraday (>= 0.17.1)
|
7
|
+
jsonpath
|
8
|
+
sawyer (>= 0.8.2)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
actioncable (6.1.0)
|
14
|
+
actionpack (= 6.1.0)
|
15
|
+
activesupport (= 6.1.0)
|
16
|
+
nio4r (~> 2.0)
|
17
|
+
websocket-driver (>= 0.6.1)
|
18
|
+
actionmailbox (6.1.0)
|
19
|
+
actionpack (= 6.1.0)
|
20
|
+
activejob (= 6.1.0)
|
21
|
+
activerecord (= 6.1.0)
|
22
|
+
activestorage (= 6.1.0)
|
23
|
+
activesupport (= 6.1.0)
|
24
|
+
mail (>= 2.7.1)
|
25
|
+
actionmailer (6.1.0)
|
26
|
+
actionpack (= 6.1.0)
|
27
|
+
actionview (= 6.1.0)
|
28
|
+
activejob (= 6.1.0)
|
29
|
+
activesupport (= 6.1.0)
|
30
|
+
mail (~> 2.5, >= 2.5.4)
|
31
|
+
rails-dom-testing (~> 2.0)
|
32
|
+
actionpack (6.1.0)
|
33
|
+
actionview (= 6.1.0)
|
34
|
+
activesupport (= 6.1.0)
|
35
|
+
rack (~> 2.0, >= 2.0.9)
|
36
|
+
rack-test (>= 0.6.3)
|
37
|
+
rails-dom-testing (~> 2.0)
|
38
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
39
|
+
actiontext (6.1.0)
|
40
|
+
actionpack (= 6.1.0)
|
41
|
+
activerecord (= 6.1.0)
|
42
|
+
activestorage (= 6.1.0)
|
43
|
+
activesupport (= 6.1.0)
|
44
|
+
nokogiri (>= 1.8.5)
|
45
|
+
actionview (6.1.0)
|
46
|
+
activesupport (= 6.1.0)
|
47
|
+
builder (~> 3.1)
|
48
|
+
erubi (~> 1.4)
|
49
|
+
rails-dom-testing (~> 2.0)
|
50
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
51
|
+
activejob (6.1.0)
|
52
|
+
activesupport (= 6.1.0)
|
53
|
+
globalid (>= 0.3.6)
|
54
|
+
activemodel (6.1.0)
|
55
|
+
activesupport (= 6.1.0)
|
56
|
+
activerecord (6.1.0)
|
57
|
+
activemodel (= 6.1.0)
|
58
|
+
activesupport (= 6.1.0)
|
59
|
+
activestorage (6.1.0)
|
60
|
+
actionpack (= 6.1.0)
|
61
|
+
activejob (= 6.1.0)
|
62
|
+
activerecord (= 6.1.0)
|
63
|
+
activesupport (= 6.1.0)
|
64
|
+
marcel (~> 0.3.1)
|
65
|
+
mimemagic (~> 0.3.2)
|
66
|
+
activesupport (6.1.0)
|
67
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
68
|
+
i18n (>= 1.6, < 2)
|
69
|
+
minitest (>= 5.1)
|
70
|
+
tzinfo (~> 2.0)
|
71
|
+
zeitwerk (~> 2.3)
|
72
|
+
addressable (2.7.0)
|
73
|
+
public_suffix (>= 2.0.2, < 5.0)
|
74
|
+
builder (3.2.4)
|
75
|
+
byebug (11.1.3)
|
76
|
+
concurrent-ruby (1.1.7)
|
77
|
+
crass (1.0.6)
|
78
|
+
diff-lcs (1.4.4)
|
79
|
+
erubi (1.10.0)
|
80
|
+
faraday (1.3.0)
|
81
|
+
faraday-net_http (~> 1.0)
|
82
|
+
multipart-post (>= 1.2, < 3)
|
83
|
+
ruby2_keywords
|
84
|
+
faraday-net_http (1.0.0)
|
85
|
+
ffi (1.14.2)
|
86
|
+
globalid (0.4.2)
|
87
|
+
activesupport (>= 4.2.0)
|
88
|
+
i18n (1.8.5)
|
89
|
+
concurrent-ruby (~> 1.0)
|
90
|
+
jsonpath (1.1.0)
|
91
|
+
multi_json
|
92
|
+
listen (3.3.3)
|
93
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
94
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
95
|
+
loofah (2.8.0)
|
96
|
+
crass (~> 1.0.2)
|
97
|
+
nokogiri (>= 1.5.9)
|
98
|
+
mail (2.7.1)
|
99
|
+
mini_mime (>= 0.1.1)
|
100
|
+
marcel (0.3.3)
|
101
|
+
mimemagic (~> 0.3.2)
|
102
|
+
method_source (1.0.0)
|
103
|
+
mimemagic (0.3.5)
|
104
|
+
mini_mime (1.0.2)
|
105
|
+
mini_portile2 (2.5.0)
|
106
|
+
minitest (5.14.2)
|
107
|
+
multi_json (1.15.0)
|
108
|
+
multipart-post (2.1.1)
|
109
|
+
nio4r (2.5.4)
|
110
|
+
nokogiri (1.11.0)
|
111
|
+
mini_portile2 (~> 2.5.0)
|
112
|
+
racc (~> 1.4)
|
113
|
+
public_suffix (4.0.6)
|
114
|
+
racc (1.5.2)
|
115
|
+
rack (2.2.3)
|
116
|
+
rack-test (1.1.0)
|
117
|
+
rack (>= 1.0, < 3)
|
118
|
+
rails (6.1.0)
|
119
|
+
actioncable (= 6.1.0)
|
120
|
+
actionmailbox (= 6.1.0)
|
121
|
+
actionmailer (= 6.1.0)
|
122
|
+
actionpack (= 6.1.0)
|
123
|
+
actiontext (= 6.1.0)
|
124
|
+
actionview (= 6.1.0)
|
125
|
+
activejob (= 6.1.0)
|
126
|
+
activemodel (= 6.1.0)
|
127
|
+
activerecord (= 6.1.0)
|
128
|
+
activestorage (= 6.1.0)
|
129
|
+
activesupport (= 6.1.0)
|
130
|
+
bundler (>= 1.15.0)
|
131
|
+
railties (= 6.1.0)
|
132
|
+
sprockets-rails (>= 2.0.0)
|
133
|
+
rails-dom-testing (2.0.3)
|
134
|
+
activesupport (>= 4.2.0)
|
135
|
+
nokogiri (>= 1.6)
|
136
|
+
rails-html-sanitizer (1.3.0)
|
137
|
+
loofah (~> 2.3)
|
138
|
+
railties (6.1.0)
|
139
|
+
actionpack (= 6.1.0)
|
140
|
+
activesupport (= 6.1.0)
|
141
|
+
method_source
|
142
|
+
rake (>= 0.8.7)
|
143
|
+
thor (~> 1.0)
|
144
|
+
rake (13.0.3)
|
145
|
+
rb-fsevent (0.10.4)
|
146
|
+
rb-inotify (0.10.1)
|
147
|
+
ffi (~> 1.0)
|
148
|
+
rspec-core (3.10.0)
|
149
|
+
rspec-support (~> 3.10.0)
|
150
|
+
rspec-expectations (3.10.0)
|
151
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
152
|
+
rspec-support (~> 3.10.0)
|
153
|
+
rspec-mocks (3.10.0)
|
154
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
155
|
+
rspec-support (~> 3.10.0)
|
156
|
+
rspec-rails (4.0.1)
|
157
|
+
actionpack (>= 4.2)
|
158
|
+
activesupport (>= 4.2)
|
159
|
+
railties (>= 4.2)
|
160
|
+
rspec-core (~> 3.9)
|
161
|
+
rspec-expectations (~> 3.9)
|
162
|
+
rspec-mocks (~> 3.9)
|
163
|
+
rspec-support (~> 3.9)
|
164
|
+
rspec-support (3.10.0)
|
165
|
+
ruby2_keywords (0.0.2)
|
166
|
+
sawyer (0.8.2)
|
167
|
+
addressable (>= 2.3.5)
|
168
|
+
faraday (> 0.8, < 2.0)
|
169
|
+
sprockets (4.0.2)
|
170
|
+
concurrent-ruby (~> 1.0)
|
171
|
+
rack (> 1, < 3)
|
172
|
+
sprockets-rails (3.2.2)
|
173
|
+
actionpack (>= 4.0)
|
174
|
+
activesupport (>= 4.0)
|
175
|
+
sprockets (>= 3.0.0)
|
176
|
+
sqlite3 (1.4.2)
|
177
|
+
thor (1.0.1)
|
178
|
+
tzinfo (2.0.4)
|
179
|
+
concurrent-ruby (~> 1.0)
|
180
|
+
websocket-driver (0.7.3)
|
181
|
+
websocket-extensions (>= 0.1.0)
|
182
|
+
websocket-extensions (0.1.5)
|
183
|
+
zeitwerk (2.4.2)
|
184
|
+
|
185
|
+
PLATFORMS
|
186
|
+
ruby
|
187
|
+
|
188
|
+
DEPENDENCIES
|
189
|
+
byebug
|
190
|
+
listen (~> 3.3)
|
191
|
+
my_api_client!
|
192
|
+
rails (~> 6.1.0)
|
193
|
+
rspec-rails
|
194
|
+
sqlite3 (~> 1.4)
|
195
|
+
|
196
|
+
BUNDLED WITH
|
197
|
+
2.1.2
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,114 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../../Gemfile", __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_version
|
64
|
+
@bundler_version ||=
|
65
|
+
env_var_version || cli_arg_version ||
|
66
|
+
lockfile_version
|
67
|
+
end
|
68
|
+
|
69
|
+
def bundler_requirement
|
70
|
+
return "#{Gem::Requirement.default}.a" unless bundler_version
|
71
|
+
|
72
|
+
bundler_gem_version = Gem::Version.new(bundler_version)
|
73
|
+
|
74
|
+
requirement = bundler_gem_version.approximate_recommendation
|
75
|
+
|
76
|
+
return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
|
77
|
+
|
78
|
+
requirement += ".a" if bundler_gem_version.prerelease?
|
79
|
+
|
80
|
+
requirement
|
81
|
+
end
|
82
|
+
|
83
|
+
def load_bundler!
|
84
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
85
|
+
|
86
|
+
activate_bundler
|
87
|
+
end
|
88
|
+
|
89
|
+
def activate_bundler
|
90
|
+
gem_error = activation_error_handling do
|
91
|
+
gem "bundler", bundler_requirement
|
92
|
+
end
|
93
|
+
return if gem_error.nil?
|
94
|
+
require_error = activation_error_handling do
|
95
|
+
require "bundler/version"
|
96
|
+
end
|
97
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
98
|
+
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
|
99
|
+
exit 42
|
100
|
+
end
|
101
|
+
|
102
|
+
def activation_error_handling
|
103
|
+
yield
|
104
|
+
nil
|
105
|
+
rescue StandardError, LoadError => e
|
106
|
+
e
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
m.load_bundler!
|
111
|
+
|
112
|
+
if m.invoked_as_script?
|
113
|
+
load Gem.bin_path("bundler", "bundle")
|
114
|
+
end
|