active_record_has 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/lib/active_record_has/scope.rb +56 -0
  3. data/lib/active_record_has/version.rb +1 -1
  4. data/lib/active_record_has.rb +6 -6
  5. metadata +4 -56
  6. data/sample/Rakefile +0 -8
  7. data/sample/app/assets/stylesheets/application.css +0 -1
  8. data/sample/app/controllers/application_controller.rb +0 -4
  9. data/sample/app/helpers/application_helper.rb +0 -4
  10. data/sample/app/importers/categories_importer.rb +0 -7
  11. data/sample/app/importers/tags_importer.rb +0 -7
  12. data/sample/app/models/application_record.rb +0 -6
  13. data/sample/app/models/article.rb +0 -7
  14. data/sample/app/models/article_tag.rb +0 -6
  15. data/sample/app/models/category.rb +0 -5
  16. data/sample/app/models/concerns/.keep +0 -0
  17. data/sample/app/models/tag.rb +0 -6
  18. data/sample/app/views/layouts/application.html.erb +0 -15
  19. data/sample/bin/rails +0 -6
  20. data/sample/bin/rake +0 -6
  21. data/sample/bin/setup +0 -35
  22. data/sample/config/application.rb +0 -37
  23. data/sample/config/boot.rb +0 -7
  24. data/sample/config/credentials.yml.enc +0 -1
  25. data/sample/config/database.yml +0 -25
  26. data/sample/config/environment.rb +0 -7
  27. data/sample/config/environments/development.rb +0 -61
  28. data/sample/config/environments/production.rb +0 -75
  29. data/sample/config/environments/test.rb +0 -56
  30. data/sample/config/initializers/content_security_policy.rb +0 -27
  31. data/sample/config/initializers/filter_parameter_logging.rb +0 -10
  32. data/sample/config/initializers/inflections.rb +0 -18
  33. data/sample/config/initializers/permissions_policy.rb +0 -15
  34. data/sample/config/locales/en.yml +0 -31
  35. data/sample/config/master.key +0 -1
  36. data/sample/config/puma.rb +0 -37
  37. data/sample/config/routes.rb +0 -12
  38. data/sample/config.ru +0 -8
  39. data/sample/db/data/categories.yaml +0 -3
  40. data/sample/db/data/tags.yaml +0 -3
  41. data/sample/db/migrate/20240711153022_create_categories.rb +0 -11
  42. data/sample/db/migrate/20240711153202_create_tags.rb +0 -11
  43. data/sample/db/migrate/20240711161946_create_articles.rb +0 -13
  44. data/sample/db/migrate/20240711162033_create_article_tags.rb +0 -12
  45. data/sample/db/schema.rb +0 -49
  46. data/sample/db/seeds.rb +0 -6
  47. data/sample/public/404.html +0 -67
  48. data/sample/public/422.html +0 -67
  49. data/sample/public/500.html +0 -66
  50. data/sample/public/apple-touch-icon-precomposed.png +0 -0
  51. data/sample/public/apple-touch-icon.png +0 -0
  52. data/sample/public/favicon.ico +0 -0
  53. data/sample/public/robots.txt +0 -1
  54. data/sample/storage/development.sqlite3 +0 -0
  55. data/sample/storage/development.sqlite3-shm +0 -0
  56. data/sample/storage/development.sqlite3-wal +0 -0
  57. data/sample/storage/test.sqlite3 +0 -0
  58. data/sample/tmp/local_secret.txt +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71f6c9131c39ae54abd765e1c77383fe5b9039020a0d34a577f3df094cac53bf
4
- data.tar.gz: dd0c7139e76ecb10c44b843f4120bc65b2f813359ed1006d8baa0288026e4ca7
3
+ metadata.gz: a8e6638722e38048167aaadfc8a1d56f0381808394023137b361a58d415d2408
4
+ data.tar.gz: a1fabbc4b3002c51a0504cdad5e60ee105f1d44c8e4ccbe5243ed9cd7280812b
5
5
  SHA512:
6
- metadata.gz: 19104844486e1b8d2757a2c678913d0d0f821c92f52aba6ae274750a85d38234481f0724462dab0b634f11965b481b138d57370b2ad90e53a435571a891479ce
7
- data.tar.gz: f68a81cb9bf9dc7cc0a9e9f59cd1ed5c96df6ad4d2f5671c652f7157fbae27b43b4297715bed1a428d02dc6b2d9d3574f80dc48788d6ce5ec92cae84502cdc4e
6
+ metadata.gz: 73ae0efb26f616ef5f69e067e30720fafca90c3c2dde0bf5b3f2c84b625d02eca4095be04dd42f17c9f55a0f8c516ae769c1693dbf18197f2b84ecb4c0ae70a5
7
+ data.tar.gz: cd17d4d95812570ba2c14ccc76d176c1fee784c5cce8eb1bf252864331c9e2ea55c965bd718c1e58ae982f69d2bcf40d7f7e9189eec2e656c613125cb2779b07
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecordHas
4
+ class Scope
5
+ attr_reader :model, :association, :relation, :reflection, :options, :block
6
+
7
+ def initialize(model, association, relation, **options, &block)
8
+ @model = model
9
+ @association = association
10
+ @block = block
11
+ @options = options
12
+ @reflection ||=
13
+ if association.is_a? Symbol
14
+ @relation = relation if relation.is_a? ActiveRecord::Relation
15
+ @reflection = reflections[association.to_s]
16
+ elsif association.is_a? ActiveRecord::Relation
17
+ @relation = association
18
+ model_name = association.model_name
19
+ @reflection = reflections[model_name.plural] || reflections[model_name.singular]
20
+ else
21
+ nil
22
+ end
23
+ end
24
+
25
+ delegate :reflections, to: :model
26
+
27
+ def reflection
28
+ @reflection ||=
29
+ if association.is_a? Symbol
30
+ @reflection = reflections[association.to_s]
31
+ elsif association.is_a? ActiveRecord::Relation
32
+ model_name = association.model_name
33
+ @reflection = reflections[model_name.plural] || reflections[model_name.singular]
34
+ else
35
+ nil
36
+ end
37
+ end
38
+
39
+ def scope
40
+ raise Error unless reflection
41
+
42
+ @scope ||=
43
+ begin
44
+ result = reflection.foreign_scope
45
+ result = result.instance_eval(&block) if block
46
+ result = result.merge(relation) if relation
47
+ result = result.where(**options) if options.present?
48
+ result
49
+ end
50
+ end
51
+
52
+ def exists
53
+ scope.arel.exists
54
+ end
55
+ end
56
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecordHas
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -4,6 +4,7 @@ require "active_record"
4
4
  require_relative "active_record_has/version"
5
5
  require_relative "active_record_has/reflection_methods"
6
6
  require_relative "active_record_has/through_methods"
7
+ require_relative "active_record_has/scope"
7
8
 
8
9
  ActiveRecord::Reflection::BelongsToReflection.include ActiveRecordHas::ReflectionMethods
9
10
  ActiveRecord::Reflection::HasManyReflection.include ActiveRecordHas::ReflectionMethods
@@ -12,12 +13,11 @@ ActiveRecord::Reflection::ThroughReflection.include ActiveRecordHas::ThroughMeth
12
13
  module ActiveRecordHas
13
14
  class Error < StandardError; end
14
15
 
15
- def has(association, &block)
16
- reflection = reflections[association.to_s]
17
- raise Error unless reflection
16
+ def has(association, relation=nil, **options, &block)
17
+ where(Scope.new(self, association, relation, **options, &block).exists)
18
+ end
18
19
 
19
- foreign_scope = reflection.foreign_scope
20
- foreign_scope = block.call(foreign_scope) if block
21
- where(foreign_scope.arel.exists)
20
+ def has_not(association, relation=nil, **options, &block)
21
+ where.not(Scope.new(self, association, relation, **options, &block).exists)
22
22
  end
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_has
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Ferney
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-15 00:00:00.000000000 Z
11
+ date: 2024-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -39,68 +39,16 @@ files:
39
39
  - Rakefile
40
40
  - lib/active_record_has.rb
41
41
  - lib/active_record_has/reflection_methods.rb
42
+ - lib/active_record_has/scope.rb
42
43
  - lib/active_record_has/through_methods.rb
43
44
  - lib/active_record_has/version.rb
44
- - sample/Rakefile
45
- - sample/app/assets/stylesheets/application.css
46
- - sample/app/controllers/application_controller.rb
47
- - sample/app/helpers/application_helper.rb
48
- - sample/app/importers/categories_importer.rb
49
- - sample/app/importers/tags_importer.rb
50
- - sample/app/models/application_record.rb
51
- - sample/app/models/article.rb
52
- - sample/app/models/article_tag.rb
53
- - sample/app/models/category.rb
54
- - sample/app/models/concerns/.keep
55
- - sample/app/models/tag.rb
56
- - sample/app/views/layouts/application.html.erb
57
- - sample/bin/rails
58
- - sample/bin/rake
59
- - sample/bin/setup
60
- - sample/config.ru
61
- - sample/config/application.rb
62
- - sample/config/boot.rb
63
- - sample/config/credentials.yml.enc
64
- - sample/config/database.yml
65
- - sample/config/environment.rb
66
- - sample/config/environments/development.rb
67
- - sample/config/environments/production.rb
68
- - sample/config/environments/test.rb
69
- - sample/config/initializers/content_security_policy.rb
70
- - sample/config/initializers/filter_parameter_logging.rb
71
- - sample/config/initializers/inflections.rb
72
- - sample/config/initializers/permissions_policy.rb
73
- - sample/config/locales/en.yml
74
- - sample/config/master.key
75
- - sample/config/puma.rb
76
- - sample/config/routes.rb
77
- - sample/db/data/categories.yaml
78
- - sample/db/data/tags.yaml
79
- - sample/db/migrate/20240711153022_create_categories.rb
80
- - sample/db/migrate/20240711153202_create_tags.rb
81
- - sample/db/migrate/20240711161946_create_articles.rb
82
- - sample/db/migrate/20240711162033_create_article_tags.rb
83
- - sample/db/schema.rb
84
- - sample/db/seeds.rb
85
- - sample/public/404.html
86
- - sample/public/422.html
87
- - sample/public/500.html
88
- - sample/public/apple-touch-icon-precomposed.png
89
- - sample/public/apple-touch-icon.png
90
- - sample/public/favicon.ico
91
- - sample/public/robots.txt
92
- - sample/storage/development.sqlite3
93
- - sample/storage/development.sqlite3-shm
94
- - sample/storage/development.sqlite3-wal
95
- - sample/storage/test.sqlite3
96
- - sample/tmp/local_secret.txt
97
45
  - sig/active_record_has.rbs
98
46
  homepage: https://github.com/capnregex/active_record_has
99
47
  licenses: []
100
48
  metadata:
101
49
  homepage_uri: https://github.com/capnregex/active_record_has
102
50
  source_code_uri: https://github.com/capnregex/active_record_has
103
- changelog_uri: https://github.com/capnregex/active_record_has/releases/tag/v0.1.0
51
+ changelog_uri: https://github.com/capnregex/active_record_has/releases/tag/v0.1.2
104
52
  post_install_message:
105
53
  rdoc_options: []
106
54
  require_paths:
data/sample/Rakefile DELETED
@@ -1,8 +0,0 @@
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
@@ -1 +0,0 @@
1
- /* Application styles */
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ApplicationController < ActionController::Base
4
- end
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ApplicationHelper
4
- end
@@ -1,7 +0,0 @@
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
@@ -1,7 +0,0 @@
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
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ApplicationRecord < ActiveRecord::Base
4
- extend ActiveRecordHas
5
- primary_abstract_class
6
- end
@@ -1,7 +0,0 @@
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
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class ArticleTag < ApplicationRecord
4
- belongs_to :article
5
- belongs_to :tag
6
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Category < ApplicationRecord
4
- has_many :article
5
- end
File without changes
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Tag < ApplicationRecord
4
- has_many :article_tags
5
- has_many :articles, through: :article_tags
6
- end
@@ -1,15 +0,0 @@
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 DELETED
@@ -1,6 +0,0 @@
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 DELETED
@@ -1,6 +0,0 @@
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 DELETED
@@ -1,35 +0,0 @@
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
@@ -1,37 +0,0 @@
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
@@ -1,7 +0,0 @@
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__)
@@ -1 +0,0 @@
1
- 4yZ66VzNFNsG/IJK7T8Ge2B1IQ4auCX6lP7fhmtieSsHFRfadNvGbqycBP/UeLe/Ee7/hzM6XOuBtI2+l5QKEfRqQUUYe+IB0jQxR05RA0BjE4NMRhYodGqtz65IhTtB6cREXyZUvNRvRtG6Mm6yoFqXum4Zv555xOiz1ghNeoR5+iaRJiR9Y+BdOIy/6vN3REeS7vxAR/8VZOLhUBjteSikOSLoBngMGxBkxcQ8HVCv9f7URA4MAKWw9tMTptvkSvvuF8/M4EXxiLsln8sn5rOfKkxsNO9gjDL5awgm13SSYaWuCflz1upqNhsx7YW9xgFCLJgZVlHTJ8HhRlE6uVyUvp90mAoBamoOw1JV1yS4la4IaG7idYjxedF1mkrtjo8Mn9brUFNj+bcoNmB/TUU1a2bo--7FBPTk7D5shz6gLL--Pxy9qP1V8Byk6E97MCrsfA==
@@ -1,25 +0,0 @@
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
@@ -1,7 +0,0 @@
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!
@@ -1,61 +0,0 @@
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
@@ -1,75 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_support/core_ext/integer/time"
4
-
5
- Rails.application.configure do
6
- # Settings specified here will take precedence over those in config/application.rb.
7
-
8
- # Code is not reloaded between requests.
9
- config.enable_reloading = false
10
-
11
- # Eager load code on boot. This eager loads most of Rails and
12
- # your application in memory, allowing both threaded web servers
13
- # and those relying on copy on write to perform better.
14
- # Rake tasks automatically ignore this option for performance.
15
- config.eager_load = true
16
-
17
- # Full error reports are disabled and caching is turned on.
18
- config.consider_all_requests_local = false
19
- config.action_controller.perform_caching = true
20
-
21
- # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
22
- # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files).
23
- # config.require_master_key = true
24
-
25
- # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead.
26
- # config.public_file_server.enabled = false
27
-
28
- # Enable serving of images, stylesheets, and JavaScripts from an asset server.
29
- # config.asset_host = "http://assets.example.com"
30
-
31
- # Specifies the header that your server uses for sending files.
32
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
33
- # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
34
-
35
- # Assume all access to the app is happening through a SSL-terminating reverse proxy.
36
- # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies.
37
- # config.assume_ssl = true
38
-
39
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
40
- config.force_ssl = true
41
-
42
- # Log to STDOUT by default
43
- config.logger = ActiveSupport::Logger.new($stdout)
44
- .tap { |logger| logger.formatter = ::Logger::Formatter.new }
45
- .then { |logger| ActiveSupport::TaggedLogging.new(logger) }
46
-
47
- # Prepend all log lines with the following tags.
48
- config.log_tags = [:request_id]
49
-
50
- # "info" includes generic and useful information about system operation, but avoids logging too much
51
- # information to avoid inadvertent exposure of personally identifiable information (PII). If you
52
- # want to log everything, set the level to "debug".
53
- config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
54
-
55
- # Use a different cache store in production.
56
- # config.cache_store = :mem_cache_store
57
-
58
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
59
- # the I18n.default_locale when a translation cannot be found).
60
- config.i18n.fallbacks = true
61
-
62
- # Don't log any deprecations.
63
- config.active_support.report_deprecations = false
64
-
65
- # Do not dump schema after migrations.
66
- config.active_record.dump_schema_after_migration = false
67
-
68
- # Enable DNS rebinding protection and other `Host` header attacks.
69
- # config.hosts = [
70
- # "example.com", # Allow requests from example.com
71
- # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
72
- # ]
73
- # Skip DNS rebinding protection for the default health check endpoint.
74
- # config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
75
- end
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "active_support/core_ext/integer/time"
4
-
5
- # The test environment is used exclusively to run your application's
6
- # test suite. You never need to work with it otherwise. Remember that
7
- # your test database is "scratch space" for the test suite and is wiped
8
- # and recreated between test runs. Don't rely on the data there!
9
-
10
- Rails.application.configure do
11
- # Settings specified here will take precedence over those in config/application.rb.
12
-
13
- # While tests run files are not watched, reloading is not necessary.
14
- config.enable_reloading = false
15
-
16
- # Eager loading loads your entire application. When running a single test locally,
17
- # this is usually not necessary, and can slow down your test suite. However, it's
18
- # recommended that you enable it in continuous integration systems to ensure eager
19
- # loading is working properly before deploying your code.
20
- config.eager_load = ENV["CI"].present?
21
-
22
- # Configure public file server for tests with Cache-Control for performance.
23
- config.public_file_server.enabled = true
24
- config.public_file_server.headers = {
25
- "Cache-Control" => "public, max-age=#{1.hour.to_i}"
26
- }
27
-
28
- # Show full error reports and disable caching.
29
- config.consider_all_requests_local = true
30
- config.action_controller.perform_caching = false
31
- config.cache_store = :null_store
32
-
33
- # Render exception templates for rescuable exceptions and raise for other exceptions.
34
- config.action_dispatch.show_exceptions = :rescuable
35
-
36
- # Disable request forgery protection in test environment.
37
- config.action_controller.allow_forgery_protection = false
38
-
39
- # Print deprecation notices to the stderr.
40
- config.active_support.deprecation = :stderr
41
-
42
- # Raise exceptions for disallowed deprecations.
43
- config.active_support.disallowed_deprecation = :raise
44
-
45
- # Tell Active Support which deprecation messages to disallow.
46
- config.active_support.disallowed_deprecation_warnings = []
47
-
48
- # Raises error for missing translations.
49
- # config.i18n.raise_on_missing_translations = true
50
-
51
- # Annotate rendered view with file names.
52
- # config.action_view.annotate_rendered_view_with_filenames = true
53
-
54
- # Raise error when a before_action's only/except options reference missing actions
55
- config.action_controller.raise_on_missing_callback_actions = true
56
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Be sure to restart your server when you modify this file.
4
-
5
- # Define an application-wide content security policy.
6
- # See the Securing Rails Applications Guide for more information:
7
- # https://guides.rubyonrails.org/security.html#content-security-policy-header
8
-
9
- # Rails.application.configure do
10
- # config.content_security_policy do |policy|
11
- # policy.default_src :self, :https
12
- # policy.font_src :self, :https, :data
13
- # policy.img_src :self, :https, :data
14
- # policy.object_src :none
15
- # policy.script_src :self, :https
16
- # policy.style_src :self, :https
17
- # # Specify URI for violation reports
18
- # # policy.report_uri "/csp-violation-report-endpoint"
19
- # end
20
- #
21
- # # Generate session nonces for permitted importmap, inline scripts, and inline styles.
22
- # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
23
- # config.content_security_policy_nonce_directives = %w(script-src style-src)
24
- #
25
- # # Report violations without enforcing the policy.
26
- # # config.content_security_policy_report_only = true
27
- # end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Be sure to restart your server when you modify this file.
4
-
5
- # Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
6
- # Use this to limit dissemination of sensitive information.
7
- # See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
8
- Rails.application.config.filter_parameters += %i[
9
- passw secret token _key crypt salt certificate otp ssn
10
- ]
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Be sure to restart your server when you modify this file.
4
-
5
- # Add new inflection rules using the following format. Inflections
6
- # are locale specific, and you may define rules for as many different
7
- # locales as you wish. All of these examples are active by default:
8
- # ActiveSupport::Inflector.inflections(:en) do |inflect|
9
- # inflect.plural /^(ox)$/i, "\\1en"
10
- # inflect.singular /^(ox)en/i, "\\1"
11
- # inflect.irregular "person", "people"
12
- # inflect.uncountable %w( fish sheep )
13
- # end
14
-
15
- # These inflection rules are supported but not enabled by default:
16
- # ActiveSupport::Inflector.inflections(:en) do |inflect|
17
- # inflect.acronym "RESTful"
18
- # end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Be sure to restart your server when you modify this file.
4
-
5
- # Define an application-wide HTTP permissions policy. For further
6
- # information see: https://developers.google.com/web/updates/2018/06/feature-policy
7
-
8
- # Rails.application.config.permissions_policy do |policy|
9
- # policy.camera :none
10
- # policy.gyroscope :none
11
- # policy.microphone :none
12
- # policy.usb :none
13
- # policy.fullscreen :self
14
- # policy.payment :self, "https://secure.example.com"
15
- # end
@@ -1,31 +0,0 @@
1
- # Files in the config/locales directory are used for internationalization and
2
- # are automatically loaded by Rails. If you want to use locales other than
3
- # English, add the necessary files in this directory.
4
- #
5
- # To use the locales, use `I18n.t`:
6
- #
7
- # I18n.t "hello"
8
- #
9
- # In views, this is aliased to just `t`:
10
- #
11
- # <%= t("hello") %>
12
- #
13
- # To use a different locale, set it with `I18n.locale`:
14
- #
15
- # I18n.locale = :es
16
- #
17
- # This would use the information in config/locales/es.yml.
18
- #
19
- # To learn more about the API, please read the Rails Internationalization guide
20
- # at https://guides.rubyonrails.org/i18n.html.
21
- #
22
- # Be aware that YAML interprets the following case-insensitive strings as
23
- # booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings
24
- # must be quoted to be interpreted as strings. For example:
25
- #
26
- # en:
27
- # "yes": yup
28
- # enabled: "ON"
29
-
30
- en:
31
- hello: "Hello world"
@@ -1 +0,0 @@
1
- 80068b39fb9547cdc248628705797974
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This configuration file will be evaluated by Puma. The top-level methods that
4
- # are invoked here are part of Puma's configuration DSL. For more information
5
- # about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
6
-
7
- # Puma can serve each request in a thread from an internal thread pool.
8
- # The `threads` method setting takes two numbers: a minimum and maximum.
9
- # Any libraries that use thread pools should be configured to match
10
- # the maximum value specified for Puma. Default is set to 5 threads for minimum
11
- # and maximum; this matches the default thread size of Active Record.
12
- max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
13
- min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
14
- threads min_threads_count, max_threads_count
15
-
16
- # Specifies that the worker count should equal the number of processors in production.
17
- if ENV["RAILS_ENV"] == "production"
18
- require "concurrent-ruby"
19
- worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count })
20
- workers worker_count if worker_count > 1
21
- end
22
-
23
- # Specifies the `worker_timeout` threshold that Puma will use to wait before
24
- # terminating a worker in development environments.
25
- worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
26
-
27
- # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
28
- port ENV.fetch("PORT", 3000)
29
-
30
- # Specifies the `environment` that Puma will run in.
31
- environment ENV.fetch("RAILS_ENV", "development")
32
-
33
- # Specifies the `pidfile` that Puma will use.
34
- pidfile ENV.fetch("PIDFILE", "tmp/pids/server.pid")
35
-
36
- # Allow puma to be restarted by `bin/rails restart` command.
37
- plugin :tmp_restart
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Rails.application.routes.draw do
4
- # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
5
-
6
- # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
7
- # Can be used by load balancers and uptime monitors to verify that the app is live.
8
- get "up" => "rails/health#show", as: :rails_health_check
9
-
10
- # Defines the root path route ("/")
11
- # root "posts#index"
12
- end
data/sample/config.ru DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file is used by Rack-based servers to start the application.
4
-
5
- require_relative "config/environment"
6
-
7
- run Rails.application
8
- Rails.application.load_server
@@ -1,3 +0,0 @@
1
- ---
2
- - name: Food
3
- - name: Music
@@ -1,3 +0,0 @@
1
- ---
2
- - name: Fred
3
- - name: George
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class CreateCategories < ActiveRecord::Migration[7.1]
4
- def change
5
- create_table :categories do |t|
6
- t.string :name
7
-
8
- t.timestamps
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class CreateTags < ActiveRecord::Migration[7.1]
4
- def change
5
- create_table :tags do |t|
6
- t.string :name
7
-
8
- t.timestamps
9
- end
10
- end
11
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class CreateArticles < ActiveRecord::Migration[7.1]
4
- def change
5
- create_table :articles do |t|
6
- t.string :title
7
- t.belongs_to :category, null: false, foreign_key: true
8
- t.text :body
9
-
10
- t.timestamps
11
- end
12
- end
13
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class CreateArticleTags < ActiveRecord::Migration[7.1]
4
- def change
5
- create_table :article_tags, primary_key: %i[article_id tag_id] do |t|
6
- t.belongs_to :article, null: false, foreign_key: true
7
- t.belongs_to :tag, null: false, foreign_key: true
8
-
9
- t.timestamps
10
- end
11
- end
12
- end
data/sample/db/schema.rb DELETED
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file is auto-generated from the current state of the database. Instead
4
- # of editing this file, please use the migrations feature of Active Record to
5
- # incrementally modify your database, and then regenerate this schema definition.
6
- #
7
- # This file is the source Rails uses to define your schema when running `bin/rails
8
- # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
9
- # be faster and is potentially less error prone than running all of your
10
- # migrations from scratch. Old migrations may fail to apply correctly if those
11
- # migrations use external dependencies or application code.
12
- #
13
- # It's strongly recommended that you check this file into your version control system.
14
-
15
- ActiveRecord::Schema[7.1].define(version: 20_240_711_162_033) do
16
- create_table "article_tags", primary_key: %w[article_id tag_id], force: :cascade do |t|
17
- t.integer "article_id", null: false
18
- t.integer "tag_id", null: false
19
- t.datetime "created_at", null: false
20
- t.datetime "updated_at", null: false
21
- t.index ["article_id"], name: "index_article_tags_on_article_id"
22
- t.index ["tag_id"], name: "index_article_tags_on_tag_id"
23
- end
24
-
25
- create_table "articles", force: :cascade do |t|
26
- t.string "title"
27
- t.integer "category_id", null: false
28
- t.text "body"
29
- t.datetime "created_at", null: false
30
- t.datetime "updated_at", null: false
31
- t.index ["category_id"], name: "index_articles_on_category_id"
32
- end
33
-
34
- create_table "categories", force: :cascade do |t|
35
- t.string "name"
36
- t.datetime "created_at", null: false
37
- t.datetime "updated_at", null: false
38
- end
39
-
40
- create_table "tags", force: :cascade do |t|
41
- t.string "name"
42
- t.datetime "created_at", null: false
43
- t.datetime "updated_at", null: false
44
- end
45
-
46
- add_foreign_key "article_tags", "articles"
47
- add_foreign_key "article_tags", "tags"
48
- add_foreign_key "articles", "categories"
49
- end
data/sample/db/seeds.rb DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- DataImp.data_dir Rails.root.join("db/data").to_s
4
- DataImp.import_list <<~LIST
5
- categories.yaml
6
- LIST
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- .rails-default-error-page {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- .rails-default-error-page div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- .rails-default-error-page div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- .rails-default-error-page h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- .rails-default-error-page div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body class="rails-default-error-page">
58
- <!-- This file lives in public/404.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The page you were looking for doesn't exist.</h1>
62
- <p>You may have mistyped the address or the page may have moved.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- .rails-default-error-page {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- .rails-default-error-page div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- .rails-default-error-page div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- .rails-default-error-page h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- .rails-default-error-page div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body class="rails-default-error-page">
58
- <!-- This file lives in public/422.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The change you wanted was rejected.</h1>
62
- <p>Maybe you tried to change something you didn't have access to.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,66 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- .rails-default-error-page {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- .rails-default-error-page div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- .rails-default-error-page div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- .rails-default-error-page h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- .rails-default-error-page div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body class="rails-default-error-page">
58
- <!-- This file lives in public/500.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>We're sorry, but something went wrong.</h1>
62
- </div>
63
- <p>If you are the application owner check the logs for more information.</p>
64
- </div>
65
- </body>
66
- </html>
File without changes
File without changes
File without changes
@@ -1 +0,0 @@
1
- # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
Binary file
Binary file
Binary file
Binary file
@@ -1 +0,0 @@
1
- 1025c1c62f7b69ecfc70e3fbff3bb9c4ab7c791f892fe558e070b9d58aedfe8cf824bc808d264ea1da1dd5c771b8db48ff38933a2c63561286b9c85e275e1039