rails-brotli-cache 0.0.1 → 0.1.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 +34 -0
- data/.gitignore +9 -0
- data/README.md +88 -2
- data/Rakefile +5 -0
- data/docker-compose.yml.sample +11 -0
- data/lib/rails-brotli-cache/version.rb +3 -1
- data/lib/rails-brotli-cache.rb +69 -1
- data/rails-brotli-cache.gemspec +4 -0
- data/spec/dummy/Gemfile +45 -0
- data/spec/dummy/README.md +24 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/bin/bundle +114 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +25 -0
- data/spec/dummy/config/application.rb +37 -0
- data/spec/dummy/config/boot.rb +3 -0
- data/spec/dummy/config/credentials.yml.enc +1 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +72 -0
- data/spec/dummy/config/environments/test.rb +50 -0
- data/spec/dummy/config/initializers/assets.rb +12 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +8 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/permissions_policy.rb +11 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/master.key +1 -0
- data/spec/dummy/config/puma.rb +43 -0
- data/spec/dummy/config/routes.rb +6 -0
- data/spec/dummy/config.ru +6 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/lib/tasks/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/robots.txt +1 -0
- data/spec/dummy/vendor/.keep +0 -0
- data/spec/fixtures/sample.json +1 -0
- data/spec/rails-brotli-cache/common_spec.rb +58 -0
- data/spec/rails-brotli-cache/redis_spec.rb +41 -0
- data/spec/spec_helper.rb +7 -0
- metadata +150 -6
- data/Gemfile.lock +0 -172
- data/lib/rails-brotli-cache/main.rb +0 -5
- data/spec/rails-brotli-cache/main_spec.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 810b8a9a145f01f58923764d99f72e09bb2882cff72d0f8b2266c9f1a185d6d2
|
4
|
+
data.tar.gz: 699d0a32134d13fc64079c5f670d4b6b66b1250667fefbe286d7321a90c482be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b787598548edc438572e8450410b131b7e60fbb31e070ec036d96c85db5081764c66eb45ad389598097fbbb6fa6296055c122c45844da89fad068b5d7b82e67b
|
7
|
+
data.tar.gz: da03b287c5ecea11bebe57592ae13af97aa4327f2712e3cb9180e480b16a8cfbf4086f4564c4ff34b37b0f4651eccdba661c63aa01d19270f5711159dbf1c4ce
|
@@ -0,0 +1,34 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
test:
|
4
|
+
docker:
|
5
|
+
- image: cimg/ruby:2.7.6
|
6
|
+
- image: redis:alpine
|
7
|
+
- image: memcached:alpine
|
8
|
+
parallelism: 1
|
9
|
+
steps:
|
10
|
+
- checkout
|
11
|
+
- run: gem update --system
|
12
|
+
- run: gem install bundler
|
13
|
+
- run: sudo apt-get update --allow-releaseinfo-change
|
14
|
+
- run: bundle config set --local path 'vendor/bundle'
|
15
|
+
- run: bundle install
|
16
|
+
- run: sleep 5
|
17
|
+
- run:
|
18
|
+
name: Run specs for redis cache store
|
19
|
+
environment:
|
20
|
+
TEST_CACHE_STORE: redis_cache_store
|
21
|
+
command: bundle exec rspec spec/
|
22
|
+
- run:
|
23
|
+
name: Run specs for memcached cache store
|
24
|
+
environment:
|
25
|
+
TEST_CACHE_STORE: mem_cache_store
|
26
|
+
command: bundle exec rspec spec/
|
27
|
+
- run:
|
28
|
+
name: Run specs for in-memory cache store
|
29
|
+
command: bundle exec rspec spec/
|
30
|
+
workflows:
|
31
|
+
version: 2
|
32
|
+
test:
|
33
|
+
jobs:
|
34
|
+
- test
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,89 @@
|
|
1
|
-
# Rails Brotli Cache
|
1
|
+
# Rails Brotli Cache [![Gem Version](https://badge.fury.io/rb/rails-brotli-cache.svg)](https://badge.fury.io/rb/rails-brotli-cache) [![CircleCI](https://circleci.com/gh/pawurb/rails-brotli-cache.svg?style=svg)](https://circleci.com/gh/pawurb/rails-brotli-cache)
|
2
2
|
|
3
|
-
|
3
|
+
This gem enables support for compressing Ruby on Rails cache entries using the [Brotli compression algorithm](https://github.com/google/brotli). Brotli is a modern compression algorithm developed by Google that provides superior compression ratios and performance compared to the default Gzip algorithm.
|
4
|
+
|
5
|
+
**The gem is currently in an early stage of development. Ideas on how to improve it and PRs are welcome.**
|
6
|
+
|
7
|
+
## Benchmarks
|
8
|
+
|
9
|
+
Brotli offers a better compression and faster performance.
|
10
|
+
|
11
|
+
**~25%** better compression of a sample JSON object:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
json = File.read("sample.json") # sample 565kb JSON text
|
15
|
+
json.size # => 562033
|
16
|
+
Rails.cache.write("json", json)
|
17
|
+
RailsBrotliCache.write("json", json)
|
18
|
+
|
19
|
+
## Check the size of cache entry stored in Redis
|
20
|
+
$redis.get("json").size # => 41697
|
21
|
+
$redis.get("br-json").size # => 31601
|
22
|
+
```
|
23
|
+
|
24
|
+
**~20%** better compression of a sample ActiveRecord objects array:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
users = User.limit(100).to_a # 100 ActiveRecord objects
|
28
|
+
Rails.cache.write("users", users)
|
29
|
+
RailsBrotliCache.write("users", users)
|
30
|
+
$redis.get("users").size # => 12331
|
31
|
+
$redis.get("br-users").size # => 10299
|
32
|
+
```
|
33
|
+
|
34
|
+
|
35
|
+
**~25%** faster performance for reading/writing a larger JSON file:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
json = File.read("sample.json") # sample 565kb JSON text
|
39
|
+
|
40
|
+
Benchmark.bm do |x|
|
41
|
+
x.report("Rails.cache") do
|
42
|
+
1000.times do
|
43
|
+
Rails.cache.write("test", json)
|
44
|
+
Rails.cache.read("test")
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
x.report("RailsBrotliCache") do
|
49
|
+
1000.times do
|
50
|
+
RailsBrotliCache.write("test", json)
|
51
|
+
RailsBrotliCache.read("test")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# user system total real
|
57
|
+
# Rails.cache 5.177678 0.216435 5.394113 ( 8.296072)
|
58
|
+
# RailsBrotliCache 3.513312 0.323601 3.836913 ( 6.114179)
|
59
|
+
```
|
60
|
+
|
61
|
+
## API
|
62
|
+
|
63
|
+
`RailsBrotliCache` module exposes methods that are compatible with the default `Rails.cache`. Values are stored in the underlying `Rails.cache` store but precompressed with Brotli algorithm.
|
64
|
+
|
65
|
+
You can use it just like the default `Rails.cache` API:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
RailsBrotliCache.read("test-key") => nil
|
69
|
+
RailsBrotliCache.fetch("test-key") { 123 } => 123
|
70
|
+
RailsBrotliCache.delete("test-key")
|
71
|
+
RailsBrotliCache.read("test-key") => nil
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
Gem appends `br-` to the cache key names to prevent conflicts with previously saved cache entries. You can disable this behaviour by adding the following initializer file:
|
76
|
+
|
77
|
+
`app/config/initializers/rails-brotli-cache.rb`
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
RailsBrotliCache.disable_prefix!
|
81
|
+
```
|
82
|
+
|
83
|
+
## Testing
|
84
|
+
|
85
|
+
```bash
|
86
|
+
cp docker-compose.yml.sample docker-compose.yml
|
87
|
+
docker compose up -d
|
88
|
+
rake test_all
|
89
|
+
```
|
data/Rakefile
CHANGED
@@ -4,3 +4,8 @@ require 'rspec/core/rake_task'
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
6
|
task default: :spec
|
7
|
+
|
8
|
+
desc 'Test all cache_stores'
|
9
|
+
task :test_all do
|
10
|
+
system("TEST_CACHE_STORE=redis_cache_store bundle exec rspec spec/ && TEST_CACHE_STORE=mem_cache_store bundle exec rspec spec/ && bundle exec rspec spec/")
|
11
|
+
end
|
data/lib/rails-brotli-cache.rb
CHANGED
@@ -1,5 +1,73 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'rails-brotli-cache/version'
|
4
|
+
require 'brotli'
|
3
5
|
|
4
6
|
module RailsBrotliCache
|
7
|
+
COMPRESS_THRESHOLD = ENV.fetch("BR_CACHE_COMPRESS_THRESHOLD", 0).to_f * 1024.0
|
8
|
+
COMPRESS_QUALITY = ENV.fetch("BR_CACHE_COMPRESS_QUALITY", 5).to_i
|
9
|
+
MARK_BR_COMPRESSED = "\x02".b
|
10
|
+
@@prefix = "br-"
|
11
|
+
|
12
|
+
def self.fetch(name, options = nil, &block)
|
13
|
+
value = read(name, options)
|
14
|
+
return value if value.present?
|
15
|
+
|
16
|
+
if block_given?
|
17
|
+
value = block.call
|
18
|
+
write(name, value, options)
|
19
|
+
|
20
|
+
value
|
21
|
+
elsif options && options[:force]
|
22
|
+
raise ArgumentError, "Missing block: Calling `Cache#fetch` with `force: true` requires a block."
|
23
|
+
else
|
24
|
+
read(name, options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.write(name, value, options = nil)
|
29
|
+
serialized = Marshal.dump(value)
|
30
|
+
|
31
|
+
payload = if serialized.bytesize >= COMPRESS_THRESHOLD
|
32
|
+
MARK_BR_COMPRESSED + ::Brotli.deflate(serialized, quality: COMPRESS_QUALITY)
|
33
|
+
else
|
34
|
+
serialized
|
35
|
+
end
|
36
|
+
|
37
|
+
Rails.cache.write(
|
38
|
+
cache_key(name),
|
39
|
+
payload,
|
40
|
+
(options || {}).merge(compress: false)
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.read(name, options = nil)
|
45
|
+
payload = Rails.cache.read(
|
46
|
+
cache_key(name),
|
47
|
+
options
|
48
|
+
)
|
49
|
+
|
50
|
+
return nil unless payload.present?
|
51
|
+
|
52
|
+
serialized = if payload.start_with?(MARK_BR_COMPRESSED)
|
53
|
+
::Brotli.inflate(payload.byteslice(1..-1))
|
54
|
+
else
|
55
|
+
payload
|
56
|
+
end
|
57
|
+
|
58
|
+
Marshal.load(serialized)
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.delete(name, options = nil)
|
62
|
+
Rails.cache.delete(cache_key(name), options)
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.disable_prefix!
|
66
|
+
@@prefix = nil
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.cache_key(name)
|
70
|
+
"#{@@prefix}#{name}"
|
71
|
+
end
|
5
72
|
end
|
73
|
+
|
data/rails-brotli-cache.gemspec
CHANGED
@@ -16,5 +16,9 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.require_paths = ["lib"]
|
17
17
|
gem.license = "MIT"
|
18
18
|
gem.add_dependency "rails"
|
19
|
+
gem.add_dependency "brotli"
|
19
20
|
gem.add_development_dependency "rspec"
|
21
|
+
gem.add_development_dependency "redis"
|
22
|
+
gem.add_development_dependency "dalli"
|
23
|
+
gem.add_development_dependency "byebug"
|
20
24
|
end
|
data/spec/dummy/Gemfile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
|
+
|
4
|
+
ruby "2.7.5"
|
5
|
+
|
6
|
+
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
|
7
|
+
gem "rails", "~> 7.0.4", ">= 7.0.4.3"
|
8
|
+
|
9
|
+
# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
|
10
|
+
gem "sprockets-rails"
|
11
|
+
|
12
|
+
# Use the Puma web server [https://github.com/puma/puma]
|
13
|
+
gem "puma", "~> 5.0"
|
14
|
+
|
15
|
+
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
|
16
|
+
gem "jbuilder"
|
17
|
+
|
18
|
+
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
|
19
|
+
# gem "kredis"
|
20
|
+
|
21
|
+
# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
|
22
|
+
# gem "bcrypt", "~> 3.1.7"
|
23
|
+
|
24
|
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
25
|
+
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
|
26
|
+
|
27
|
+
# Use Sass to process CSS
|
28
|
+
# gem "sassc-rails"
|
29
|
+
|
30
|
+
group :development, :test do
|
31
|
+
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
|
32
|
+
gem "debug", platforms: %i[ mri mingw x64_mingw ]
|
33
|
+
end
|
34
|
+
|
35
|
+
group :development do
|
36
|
+
# Use console on exceptions pages [https://github.com/rails/web-console]
|
37
|
+
gem "web-console"
|
38
|
+
|
39
|
+
# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
|
40
|
+
# gem "rack-mini-profiler"
|
41
|
+
|
42
|
+
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
|
43
|
+
# gem "spring"
|
44
|
+
end
|
45
|
+
|
@@ -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
|
+
* ...
|
data/spec/dummy/Rakefile
ADDED
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
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</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" %>
|
10
|
+
</head>
|
11
|
+
|
12
|
+
<body>
|
13
|
+
<%= yield %>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -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
|
data/spec/dummy/bin/rake
ADDED
@@ -0,0 +1,25 @@
|
|
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== Removing old logs and tempfiles =="
|
21
|
+
system! "bin/rails log:clear tmp:clear"
|
22
|
+
|
23
|
+
puts "\n== Restarting application server =="
|
24
|
+
system! "bin/rails restart"
|
25
|
+
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 Dummy
|
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 @@
|
|
1
|
+
3QQlVtTisvLrhKqInPlY1i4jP47tE/OO4pM8zGjpgX0rFN57s0RLVpVIzclaCygn8Yz1l+JIDeGoghd8Nqilu/AvBwGgsb4Mlsq8MSN4sWfQYtZBkqtzsZ4WgWGdfj/LFTh1OGm+PWTPf7hA596k2plDC6oZA+p/C00d5Gs0KjDk2qBeItWN2Oyp4UBkQiDwYV+ZSMPgeLddhpR9w1rfXD6XhKM/bzSLwsh+Bq0/DqJ41ukO53S4CdgIAm9JIv4hGsG1jgOrrcFY3Uaw3rA5DQLQ5FPeJvOgeXMHs1F/xZMcTnQ7u3wBHLS2qmnVvYYHPYaxD7ZCP0EU2fkTh9ywdM+jYLOjVBHm9s1n4iOjX0T0zr55oZ932wdYSQtAjdU2EKn202Mftl0S5Xx+/8F1+bdS9oj8EttydK94--n17oCtetNlFexV2+--5L+PDgO0y2VKHQBrSd3AdQ==
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "active_support/core_ext/integer/time"
|
2
|
+
|
3
|
+
Rails.application.configure do
|
4
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
5
|
+
|
6
|
+
# In the development environment your application's code is reloaded any time
|
7
|
+
# it changes. This slows down response time but is perfect for development
|
8
|
+
# since you don't have to restart the web server when you make code changes.
|
9
|
+
config.cache_classes = false
|
10
|
+
|
11
|
+
# Do not eager load code on boot.
|
12
|
+
config.eager_load = false
|
13
|
+
|
14
|
+
# Show full error reports.
|
15
|
+
config.consider_all_requests_local = true
|
16
|
+
|
17
|
+
# Enable server timing
|
18
|
+
config.server_timing = true
|
19
|
+
|
20
|
+
# Enable/disable caching. By default caching is disabled.
|
21
|
+
# Run rails dev:cache to toggle caching.
|
22
|
+
config.cache_store = (ENV["TEST_CACHE_STORE"] || :memory_store).to_sym
|
23
|
+
|
24
|
+
# Print deprecation notices to the Rails logger.
|
25
|
+
config.active_support.deprecation = :log
|
26
|
+
|
27
|
+
# Raise exceptions for disallowed deprecations.
|
28
|
+
config.active_support.disallowed_deprecation = :raise
|
29
|
+
|
30
|
+
# Tell Active Support which deprecation messages to disallow.
|
31
|
+
config.active_support.disallowed_deprecation_warnings = []
|
32
|
+
|
33
|
+
# Raises error for missing translations.
|
34
|
+
# config.i18n.raise_on_missing_translations = true
|
35
|
+
|
36
|
+
# Annotate rendered view with file names.
|
37
|
+
# config.action_view.annotate_rendered_view_with_filenames = true
|
38
|
+
|
39
|
+
# Uncomment if you wish to allow Action Cable access from any origin.
|
40
|
+
# config.action_cable.disable_request_forgery_protection = true
|
41
|
+
end
|