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.
- checksums.yaml +4 -4
- data/.standard.yml +3 -0
- data/CHANGELOG.md +4 -2
- data/LICENSE +21 -0
- data/README.md +6 -0
- data/database_cleaner-spanner.gemspec +3 -0
- data/example/rails/.gitattributes +7 -0
- data/example/rails/.gitignore +39 -0
- data/example/rails/.rspec +1 -0
- data/example/rails/.ruby-version +1 -0
- data/example/rails/Gemfile +69 -0
- data/example/rails/README.md +24 -0
- data/example/rails/Rakefile +6 -0
- data/example/rails/app/assets/config/manifest.js +4 -0
- data/example/rails/app/assets/images/.keep +0 -0
- data/example/rails/app/assets/stylesheets/application.css +15 -0
- data/example/rails/app/channels/application_cable/channel.rb +4 -0
- data/example/rails/app/channels/application_cable/connection.rb +4 -0
- data/example/rails/app/controllers/application_controller.rb +2 -0
- data/example/rails/app/controllers/concerns/.keep +0 -0
- data/example/rails/app/helpers/application_helper.rb +2 -0
- data/example/rails/app/javascript/application.js +3 -0
- data/example/rails/app/javascript/controllers/application.js +9 -0
- data/example/rails/app/javascript/controllers/hello_controller.js +7 -0
- data/example/rails/app/javascript/controllers/index.js +11 -0
- data/example/rails/app/jobs/application_job.rb +7 -0
- data/example/rails/app/mailers/application_mailer.rb +4 -0
- data/example/rails/app/models/album.rb +5 -0
- data/example/rails/app/models/application_record.rb +5 -0
- data/example/rails/app/models/concerns/.keep +0 -0
- data/example/rails/app/models/customer.rb +3 -0
- data/example/rails/app/models/order.rb +4 -0
- data/example/rails/app/models/product.rb +3 -0
- data/example/rails/app/models/singer.rb +4 -0
- data/example/rails/app/models/song.rb +15 -0
- data/example/rails/app/views/layouts/application.html.erb +16 -0
- data/example/rails/app/views/layouts/mailer.html.erb +13 -0
- data/example/rails/app/views/layouts/mailer.text.erb +1 -0
- data/example/rails/bin/bundle +114 -0
- data/example/rails/bin/importmap +4 -0
- data/example/rails/bin/rails +4 -0
- data/example/rails/bin/rake +4 -0
- data/example/rails/bin/setup +33 -0
- data/example/rails/config/application.rb +37 -0
- data/example/rails/config/boot.rb +4 -0
- data/example/rails/config/cable.yml +10 -0
- data/example/rails/config/credentials.yml.enc +1 -0
- data/example/rails/config/database.yml +18 -0
- data/example/rails/config/environment.rb +5 -0
- data/example/rails/config/environments/development.rb +70 -0
- data/example/rails/config/environments/production.rb +93 -0
- data/example/rails/config/environments/test.rb +60 -0
- data/example/rails/config/importmap.rb +7 -0
- data/example/rails/config/initializers/assets.rb +12 -0
- data/example/rails/config/initializers/content_security_policy.rb +25 -0
- data/example/rails/config/initializers/filter_parameter_logging.rb +8 -0
- data/example/rails/config/initializers/inflections.rb +16 -0
- data/example/rails/config/initializers/permissions_policy.rb +11 -0
- data/example/rails/config/locales/en.yml +33 -0
- data/example/rails/config/puma.rb +43 -0
- data/example/rails/config/routes.rb +6 -0
- data/example/rails/config/storage.yml +34 -0
- data/example/rails/config.ru +6 -0
- data/example/rails/db/migrate/20221113100815_create_customers.rb +9 -0
- data/example/rails/db/migrate/20221113101016_create_products.rb +10 -0
- data/example/rails/db/migrate/20221113101027_create_orders.rb +11 -0
- data/example/rails/db/migrate/20221113101034_create_singers.rb +10 -0
- data/example/rails/db/migrate/20221113101039_create_albums.rb +12 -0
- data/example/rails/db/migrate/20221113101044_create_songs.rb +13 -0
- data/example/rails/db/schema.rb +58 -0
- data/example/rails/db/seeds.rb +7 -0
- data/example/rails/lib/assets/.keep +0 -0
- data/example/rails/lib/tasks/.keep +0 -0
- data/example/rails/log/.keep +0 -0
- data/example/rails/public/404.html +67 -0
- data/example/rails/public/422.html +67 -0
- data/example/rails/public/500.html +66 -0
- data/example/rails/public/apple-touch-icon-precomposed.png +0 -0
- data/example/rails/public/apple-touch-icon.png +0 -0
- data/example/rails/public/favicon.ico +0 -0
- data/example/rails/public/robots.txt +1 -0
- data/example/rails/spec/factories/factory.rb +33 -0
- data/example/rails/spec/models/album_spec.rb +5 -0
- data/example/rails/spec/models/customer_spec.rb +5 -0
- data/example/rails/spec/models/order_spec.rb +5 -0
- data/example/rails/spec/models/product_spec.rb +5 -0
- data/example/rails/spec/models/singer_spec.rb +5 -0
- data/example/rails/spec/models/song_spec.rb +5 -0
- data/example/rails/spec/rails_helper.rb +70 -0
- data/example/rails/spec/sample_spec.rb +14 -0
- data/example/rails/spec/spec_helper.rb +94 -0
- data/example/rails/spec/support/factory_bot.rb +3 -0
- data/example/rails/storage/.keep +0 -0
- data/example/rails/tmp/.keep +0 -0
- data/example/rails/tmp/pids/.keep +0 -0
- data/example/rails/tmp/storage/.keep +0 -0
- data/example/rails/vendor/.keep +0 -0
- data/example/rails/vendor/javascript/.keep +0 -0
- data/lib/database_cleaner/spanner/deletion.rb +31 -5
- data/lib/database_cleaner/spanner/version.rb +1 -1
- data/scripts/performance_test.rb +127 -0
- data/scripts/schema.sql +93 -0
- metadata +125 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90164a2a9974ce6a9a1bd0510b4643fe7016d4c6946e98626f4ce2bc14106da4
|
4
|
+
data.tar.gz: 8b41c9c5d1cc37c3dfeae451c92f46e22338b6522cf73ccb6cd165eda2a6d96b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e42bcbaf9758939dc7e9b4d9079c7decf72c9fd97dea2452bcda7390a1543037edd7e45daccf492e514de27c3be32d743eebadd404da5186b3cf56fd16d5a2b6
|
7
|
+
data.tar.gz: 1299d683a3e051c0d6fbcb2e7a4f8bc7c12092c8542b7aafd0e72b4b1eff54567ef308712b242fb4e2bbb9f1815e230d08c1594291613fa0eedfc7ec29dc98f3
|
data/.standard.yml
CHANGED
data/CHANGELOG.md
CHANGED
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,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
|
+
* ...
|
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
|
+
*/
|
File without changes
|
@@ -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
|
File without changes
|
@@ -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 @@
|
|
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,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
|