active_record_has 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.rubocop.yml +8 -0
  4. data/CHANGELOG.md +5 -0
  5. data/CODE_OF_CONDUCT.md +132 -0
  6. data/README.md +35 -0
  7. data/Rakefile +16 -0
  8. data/lib/active_record_has/reflection_methods.rb +15 -0
  9. data/lib/active_record_has/through_methods.rb +43 -0
  10. data/lib/active_record_has/version.rb +5 -0
  11. data/lib/active_record_has.rb +23 -0
  12. data/sample/Rakefile +8 -0
  13. data/sample/app/assets/stylesheets/application.css +1 -0
  14. data/sample/app/controllers/application_controller.rb +4 -0
  15. data/sample/app/helpers/application_helper.rb +4 -0
  16. data/sample/app/importers/categories_importer.rb +7 -0
  17. data/sample/app/importers/tags_importer.rb +7 -0
  18. data/sample/app/models/application_record.rb +6 -0
  19. data/sample/app/models/article.rb +7 -0
  20. data/sample/app/models/article_tag.rb +6 -0
  21. data/sample/app/models/category.rb +5 -0
  22. data/sample/app/models/concerns/.keep +0 -0
  23. data/sample/app/models/tag.rb +6 -0
  24. data/sample/app/views/layouts/application.html.erb +15 -0
  25. data/sample/bin/rails +6 -0
  26. data/sample/bin/rake +6 -0
  27. data/sample/bin/setup +35 -0
  28. data/sample/config/application.rb +37 -0
  29. data/sample/config/boot.rb +7 -0
  30. data/sample/config/credentials.yml.enc +1 -0
  31. data/sample/config/database.yml +25 -0
  32. data/sample/config/environment.rb +7 -0
  33. data/sample/config/environments/development.rb +61 -0
  34. data/sample/config/environments/production.rb +75 -0
  35. data/sample/config/environments/test.rb +56 -0
  36. data/sample/config/initializers/content_security_policy.rb +27 -0
  37. data/sample/config/initializers/filter_parameter_logging.rb +10 -0
  38. data/sample/config/initializers/inflections.rb +18 -0
  39. data/sample/config/initializers/permissions_policy.rb +15 -0
  40. data/sample/config/locales/en.yml +31 -0
  41. data/sample/config/master.key +1 -0
  42. data/sample/config/puma.rb +37 -0
  43. data/sample/config/routes.rb +12 -0
  44. data/sample/config.ru +8 -0
  45. data/sample/db/data/categories.yaml +3 -0
  46. data/sample/db/data/tags.yaml +3 -0
  47. data/sample/db/migrate/20240711153022_create_categories.rb +11 -0
  48. data/sample/db/migrate/20240711153202_create_tags.rb +11 -0
  49. data/sample/db/migrate/20240711161946_create_articles.rb +13 -0
  50. data/sample/db/migrate/20240711162033_create_article_tags.rb +12 -0
  51. data/sample/db/schema.rb +49 -0
  52. data/sample/db/seeds.rb +6 -0
  53. data/sample/public/404.html +67 -0
  54. data/sample/public/422.html +67 -0
  55. data/sample/public/500.html +66 -0
  56. data/sample/public/apple-touch-icon-precomposed.png +0 -0
  57. data/sample/public/apple-touch-icon.png +0 -0
  58. data/sample/public/favicon.ico +0 -0
  59. data/sample/public/robots.txt +1 -0
  60. data/sample/storage/development.sqlite3 +0 -0
  61. data/sample/storage/development.sqlite3-shm +0 -0
  62. data/sample/storage/development.sqlite3-wal +0 -0
  63. data/sample/storage/test.sqlite3 +0 -0
  64. data/sample/tmp/local_secret.txt +1 -0
  65. data/sig/active_record_has.rbs +4 -0
  66. metadata +123 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 71f6c9131c39ae54abd765e1c77383fe5b9039020a0d34a577f3df094cac53bf
4
+ data.tar.gz: dd0c7139e76ecb10c44b843f4120bc65b2f813359ed1006d8baa0288026e4ca7
5
+ SHA512:
6
+ metadata.gz: 19104844486e1b8d2757a2c678913d0d0f821c92f52aba6ae274750a85d38234481f0724462dab0b634f11965b481b138d57370b2ad90e53a435571a891479ce
7
+ data.tar.gz: f68a81cb9bf9dc7cc0a9e9f59cd1ed5c96df6ad4d2f5671c652f7157fbae27b43b4297715bed1a428d02dc6b2d9d3574f80dc48788d6ce5ec92cae84502cdc4e
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require rails_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.0
3
+
4
+ Style/StringLiterals:
5
+ EnforcedStyle: double_quotes
6
+
7
+ Style/StringLiteralsInInterpolation:
8
+ EnforcedStyle: double_quotes
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2024-07-12
4
+
5
+ - Initial release
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [Mozilla CoC]: https://github.com/mozilla/diversity
131
+ [FAQ]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # ActiveRecordHas
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/active_record_has`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+ If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/active_record_has. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/active_record_has/blob/master/CODE_OF_CONDUCT.md).
32
+
33
+ ## Code of Conduct
34
+
35
+ Everyone interacting in the ActiveRecordHas project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/active_record_has/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "sample/config/application"
4
+
5
+ require "bundler/gem_tasks"
6
+ require "rspec/core/rake_task"
7
+
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ require "rubocop/rake_task"
11
+
12
+ RuboCop::RakeTask.new
13
+
14
+ task default: %i[spec rubocop]
15
+
16
+ Rails.application.load_tasks
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecordHas
4
+ module ReflectionMethods
5
+ def arel_join_condition
6
+ klass.arel_table[join_primary_key].eq(
7
+ active_record.arel_table[join_foreign_key]
8
+ )
9
+ end
10
+
11
+ def foreign_scope
12
+ klass.where(arel_join_condition).select(1).except(:order)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecordHas
4
+ module ThroughMethods
5
+ #ActiveRecord::Reflection::ThroughReflection(
6
+ # @class_name="Tag",
7
+ # @inverse_which_updates_counter_cache_defined=false,
8
+ # @delegate_reflection=ActiveRecord::Reflection::HasManyReflection(
9
+ # @inverse_which_updates_counter_cache_defined=false,
10
+ # @name=:tags,
11
+ # @options={
12
+ # :through=>:article_tags
13
+ # },
14
+ # @active_record=
15
+ # Article(id: integer, title: string, category_id: integer, body: text, created_at: datetime, updated_at: datetime),
16
+ # @klass=nil,
17
+ # @plural_name="tags",
18
+ # @join_table=nil,
19
+ # @foreign_key=nil,
20
+ # @association_foreign_key=nil,
21
+ # @association_primary_key=nil
22
+ # ),
23
+ # @klass=Tag(id: integer, name: string, created_at: datetime, updated_at: datetime),
24
+ # @source_reflection_name=:tag
25
+ #)
26
+ def through_reflection
27
+ @through_reflection ||= active_record.reflections[options[:through]&.to_s]
28
+ end
29
+
30
+ def arel_join_condition
31
+ raise Error unless through_reflection
32
+
33
+ through_reflection.arel_join_condition
34
+ end
35
+
36
+ def foreign_scope
37
+ through = options[:through]
38
+ raise Error unless through
39
+
40
+ klass.joins(through).where(arel_join_condition).select(1).except(:order)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecordHas
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_record"
4
+ require_relative "active_record_has/version"
5
+ require_relative "active_record_has/reflection_methods"
6
+ require_relative "active_record_has/through_methods"
7
+
8
+ ActiveRecord::Reflection::BelongsToReflection.include ActiveRecordHas::ReflectionMethods
9
+ ActiveRecord::Reflection::HasManyReflection.include ActiveRecordHas::ReflectionMethods
10
+ ActiveRecord::Reflection::ThroughReflection.include ActiveRecordHas::ThroughMethods
11
+
12
+ module ActiveRecordHas
13
+ class Error < StandardError; end
14
+
15
+ def has(association, &block)
16
+ reflection = reflections[association.to_s]
17
+ raise Error unless reflection
18
+
19
+ foreign_scope = reflection.foreign_scope
20
+ foreign_scope = block.call(foreign_scope) if block
21
+ where(foreign_scope.arel.exists)
22
+ end
23
+ end
data/sample/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
4
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
5
+
6
+ require_relative "config/application"
7
+
8
+ Rails.application.load_tasks
@@ -0,0 +1 @@
1
+ /* Application styles */
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationController < ActionController::Base
4
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationHelper
4
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CategoriesImporter < DataImp::Porter
4
+ def import
5
+ Category.find_or_create_by(name: name)
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class TagsImporter < DataImp::Porter
4
+ def import
5
+ Tag.find_or_create_by(name: name)
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ extend ActiveRecordHas
5
+ primary_abstract_class
6
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Article < ApplicationRecord
4
+ belongs_to :category
5
+ has_many :article_tags
6
+ has_many :tags, through: :article_tags
7
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ArticleTag < ApplicationRecord
4
+ belongs_to :article
5
+ belongs_to :tag
6
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Category < ApplicationRecord
4
+ has_many :article
5
+ end
File without changes
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Tag < ApplicationRecord
4
+ has_many :article_tags
5
+ has_many :articles, through: :article_tags
6
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>SqliteSample</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
+ </head>
11
+
12
+ <body>
13
+ <%= yield %>
14
+ </body>
15
+ </html>
data/sample/bin/rails ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ APP_PATH = File.expand_path("../config/application", __dir__)
5
+ require_relative "../config/boot"
6
+ require "rails/commands"
data/sample/bin/rake ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../config/boot"
5
+ require "rake"
6
+ Rake.application.run
data/sample/bin/setup ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "fileutils"
5
+
6
+ # path to your application root.
7
+ APP_ROOT = File.expand_path("..", __dir__)
8
+
9
+ def system!(*args)
10
+ system(*args, exception: true)
11
+ end
12
+
13
+ FileUtils.chdir APP_ROOT do
14
+ # This script is a way to set up or update your development environment automatically.
15
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
16
+ # Add necessary setup steps to this file.
17
+
18
+ puts "== Installing dependencies =="
19
+ system! "gem install bundler --conservative"
20
+ system("bundle check") || system!("bundle install")
21
+
22
+ # puts "\n== Copying sample files =="
23
+ # unless File.exist?("config/database.yml")
24
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
25
+ # end
26
+
27
+ puts "\n== Preparing database =="
28
+ system! "bin/rails db:prepare"
29
+
30
+ puts "\n== Removing old logs and tempfiles =="
31
+ system! "bin/rails log:clear tmp:clear"
32
+
33
+ puts "\n== Restarting application server =="
34
+ system! "bin/rails restart"
35
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "boot"
4
+
5
+ require "rails"
6
+ require "active_model/railtie"
7
+ require "active_record/railtie"
8
+ require "action_controller/railtie"
9
+ require "action_view/railtie"
10
+ require "active_record_has"
11
+
12
+ # Require the gems listed in Gemfile, including any gems
13
+ # you've limited to :test, :development, or :production.
14
+ Bundler.require(*Rails.groups)
15
+
16
+ module SqliteSample
17
+ class Application < Rails::Application
18
+ # Initialize configuration defaults for originally generated Rails version.
19
+ config.load_defaults 7.1
20
+
21
+ # Please, add to the `ignore` list any other `lib` subdirectories that do
22
+ # not contain `.rb` files, or that should not be reloaded or eager loaded.
23
+ # Common ones are `templates`, `generators`, or `middleware`, for example.
24
+ config.autoload_lib(ignore: %w[assets tasks])
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,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __dir__)
4
+
5
+ require "bundler/setup" # Set up gems listed in the Gemfile.
6
+ require "bootsnap/setup" # Speed up boot time by caching expensive operations.
7
+ $LOAD_PATH.unshift File.expand_path("../../lib", __dir__)
@@ -0,0 +1 @@
1
+ 4yZ66VzNFNsG/IJK7T8Ge2B1IQ4auCX6lP7fhmtieSsHFRfadNvGbqycBP/UeLe/Ee7/hzM6XOuBtI2+l5QKEfRqQUUYe+IB0jQxR05RA0BjE4NMRhYodGqtz65IhTtB6cREXyZUvNRvRtG6Mm6yoFqXum4Zv555xOiz1ghNeoR5+iaRJiR9Y+BdOIy/6vN3REeS7vxAR/8VZOLhUBjteSikOSLoBngMGxBkxcQ8HVCv9f7URA4MAKWw9tMTptvkSvvuF8/M4EXxiLsln8sn5rOfKkxsNO9gjDL5awgm13SSYaWuCflz1upqNhsx7YW9xgFCLJgZVlHTJ8HhRlE6uVyUvp90mAoBamoOw1JV1yS4la4IaG7idYjxedF1mkrtjo8Mn9brUFNj+bcoNmB/TUU1a2bo--7FBPTk7D5shz6gLL--Pxy9qP1V8Byk6E97MCrsfA==
@@ -0,0 +1,25 @@
1
+ # SQLite. Versions 3.8.0 and up are supported.
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem "sqlite3"
6
+ #
7
+ default: &default
8
+ adapter: sqlite3
9
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10
+ timeout: 5000
11
+
12
+ development:
13
+ <<: *default
14
+ database: storage/development.sqlite3
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
19
+ test:
20
+ <<: *default
21
+ database: storage/test.sqlite3
22
+
23
+ production:
24
+ <<: *default
25
+ database: storage/production.sqlite3
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Load the Rails application.
4
+ require_relative "application"
5
+
6
+ # Initialize the Rails application.
7
+ Rails.application.initialize!
@@ -0,0 +1,61 @@
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
+ # In the development environment your application's code is reloaded any time
9
+ # it changes. This slows down response time but is perfect for development
10
+ # since you don't have to restart the web server when you make code changes.
11
+ config.enable_reloading = true
12
+
13
+ # Do not eager load code on boot.
14
+ config.eager_load = false
15
+
16
+ # Show full error reports.
17
+ config.consider_all_requests_local = true
18
+
19
+ # Enable server timing
20
+ config.server_timing = true
21
+
22
+ # Enable/disable caching. By default caching is disabled.
23
+ # Run rails dev:cache to toggle caching.
24
+ if Rails.root.join("tmp/caching-dev.txt").exist?
25
+ config.action_controller.perform_caching = true
26
+ config.action_controller.enable_fragment_cache_logging = true
27
+
28
+ config.cache_store = :memory_store
29
+ config.public_file_server.headers = {
30
+ "Cache-Control" => "public, max-age=#{2.days.to_i}"
31
+ }
32
+ else
33
+ config.action_controller.perform_caching = false
34
+
35
+ config.cache_store = :null_store
36
+ end
37
+
38
+ # Print deprecation notices to the Rails logger.
39
+ config.active_support.deprecation = :log
40
+
41
+ # Raise exceptions for disallowed deprecations.
42
+ config.active_support.disallowed_deprecation = :raise
43
+
44
+ # Tell Active Support which deprecation messages to disallow.
45
+ config.active_support.disallowed_deprecation_warnings = []
46
+
47
+ # Raise an error on page load if there are pending migrations.
48
+ config.active_record.migration_error = :page_load
49
+
50
+ # Highlight code that triggered database queries in logs.
51
+ config.active_record.verbose_query_logs = true
52
+
53
+ # Raises error for missing translations.
54
+ # config.i18n.raise_on_missing_translations = true
55
+
56
+ # Annotate rendered view with file names.
57
+ # config.action_view.annotate_rendered_view_with_filenames = true
58
+
59
+ # Raise error when a before_action's only/except options reference missing actions
60
+ config.action_controller.raise_on_missing_callback_actions = true
61
+ end