my_api_client 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +8 -7
- data/.rubocop.yml +7 -4
- data/.ruby-version +1 -0
- data/CHANGELOG.md +71 -0
- data/Gemfile.lock +95 -81
- data/README.jp.md +2 -2
- data/README.md +2 -2
- data/example/api_clients/my_error_api_client.rb +1 -1
- data/example/api_clients/my_header_api_client.rb +1 -1
- data/example/api_clients/my_pagination_api_client.rb +2 -2
- data/example/api_clients/my_rest_api_client.rb +10 -10
- data/example/api_clients/my_status_api_client.rb +1 -1
- data/gemfiles/rails_7.1.gemfile +15 -0
- data/gemfiles/rails_7.2.gemfile +15 -0
- data/lib/my_api_client/base.rb +1 -1
- data/lib/my_api_client/error_handling.rb +1 -1
- data/lib/my_api_client/errors/network_error.rb +1 -1
- data/lib/my_api_client/errors.rb +1 -1
- data/lib/my_api_client/exceptions.rb +1 -1
- data/lib/my_api_client/params/params.rb +1 -1
- data/lib/my_api_client/params/request.rb +8 -8
- data/lib/my_api_client/request/basic.rb +2 -2
- data/lib/my_api_client/request/executor.rb +1 -1
- data/lib/my_api_client/request/pagination.rb +1 -3
- data/lib/my_api_client/request.rb +5 -5
- data/lib/my_api_client/rspec/matcher_helper.rb +3 -3
- data/lib/my_api_client/rspec/matchers/request_to.rb +1 -1
- data/lib/my_api_client/version.rb +1 -1
- data/my_api/Gemfile +1 -1
- data/my_api/Gemfile.lock +83 -71
- data/my_api/app/controllers/error_controller.rb +1 -1
- data/my_api/app/controllers/pagination_controller.rb +1 -1
- data/my_api/app/controllers/rest_controller.rb +4 -4
- data/my_api/app/controllers/status_controller.rb +1 -1
- data/my_api/spec/controllers/error_controller_spec.rb +4 -4
- data/my_api/spec/controllers/status_controller_spec.rb +3 -3
- data/my_api_client.gemspec +2 -1
- data/rails_app/rails_6.1/Gemfile.lock +73 -71
- data/rails_app/rails_7.0/Gemfile.lock +78 -76
- data/rails_app/rails_7.1/.dockerignore +31 -0
- data/rails_app/rails_7.1/.rspec +1 -0
- data/rails_app/rails_7.1/Dockerfile +55 -0
- data/rails_app/rails_7.1/Gemfile +16 -0
- data/rails_app/rails_7.1/Gemfile.lock +241 -0
- data/rails_app/rails_7.1/README.md +24 -0
- data/rails_app/rails_7.1/Rakefile +8 -0
- data/rails_app/rails_7.1/app/controllers/application_controller.rb +4 -0
- data/rails_app/rails_7.1/app/controllers/concerns/.keep +0 -0
- data/rails_app/rails_7.1/app/models/application_record.rb +5 -0
- data/rails_app/rails_7.1/app/models/concerns/.keep +0 -0
- data/rails_app/rails_7.1/bin/bundle +122 -0
- data/rails_app/rails_7.1/bin/docker-entrypoint +8 -0
- data/rails_app/rails_7.1/bin/rails +6 -0
- data/rails_app/rails_7.1/bin/rake +6 -0
- data/rails_app/rails_7.1/bin/setup +35 -0
- data/rails_app/rails_7.1/config/application.rb +46 -0
- data/rails_app/rails_7.1/config/boot.rb +5 -0
- data/rails_app/rails_7.1/config/credentials.yml.enc +1 -0
- data/rails_app/rails_7.1/config/database.yml +25 -0
- data/rails_app/rails_7.1/config/environment.rb +7 -0
- data/rails_app/rails_7.1/config/environments/development.rb +58 -0
- data/rails_app/rails_7.1/config/environments/production.rb +74 -0
- data/rails_app/rails_7.1/config/environments/test.rb +56 -0
- data/rails_app/rails_7.1/config/initializers/cors.rb +17 -0
- data/rails_app/rails_7.1/config/initializers/filter_parameter_logging.rb +10 -0
- data/rails_app/rails_7.1/config/initializers/inflections.rb +17 -0
- data/rails_app/rails_7.1/config/locales/en.yml +31 -0
- data/rails_app/rails_7.1/config/puma.rb +46 -0
- data/rails_app/rails_7.1/config/routes.rb +12 -0
- data/rails_app/rails_7.1/config.ru +8 -0
- data/rails_app/rails_7.1/db/seeds.rb +10 -0
- data/rails_app/rails_7.1/lib/tasks/.keep +0 -0
- data/rails_app/rails_7.1/public/robots.txt +2 -0
- data/rails_app/rails_7.1/spec/rails_helper.rb +13 -0
- data/rails_app/rails_7.1/spec/spec_helper.rb +13 -0
- data/rails_app/rails_7.1/storage/.keep +0 -0
- data/rails_app/rails_7.1/tmp/.keep +0 -0
- data/rails_app/rails_7.1/tmp/pids/.keep +0 -0
- data/rails_app/rails_7.1/tmp/storage/.keep +0 -0
- data/rails_app/rails_7.1/vendor/.keep +0 -0
- data/rails_app/rails_7.2/.dockerignore +42 -0
- data/rails_app/rails_7.2/.github/dependabot.yml +12 -0
- data/rails_app/rails_7.2/.github/workflows/ci.yml +55 -0
- data/rails_app/rails_7.2/.rspec +1 -0
- data/rails_app/rails_7.2/Dockerfile +62 -0
- data/rails_app/rails_7.2/Gemfile +15 -0
- data/rails_app/rails_7.2/Gemfile.lock +240 -0
- data/rails_app/rails_7.2/README.md +24 -0
- data/rails_app/rails_7.2/Rakefile +8 -0
- data/rails_app/rails_7.2/app/controllers/application_controller.rb +4 -0
- data/rails_app/rails_7.2/app/controllers/concerns/.keep +0 -0
- data/rails_app/rails_7.2/app/models/application_record.rb +5 -0
- data/rails_app/rails_7.2/app/models/concerns/.keep +0 -0
- data/rails_app/rails_7.2/bin/brakeman +9 -0
- data/rails_app/rails_7.2/bin/bundle +122 -0
- data/rails_app/rails_7.2/bin/docker-entrypoint +13 -0
- data/rails_app/rails_7.2/bin/rails +6 -0
- data/rails_app/rails_7.2/bin/rake +6 -0
- data/rails_app/rails_7.2/bin/rubocop +10 -0
- data/rails_app/rails_7.2/bin/setup +39 -0
- data/rails_app/rails_7.2/config/application.rb +46 -0
- data/rails_app/rails_7.2/config/boot.rb +5 -0
- data/rails_app/rails_7.2/config/credentials.yml.enc +1 -0
- data/rails_app/rails_7.2/config/database.yml +32 -0
- data/rails_app/rails_7.2/config/environment.rb +7 -0
- data/rails_app/rails_7.2/config/environments/development.rb +59 -0
- data/rails_app/rails_7.2/config/environments/production.rb +77 -0
- data/rails_app/rails_7.2/config/environments/test.rb +53 -0
- data/rails_app/rails_7.2/config/initializers/cors.rb +18 -0
- data/rails_app/rails_7.2/config/initializers/filter_parameter_logging.rb +10 -0
- data/rails_app/rails_7.2/config/initializers/inflections.rb +18 -0
- data/rails_app/rails_7.2/config/locales/en.yml +31 -0
- data/rails_app/rails_7.2/config/puma.rb +36 -0
- data/rails_app/rails_7.2/config/routes.rb +12 -0
- data/rails_app/rails_7.2/config.ru +8 -0
- data/rails_app/rails_7.2/db/seeds.rb +11 -0
- data/rails_app/rails_7.2/lib/tasks/.keep +0 -0
- data/rails_app/rails_7.2/public/robots.txt +3 -0
- data/rails_app/rails_7.2/spec/rails_helper.rb +13 -0
- data/rails_app/rails_7.2/spec/spec_helper.rb +13 -0
- data/rails_app/rails_7.2/storage/.keep +0 -0
- data/rails_app/rails_7.2/tmp/.keep +0 -0
- data/rails_app/rails_7.2/tmp/pids/.keep +0 -0
- data/rails_app/rails_7.2/tmp/storage/.keep +0 -0
- data/rails_app/rails_7.2/vendor/.keep +0 -0
- metadata +107 -7
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/integer/time'
|
4
|
+
|
5
|
+
Rails.application.configure do
|
6
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
7
|
+
|
8
|
+
# Code is not reloaded between requests.
|
9
|
+
config.enable_reloading = false
|
10
|
+
|
11
|
+
# Eager load code on boot. This eager loads most of Rails and
|
12
|
+
# your application in memory, allowing both threaded web servers
|
13
|
+
# and those relying on copy on write to perform better.
|
14
|
+
# Rake tasks automatically ignore this option for performance.
|
15
|
+
config.eager_load = true
|
16
|
+
|
17
|
+
# Full error reports are disabled and caching is turned on.
|
18
|
+
config.consider_all_requests_local = false
|
19
|
+
|
20
|
+
# Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
|
21
|
+
# key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
|
22
|
+
# config.require_master_key = true
|
23
|
+
|
24
|
+
# Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
|
25
|
+
# config.public_file_server.enabled = false
|
26
|
+
|
27
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
28
|
+
# config.asset_host = "http://assets.example.com"
|
29
|
+
|
30
|
+
# Specifies the header that your server uses for sending files.
|
31
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
|
32
|
+
# config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
|
33
|
+
|
34
|
+
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
|
35
|
+
# Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
|
36
|
+
# config.assume_ssl = true
|
37
|
+
|
38
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
39
|
+
config.force_ssl = true
|
40
|
+
|
41
|
+
# Log to STDOUT by default
|
42
|
+
config.logger = ActiveSupport::Logger.new($stdout)
|
43
|
+
.tap { |logger| logger.formatter = Logger::Formatter.new }
|
44
|
+
.then { |logger| ActiveSupport::TaggedLogging.new(logger) }
|
45
|
+
|
46
|
+
# Prepend all log lines with the following tags.
|
47
|
+
config.log_tags = [:request_id]
|
48
|
+
|
49
|
+
# "info" includes generic and useful information about system operation, but avoids logging too much
|
50
|
+
# information to avoid inadvertent exposure of personally identifiable information (PII). If you
|
51
|
+
# want to log everything, set the level to "debug".
|
52
|
+
config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info')
|
53
|
+
|
54
|
+
# Use a different cache store in production.
|
55
|
+
# config.cache_store = :mem_cache_store
|
56
|
+
|
57
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
58
|
+
# the I18n.default_locale when a translation cannot be found).
|
59
|
+
config.i18n.fallbacks = true
|
60
|
+
|
61
|
+
# Don't log any deprecations.
|
62
|
+
config.active_support.report_deprecations = false
|
63
|
+
|
64
|
+
# Do not dump schema after migrations.
|
65
|
+
config.active_record.dump_schema_after_migration = false
|
66
|
+
|
67
|
+
# Enable DNS rebinding protection and other `Host` header attacks.
|
68
|
+
# config.hosts = [
|
69
|
+
# "example.com", # Allow requests from example.com
|
70
|
+
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
|
71
|
+
# ]
|
72
|
+
# Skip DNS rebinding protection for the default health check endpoint.
|
73
|
+
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
|
74
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/core_ext/integer/time'
|
4
|
+
|
5
|
+
# The test environment is used exclusively to run your application's
|
6
|
+
# test suite. You never need to work with it otherwise. Remember that
|
7
|
+
# your test database is "scratch space" for the test suite and is wiped
|
8
|
+
# and recreated between test runs. Don't rely on the data there!
|
9
|
+
|
10
|
+
Rails.application.configure do
|
11
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
12
|
+
|
13
|
+
# While tests run files are not watched, reloading is not necessary.
|
14
|
+
config.enable_reloading = false
|
15
|
+
|
16
|
+
# Eager loading loads your entire application. When running a single test locally,
|
17
|
+
# this is usually not necessary, and can slow down your test suite. However, it's
|
18
|
+
# recommended that you enable it in continuous integration systems to ensure eager
|
19
|
+
# loading is working properly before deploying your code.
|
20
|
+
config.eager_load = ENV['CI'].present?
|
21
|
+
|
22
|
+
# Configure public file server for tests with Cache-Control for performance.
|
23
|
+
config.public_file_server.enabled = true
|
24
|
+
config.public_file_server.headers = {
|
25
|
+
'Cache-Control' => "public, max-age=#{1.hour.to_i}",
|
26
|
+
}
|
27
|
+
|
28
|
+
# Show full error reports and disable caching.
|
29
|
+
config.consider_all_requests_local = true
|
30
|
+
config.action_controller.perform_caching = false
|
31
|
+
config.cache_store = :null_store
|
32
|
+
|
33
|
+
# Render exception templates for rescuable exceptions and raise for other exceptions.
|
34
|
+
config.action_dispatch.show_exceptions = :rescuable
|
35
|
+
|
36
|
+
# Disable request forgery protection in test environment.
|
37
|
+
config.action_controller.allow_forgery_protection = false
|
38
|
+
|
39
|
+
# Print deprecation notices to the stderr.
|
40
|
+
config.active_support.deprecation = :stderr
|
41
|
+
|
42
|
+
# Raise exceptions for disallowed deprecations.
|
43
|
+
config.active_support.disallowed_deprecation = :raise
|
44
|
+
|
45
|
+
# Tell Active Support which deprecation messages to disallow.
|
46
|
+
config.active_support.disallowed_deprecation_warnings = []
|
47
|
+
|
48
|
+
# Raises error for missing translations.
|
49
|
+
# config.i18n.raise_on_missing_translations = true
|
50
|
+
|
51
|
+
# Annotate rendered view with file names.
|
52
|
+
# config.action_view.annotate_rendered_view_with_filenames = true
|
53
|
+
|
54
|
+
# Raise error when a before_action's only/except options reference missing actions
|
55
|
+
config.action_controller.raise_on_missing_callback_actions = true
|
56
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Be sure to restart your server when you modify this file.
|
3
|
+
|
4
|
+
# Avoid CORS issues when API is called from the frontend app.
|
5
|
+
# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin Ajax requests.
|
6
|
+
|
7
|
+
# Read more: https://github.com/cyu/rack-cors
|
8
|
+
|
9
|
+
# Rails.application.config.middleware.insert_before 0, Rack::Cors do
|
10
|
+
# allow do
|
11
|
+
# origins "example.com"
|
12
|
+
#
|
13
|
+
# resource "*",
|
14
|
+
# headers: :any,
|
15
|
+
# methods: [:get, :post, :put, :patch, :delete, :options, :head]
|
16
|
+
# end
|
17
|
+
# end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Be sure to restart your server when you modify this file.
|
4
|
+
|
5
|
+
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
|
6
|
+
# Use this to limit dissemination of sensitive information.
|
7
|
+
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
|
8
|
+
Rails.application.config.filter_parameters += %i[
|
9
|
+
passw secret token _key crypt salt certificate otp ssn
|
10
|
+
]
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Be sure to restart your server when you modify this file.
|
3
|
+
|
4
|
+
# Add new inflection rules using the following format. Inflections
|
5
|
+
# are locale specific, and you may define rules for as many different
|
6
|
+
# locales as you wish. All of these examples are active by default:
|
7
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
8
|
+
# inflect.plural /^(ox)$/i, "\\1en"
|
9
|
+
# inflect.singular /^(ox)en/i, "\\1"
|
10
|
+
# inflect.irregular "person", "people"
|
11
|
+
# inflect.uncountable %w( fish sheep )
|
12
|
+
# end
|
13
|
+
|
14
|
+
# These inflection rules are supported but not enabled by default:
|
15
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
16
|
+
# inflect.acronym "RESTful"
|
17
|
+
# end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization and
|
2
|
+
# are automatically loaded by Rails. If you want to use locales other than
|
3
|
+
# English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t "hello"
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t("hello") %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# To learn more about the API, please read the Rails Internationalization guide
|
20
|
+
# at https://guides.rubyonrails.org/i18n.html.
|
21
|
+
#
|
22
|
+
# Be aware that YAML interprets the following case-insensitive strings as
|
23
|
+
# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings
|
24
|
+
# must be quoted to be interpreted as strings. For example:
|
25
|
+
#
|
26
|
+
# en:
|
27
|
+
# "yes": yup
|
28
|
+
# enabled: "ON"
|
29
|
+
|
30
|
+
en:
|
31
|
+
hello: "Hello world"
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This configuration file will be evaluated by Puma. The top-level methods that
|
4
|
+
# are invoked here are part of Puma's configuration DSL. For more information
|
5
|
+
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
|
6
|
+
|
7
|
+
# Puma can serve each request in a thread from an internal thread pool.
|
8
|
+
# The `threads` method setting takes two numbers: a minimum and maximum.
|
9
|
+
# Any libraries that use thread pools should be configured to match
|
10
|
+
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
11
|
+
# and maximum; this matches the default thread size of Active Record.
|
12
|
+
max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
|
13
|
+
min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
|
14
|
+
threads min_threads_count, max_threads_count
|
15
|
+
|
16
|
+
rails_env = ENV.fetch('RAILS_ENV', 'development')
|
17
|
+
|
18
|
+
if rails_env == 'production'
|
19
|
+
# If you are running more than 1 thread per process, the workers count
|
20
|
+
# should be equal to the number of processors (CPU cores) in production.
|
21
|
+
#
|
22
|
+
# It defaults to 1 because it's impossible to reliably detect how many
|
23
|
+
# CPU cores are available. Make sure to set the `WEB_CONCURRENCY` environment
|
24
|
+
# variable to match the number of processors.
|
25
|
+
worker_count = Integer(ENV.fetch('WEB_CONCURRENCY', 1))
|
26
|
+
if worker_count > 1
|
27
|
+
workers worker_count
|
28
|
+
else
|
29
|
+
preload_app!
|
30
|
+
end
|
31
|
+
end
|
32
|
+
# Specifies the `worker_timeout` threshold that Puma will use to wait before
|
33
|
+
# terminating a worker in development environments.
|
34
|
+
worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development'
|
35
|
+
|
36
|
+
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
37
|
+
port ENV.fetch('PORT', 3000)
|
38
|
+
|
39
|
+
# Specifies the `environment` that Puma will run in.
|
40
|
+
environment rails_env
|
41
|
+
|
42
|
+
# Specifies the `pidfile` that Puma will use.
|
43
|
+
pidfile ENV.fetch('PIDFILE', 'tmp/pids/server.pid')
|
44
|
+
|
45
|
+
# Allow puma to be restarted by `bin/rails restart` command.
|
46
|
+
plugin :tmp_restart
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Rails.application.routes.draw do
|
4
|
+
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
5
|
+
|
6
|
+
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
|
7
|
+
# Can be used by load balancers and uptime monitors to verify that the app is live.
|
8
|
+
get 'up' => 'rails/health#show', as: :rails_health_check
|
9
|
+
|
10
|
+
# Defines the root path route ("/")
|
11
|
+
# root "posts#index"
|
12
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# This file should ensure the existence of records required to run the application in every environment (production,
|
3
|
+
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
|
4
|
+
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
|
5
|
+
#
|
6
|
+
# Example:
|
7
|
+
#
|
8
|
+
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
|
9
|
+
# MovieGenre.find_or_create_by!(name: genre_name)
|
10
|
+
# end
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
ENV['RAILS_ENV'] ||= 'test'
|
5
|
+
require_relative '../config/environment'
|
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.infer_spec_type_from_file_location!
|
12
|
+
config.filter_rails_from_backtrace!
|
13
|
+
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
|
2
|
+
|
3
|
+
# Ignore git directory.
|
4
|
+
/.git/
|
5
|
+
/.gitignore
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore all environment files (except templates).
|
11
|
+
/.env*
|
12
|
+
!/.env*.erb
|
13
|
+
|
14
|
+
# Ignore all default key files.
|
15
|
+
/config/master.key
|
16
|
+
/config/credentials/*.key
|
17
|
+
|
18
|
+
# Ignore all logfiles and tempfiles.
|
19
|
+
/log/*
|
20
|
+
/tmp/*
|
21
|
+
!/log/.keep
|
22
|
+
!/tmp/.keep
|
23
|
+
|
24
|
+
# Ignore pidfiles, but keep the directory.
|
25
|
+
/tmp/pids/*
|
26
|
+
!/tmp/pids/.keep
|
27
|
+
|
28
|
+
# Ignore storage (uploaded files in development and any SQLite databases).
|
29
|
+
/storage/*
|
30
|
+
!/storage/.keep
|
31
|
+
/tmp/storage/*
|
32
|
+
!/tmp/storage/.keep
|
33
|
+
|
34
|
+
# Ignore CI service files.
|
35
|
+
/.github
|
36
|
+
|
37
|
+
# Ignore development files
|
38
|
+
/.devcontainer
|
39
|
+
|
40
|
+
# Ignore Docker-related files
|
41
|
+
/.dockerignore
|
42
|
+
/Dockerfile*
|
@@ -0,0 +1,55 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
branches: [ main ]
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
scan_ruby:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
steps:
|
13
|
+
- name: Checkout code
|
14
|
+
uses: actions/checkout@v4
|
15
|
+
|
16
|
+
- name: Set up Ruby
|
17
|
+
uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: .ruby-version
|
20
|
+
bundler-cache: true
|
21
|
+
|
22
|
+
- name: Scan for common Rails security vulnerabilities using static analysis
|
23
|
+
run: bin/brakeman --no-pager
|
24
|
+
|
25
|
+
scan_js:
|
26
|
+
runs-on: ubuntu-latest
|
27
|
+
|
28
|
+
steps:
|
29
|
+
- name: Checkout code
|
30
|
+
uses: actions/checkout@v4
|
31
|
+
|
32
|
+
- name: Set up Ruby
|
33
|
+
uses: ruby/setup-ruby@v1
|
34
|
+
with:
|
35
|
+
ruby-version: .ruby-version
|
36
|
+
bundler-cache: true
|
37
|
+
|
38
|
+
- name: Scan for security vulnerabilities in JavaScript dependencies
|
39
|
+
run: bin/importmap audit
|
40
|
+
|
41
|
+
lint:
|
42
|
+
runs-on: ubuntu-latest
|
43
|
+
steps:
|
44
|
+
- name: Checkout code
|
45
|
+
uses: actions/checkout@v4
|
46
|
+
|
47
|
+
- name: Set up Ruby
|
48
|
+
uses: ruby/setup-ruby@v1
|
49
|
+
with:
|
50
|
+
ruby-version: .ruby-version
|
51
|
+
bundler-cache: true
|
52
|
+
|
53
|
+
- name: Lint code for consistent style
|
54
|
+
run: bin/rubocop -f github
|
55
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# syntax = docker/dockerfile:1
|
2
|
+
|
3
|
+
# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand:
|
4
|
+
# docker build -t my-app .
|
5
|
+
# docker run -d -p 80:80 -p 443:443 --name my-app -e RAILS_MASTER_KEY=<value from config/master.key> my-app
|
6
|
+
|
7
|
+
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
|
8
|
+
ARG RUBY_VERSION=3.1.6
|
9
|
+
FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base
|
10
|
+
|
11
|
+
# Rails app lives here
|
12
|
+
WORKDIR /rails
|
13
|
+
|
14
|
+
# Install base packages
|
15
|
+
RUN apt-get update -qq && \
|
16
|
+
apt-get install --no-install-recommends -y curl libjemalloc2 sqlite3 && \
|
17
|
+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
|
18
|
+
|
19
|
+
# Set production environment
|
20
|
+
ENV RAILS_ENV="production" \
|
21
|
+
BUNDLE_DEPLOYMENT="1" \
|
22
|
+
BUNDLE_PATH="/usr/local/bundle" \
|
23
|
+
BUNDLE_WITHOUT="development"
|
24
|
+
|
25
|
+
# Throw-away build stage to reduce size of final image
|
26
|
+
FROM base AS build
|
27
|
+
|
28
|
+
# Install packages needed to build gems
|
29
|
+
RUN apt-get update -qq && \
|
30
|
+
apt-get install --no-install-recommends -y build-essential git pkg-config && \
|
31
|
+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
|
32
|
+
|
33
|
+
# Install application gems
|
34
|
+
COPY Gemfile Gemfile.lock ./
|
35
|
+
RUN bundle install && \
|
36
|
+
rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git
|
37
|
+
|
38
|
+
# Copy application code
|
39
|
+
COPY . .
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
# Final stage for app image
|
45
|
+
FROM base
|
46
|
+
|
47
|
+
# Copy built artifacts: gems, application
|
48
|
+
COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
|
49
|
+
COPY --from=build /rails /rails
|
50
|
+
|
51
|
+
# Run and own only the runtime files as a non-root user for security
|
52
|
+
RUN groupadd --system --gid 1000 rails && \
|
53
|
+
useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash && \
|
54
|
+
chown -R rails:rails db log storage tmp
|
55
|
+
USER 1000:1000
|
56
|
+
|
57
|
+
# Entrypoint prepares the database.
|
58
|
+
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
|
59
|
+
|
60
|
+
# Start the server by default, this can be overwritten at runtime
|
61
|
+
EXPOSE 3000
|
62
|
+
CMD ["./bin/rails", "server"]
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
gem 'my_api_client', path: '../..'
|
6
|
+
gem 'puma', '>= 5.0'
|
7
|
+
gem 'rails', '~> 7.2.1'
|
8
|
+
gem 'sqlite3', '>= 1.4'
|
9
|
+
|
10
|
+
gem 'tzinfo-data', platforms: %i[windows jruby]
|
11
|
+
|
12
|
+
group :development, :test do
|
13
|
+
gem 'debug', platforms: %i[mri windows], require: 'debug/prelude'
|
14
|
+
gem 'rspec-rails'
|
15
|
+
end
|