database_cleaner-spanner 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.standard.yml +3 -0
  3. data/CHANGELOG.md +4 -2
  4. data/LICENSE +21 -0
  5. data/README.md +6 -0
  6. data/database_cleaner-spanner.gemspec +3 -0
  7. data/example/rails/.gitattributes +7 -0
  8. data/example/rails/.gitignore +39 -0
  9. data/example/rails/.rspec +1 -0
  10. data/example/rails/.ruby-version +1 -0
  11. data/example/rails/Gemfile +69 -0
  12. data/example/rails/README.md +24 -0
  13. data/example/rails/Rakefile +6 -0
  14. data/example/rails/app/assets/config/manifest.js +4 -0
  15. data/example/rails/app/assets/images/.keep +0 -0
  16. data/example/rails/app/assets/stylesheets/application.css +15 -0
  17. data/example/rails/app/channels/application_cable/channel.rb +4 -0
  18. data/example/rails/app/channels/application_cable/connection.rb +4 -0
  19. data/example/rails/app/controllers/application_controller.rb +2 -0
  20. data/example/rails/app/controllers/concerns/.keep +0 -0
  21. data/example/rails/app/helpers/application_helper.rb +2 -0
  22. data/example/rails/app/javascript/application.js +3 -0
  23. data/example/rails/app/javascript/controllers/application.js +9 -0
  24. data/example/rails/app/javascript/controllers/hello_controller.js +7 -0
  25. data/example/rails/app/javascript/controllers/index.js +11 -0
  26. data/example/rails/app/jobs/application_job.rb +7 -0
  27. data/example/rails/app/mailers/application_mailer.rb +4 -0
  28. data/example/rails/app/models/album.rb +5 -0
  29. data/example/rails/app/models/application_record.rb +5 -0
  30. data/example/rails/app/models/concerns/.keep +0 -0
  31. data/example/rails/app/models/customer.rb +3 -0
  32. data/example/rails/app/models/order.rb +4 -0
  33. data/example/rails/app/models/product.rb +3 -0
  34. data/example/rails/app/models/singer.rb +4 -0
  35. data/example/rails/app/models/song.rb +15 -0
  36. data/example/rails/app/views/layouts/application.html.erb +16 -0
  37. data/example/rails/app/views/layouts/mailer.html.erb +13 -0
  38. data/example/rails/app/views/layouts/mailer.text.erb +1 -0
  39. data/example/rails/bin/bundle +114 -0
  40. data/example/rails/bin/importmap +4 -0
  41. data/example/rails/bin/rails +4 -0
  42. data/example/rails/bin/rake +4 -0
  43. data/example/rails/bin/setup +33 -0
  44. data/example/rails/config/application.rb +37 -0
  45. data/example/rails/config/boot.rb +4 -0
  46. data/example/rails/config/cable.yml +10 -0
  47. data/example/rails/config/credentials.yml.enc +1 -0
  48. data/example/rails/config/database.yml +18 -0
  49. data/example/rails/config/environment.rb +5 -0
  50. data/example/rails/config/environments/development.rb +70 -0
  51. data/example/rails/config/environments/production.rb +93 -0
  52. data/example/rails/config/environments/test.rb +60 -0
  53. data/example/rails/config/importmap.rb +7 -0
  54. data/example/rails/config/initializers/assets.rb +12 -0
  55. data/example/rails/config/initializers/content_security_policy.rb +25 -0
  56. data/example/rails/config/initializers/filter_parameter_logging.rb +8 -0
  57. data/example/rails/config/initializers/inflections.rb +16 -0
  58. data/example/rails/config/initializers/permissions_policy.rb +11 -0
  59. data/example/rails/config/locales/en.yml +33 -0
  60. data/example/rails/config/puma.rb +43 -0
  61. data/example/rails/config/routes.rb +6 -0
  62. data/example/rails/config/storage.yml +34 -0
  63. data/example/rails/config.ru +6 -0
  64. data/example/rails/db/migrate/20221113100815_create_customers.rb +9 -0
  65. data/example/rails/db/migrate/20221113101016_create_products.rb +10 -0
  66. data/example/rails/db/migrate/20221113101027_create_orders.rb +11 -0
  67. data/example/rails/db/migrate/20221113101034_create_singers.rb +10 -0
  68. data/example/rails/db/migrate/20221113101039_create_albums.rb +12 -0
  69. data/example/rails/db/migrate/20221113101044_create_songs.rb +13 -0
  70. data/example/rails/db/schema.rb +58 -0
  71. data/example/rails/db/seeds.rb +7 -0
  72. data/example/rails/lib/assets/.keep +0 -0
  73. data/example/rails/lib/tasks/.keep +0 -0
  74. data/example/rails/log/.keep +0 -0
  75. data/example/rails/public/404.html +67 -0
  76. data/example/rails/public/422.html +67 -0
  77. data/example/rails/public/500.html +66 -0
  78. data/example/rails/public/apple-touch-icon-precomposed.png +0 -0
  79. data/example/rails/public/apple-touch-icon.png +0 -0
  80. data/example/rails/public/favicon.ico +0 -0
  81. data/example/rails/public/robots.txt +1 -0
  82. data/example/rails/spec/factories/factory.rb +33 -0
  83. data/example/rails/spec/models/album_spec.rb +5 -0
  84. data/example/rails/spec/models/customer_spec.rb +5 -0
  85. data/example/rails/spec/models/order_spec.rb +5 -0
  86. data/example/rails/spec/models/product_spec.rb +5 -0
  87. data/example/rails/spec/models/singer_spec.rb +5 -0
  88. data/example/rails/spec/models/song_spec.rb +5 -0
  89. data/example/rails/spec/rails_helper.rb +70 -0
  90. data/example/rails/spec/sample_spec.rb +14 -0
  91. data/example/rails/spec/spec_helper.rb +94 -0
  92. data/example/rails/spec/support/factory_bot.rb +3 -0
  93. data/example/rails/storage/.keep +0 -0
  94. data/example/rails/tmp/.keep +0 -0
  95. data/example/rails/tmp/pids/.keep +0 -0
  96. data/example/rails/tmp/storage/.keep +0 -0
  97. data/example/rails/vendor/.keep +0 -0
  98. data/example/rails/vendor/javascript/.keep +0 -0
  99. data/lib/database_cleaner/spanner/deletion.rb +31 -5
  100. data/lib/database_cleaner/spanner/version.rb +1 -1
  101. data/scripts/performance_test.rb +127 -0
  102. data/scripts/schema.sql +93 -0
  103. metadata +125 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c8d719d3f246b5bda9a82752ffbea98675e9776f10310eea0b94ef3a3f44a71
4
- data.tar.gz: 6bff1b7b11584e8c81cfb0b26ab0675b217c0a8e5888c0e901713f12feafc89e
3
+ metadata.gz: 90164a2a9974ce6a9a1bd0510b4643fe7016d4c6946e98626f4ce2bc14106da4
4
+ data.tar.gz: 8b41c9c5d1cc37c3dfeae451c92f46e22338b6522cf73ccb6cd165eda2a6d96b
5
5
  SHA512:
6
- metadata.gz: 1a221c3bc36d5280d1b11588d30e3cb7ad855eb7589feb5f59b0ebaaeb66a4c9ee066f21402aa0ea33a7dfbe69acde970919ac8cedbc6ad779a9459f8fadc390
7
- data.tar.gz: c42d9eb77c819a65d241614395a42ae8bb1a409dcbc91fe557dea8daa34308b6ee37fb79f35879f5405b3f386b6ce3c6f3f4be1e7126dba745c1b41d1c910b8d
6
+ metadata.gz: e42bcbaf9758939dc7e9b4d9079c7decf72c9fd97dea2452bcda7390a1543037edd7e45daccf492e514de27c3be32d743eebadd404da5186b3cf56fd16d5a2b6
7
+ data.tar.gz: 1299d683a3e051c0d6fbcb2e7a4f8bc7c12092c8542b7aafd0e72b4b1eff54567ef308712b242fb4e2bbb9f1815e230d08c1594291613fa0eedfc7ec29dc98f3
data/.standard.yml CHANGED
@@ -1,3 +1,6 @@
1
1
  # For available configuration options, see:
2
2
  # https://github.com/testdouble/standard
3
3
  ruby_version: 2.6
4
+
5
+ ignore:
6
+ - example/**/*
data/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
- ## [Unreleased]
1
+ ## [0.1.1] - 2022-11-19
2
2
 
3
- ## [0.1.0] - 2022-11-11
3
+ - Add `:batch_deletion` option
4
+
5
+ ## [0.1.0] - 2022-11-13
4
6
 
5
7
  - Initial release
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 nownabe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Database Claner Adapter for Cloud Spanner
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/database_cleaner-spanner.svg)](https://badge.fury.io/rb/database_cleaner-spanner)
4
+ ![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/nownabe/database_cleaner-spanner/test/main)
5
+ [![codecov](https://codecov.io/gh/nownabe/database_cleaner-spanner/branch/main/graph/badge.svg?token=y5Dg4FpCeX)](https://codecov.io/gh/nownabe/database_cleaner-spanner)
6
+ [![Maintainability](https://api.codeclimate.com/v1/badges/ea64a23ba2c1785963e8/maintainability)](https://codeclimate.com/github/nownabe/database_cleaner-spanner/maintainability)
7
+
3
8
  Clean your Cloud Spanner databases with Database Cleaner.
4
9
 
5
10
  See also [https://github.com/DatabaseCleaner/database_cleaner](https://github.com/DatabaseCleaner/database_cleaner) for more information.
@@ -56,6 +61,7 @@ The Cloud Spanner adapter has only the deletion strategy.
56
61
 
57
62
  ## Strategy configuration options
58
63
 
64
+ * `:batch_deletion` - When set to `true`, [batch DML](https://cloud.google.com/spanner/docs/dml-tasks#use-batch) is used for cleaning. Defaults to `false`.
59
65
  * `:cache_tables` - When set to `true`, the list of tables to delete and the deletion orders will be
60
66
  read from the Cloud Spanner once, otherwise they will be read before each deletion. Defaults to
61
67
  `true`.
@@ -31,4 +31,7 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.add_dependency "google-cloud-spanner", "~> 2.10"
33
33
  spec.add_dependency "database_cleaner-core", "~> 2.0.0"
34
+
35
+ spec.add_development_dependency "simplecov"
36
+ spec.add_development_dependency "simplecov-cobertura"
34
37
  end
@@ -0,0 +1,7 @@
1
+ # See https://git-scm.com/docs/gitattributes for more about git attribute files.
2
+
3
+ # Mark the database schema as having been generated.
4
+ db/schema.rb linguist-generated
5
+
6
+ # Mark any vendored files as having been vendored.
7
+ vendor/* linguist-vendored
@@ -0,0 +1,39 @@
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
+ # Ignore uploaded files in development.
26
+ /storage/*
27
+ !/storage/.keep
28
+ /tmp/storage/*
29
+ !/tmp/storage/
30
+ !/tmp/storage/.keep
31
+
32
+ /public/assets
33
+
34
+ # Ignore master key for decrypting credentials and more.
35
+ /config/master.key
36
+ credentials.json
37
+ vendor/bundle
38
+ vendor/bundle
39
+ .envrc
@@ -0,0 +1 @@
1
+ --require spec_helper
@@ -0,0 +1 @@
1
+ ruby-3.1.2
@@ -0,0 +1,69 @@
1
+ source "https://rubygems.org"
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ ruby "3.1.2"
5
+
6
+ # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
7
+ gem "rails", "~> 7.0.4"
8
+
9
+ # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
10
+ gem "sprockets-rails"
11
+
12
+ gem "activerecord-spanner-adapter"
13
+ gem "composite_primary_keys"
14
+
15
+ # Use the Puma web server [https://github.com/puma/puma]
16
+ gem "puma", "~> 5.0"
17
+
18
+ # Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
19
+ gem "importmap-rails"
20
+
21
+ # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
22
+ gem "turbo-rails"
23
+
24
+ # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
25
+ gem "stimulus-rails"
26
+
27
+ # Build JSON APIs with ease [https://github.com/rails/jbuilder]
28
+ gem "jbuilder"
29
+
30
+ # Use Redis adapter to run Action Cable in production
31
+ # gem "redis", "~> 4.0"
32
+
33
+ # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
34
+ # gem "kredis"
35
+
36
+ # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
37
+ # gem "bcrypt", "~> 3.1.7"
38
+
39
+ # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
40
+ gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
41
+
42
+ # Reduces boot times through caching; required in config/boot.rb
43
+ gem "bootsnap", require: false
44
+
45
+ # Use Sass to process CSS
46
+ # gem "sassc-rails"
47
+
48
+ # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
49
+ # gem "image_processing", "~> 1.2"
50
+
51
+ group :development, :test do
52
+ # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
53
+ gem "debug", platforms: %i[ mri mingw x64_mingw ]
54
+ gem "rspec-rails", "~> 6.0.0"
55
+ gem "database_cleaner-spanner"
56
+ gem "factory_bot_rails"
57
+ end
58
+
59
+ group :development do
60
+ # Use console on exceptions pages [https://github.com/rails/web-console]
61
+ gem "web-console"
62
+
63
+ # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
64
+ # gem "rack-mini-profiler"
65
+
66
+ # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
67
+ # gem "spring"
68
+ end
69
+
@@ -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
+ * ...
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative "config/application"
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,4 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../stylesheets .css
3
+ //= link_tree ../../javascript .js
4
+ //= link_tree ../../../vendor/javascript .js
File without changes
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
6
+ * vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,3 @@
1
+ // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
2
+ import "@hotwired/turbo-rails"
3
+ import "controllers"
@@ -0,0 +1,9 @@
1
+ import { Application } from "@hotwired/stimulus"
2
+
3
+ const application = Application.start()
4
+
5
+ // Configure Stimulus development experience
6
+ application.debug = false
7
+ window.Stimulus = application
8
+
9
+ export { application }
@@ -0,0 +1,7 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ connect() {
5
+ this.element.textContent = "Hello World!"
6
+ }
7
+ }
@@ -0,0 +1,11 @@
1
+ // Import and register all your controllers from the importmap under controllers/*
2
+
3
+ import { application } from "controllers/application"
4
+
5
+ // Eager load all controllers defined in the import map under controllers/**/*_controller
6
+ import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
7
+ eagerLoadControllersFrom("controllers", application)
8
+
9
+ // Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!)
10
+ // import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading"
11
+ // lazyLoadControllersFrom("controllers", application)
@@ -0,0 +1,7 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ # Automatically retry jobs that encountered a deadlock
3
+ # retry_on ActiveRecord::Deadlocked
4
+
5
+ # Most jobs are safe to ignore if the underlying records are no longer available
6
+ # discard_on ActiveJob::DeserializationError
7
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: "from@example.com"
3
+ layout "mailer"
4
+ end
@@ -0,0 +1,5 @@
1
+ class Album < ApplicationRecord
2
+ self.primary_keys = :singerid, :albumid
3
+ belongs_to :singer, foreign_key: :singerid
4
+ has_many :songs, foreign_key: [:singerid, :albumid]
5
+ end
@@ -0,0 +1,5 @@
1
+ require "composite_primary_keys"
2
+
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ primary_abstract_class
5
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ class Customer < ApplicationRecord
2
+ has_many :orders
3
+ end
@@ -0,0 +1,4 @@
1
+ class Order < ApplicationRecord
2
+ belongs_to :customer
3
+ belongs_to :product
4
+ end
@@ -0,0 +1,3 @@
1
+ class Product < ApplicationRecord
2
+ has_many :orders
3
+ end
@@ -0,0 +1,4 @@
1
+ class Singer < ApplicationRecord
2
+ has_many :albums, foreign_key: :singerid
3
+ has_many :songs, foreign_key: :singerid
4
+ end
@@ -0,0 +1,15 @@
1
+ class Song < ApplicationRecord
2
+ self.primary_keys = :singerid, :albumid, :songid
3
+ belongs_to :album, foreign_key: [:singerid, :albumid]
4
+ belongs_to :singer, foreign_key: :singerid
5
+
6
+ def initialize(attributes = nil)
7
+ super
8
+ self.singer ||= album&.singer
9
+ end
10
+
11
+ def album=(album)
12
+ super
13
+ self.singer = album&.singer
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>MyApp</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <%= csrf_meta_tags %>
7
+ <%= csp_meta_tag %>
8
+
9
+ <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
10
+ <%= javascript_importmap_tags %>
11
+ </head>
12
+
13
+ <body>
14
+ <%= yield %>
15
+ </body>
16
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -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_requirement
64
+ @bundler_requirement ||=
65
+ env_var_version || cli_arg_version ||
66
+ bundler_requirement_for(lockfile_version)
67
+ end
68
+
69
+ def bundler_requirement_for(version)
70
+ return "#{Gem::Requirement.default}.a" unless version
71
+
72
+ bundler_gem_version = Gem::Version.new(version)
73
+
74
+ requirement = bundler_gem_version.approximate_recommendation
75
+
76
+ return requirement unless Gem.rubygems_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
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../config/application"
4
+ require "importmap/commands"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path("../config/application", __dir__)
3
+ require_relative "../config/boot"
4
+ require "rails/commands"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative "../config/boot"
3
+ require "rake"
4
+ Rake.application.run
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require "fileutils"
3
+
4
+ # path to your application root.
5
+ APP_ROOT = File.expand_path("..", __dir__)
6
+
7
+ def system!(*args)
8
+ system(*args) || abort("\n== Command #{args} failed ==")
9
+ end
10
+
11
+ FileUtils.chdir APP_ROOT do
12
+ # This script is a way to set up or update your development environment automatically.
13
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts "== Installing dependencies =="
17
+ system! "gem install bundler --conservative"
18
+ system("bundle check") || system!("bundle install")
19
+
20
+ # puts "\n== Copying sample files =="
21
+ # unless File.exist?("config/database.yml")
22
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
23
+ # end
24
+
25
+ puts "\n== Preparing database =="
26
+ system! "bin/rails db:prepare"
27
+
28
+ puts "\n== Removing old logs and tempfiles =="
29
+ system! "bin/rails log:clear tmp:clear"
30
+
31
+ puts "\n== Restarting application server =="
32
+ system! "bin/rails restart"
33
+ end
@@ -0,0 +1,37 @@
1
+ require_relative "boot"
2
+
3
+ require "rails"
4
+ # Pick the frameworks you want:
5
+ require "active_model/railtie"
6
+ require "active_job/railtie"
7
+ require "active_record/railtie"
8
+ require "active_storage/engine"
9
+ require "action_controller/railtie"
10
+ require "action_mailer/railtie"
11
+ require "action_mailbox/engine"
12
+ require "action_text/engine"
13
+ require "action_view/railtie"
14
+ require "action_cable/engine"
15
+ # require "rails/test_unit/railtie"
16
+
17
+ # Require the gems listed in Gemfile, including any gems
18
+ # you've limited to :test, :development, or :production.
19
+ Bundler.require(*Rails.groups)
20
+
21
+ module MyApp
22
+ class Application < Rails::Application
23
+ # Initialize configuration defaults for originally generated Rails version.
24
+ config.load_defaults 7.0
25
+
26
+ # Configuration for the application, engines, and railties goes here.
27
+ #
28
+ # These settings can be overridden in specific environments using the files
29
+ # in config/environments, which are processed later.
30
+ #
31
+ # config.time_zone = "Central Time (US & Canada)"
32
+ # config.eager_load_paths << Rails.root.join("extras")
33
+
34
+ # Don't generate system test files.
35
+ config.generators.system_tests = nil
36
+ end
37
+ end
@@ -0,0 +1,4 @@
1
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
2
+
3
+ require "bundler/setup" # Set up gems listed in the Gemfile.
4
+ require "bootsnap/setup" # Speed up boot time by caching expensive operations.
@@ -0,0 +1,10 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: test
6
+
7
+ production:
8
+ adapter: redis
9
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10
+ channel_prefix: my_app_production