anchormodel 0.0.1 → 0.1.0

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/.ruby-version +1 -1
  3. data/CHANGELOG.md +12 -0
  4. data/Gemfile +3 -0
  5. data/Gemfile.lock +206 -0
  6. data/README.md +10 -5
  7. data/Rakefile +23 -3
  8. data/anchormodel.gemspec +27 -11
  9. data/doc/Anchormodel/ActiveModelTypeValue.html +10 -6
  10. data/doc/Anchormodel/Attribute.html +21 -14
  11. data/doc/Anchormodel/ModelMixin.html +14 -9
  12. data/doc/Anchormodel/Version.html +3 -3
  13. data/doc/Anchormodel.html +141 -53
  14. data/doc/_index.html +2 -2
  15. data/doc/file.README.html +37 -48
  16. data/doc/index.html +37 -48
  17. data/doc/method_list.html +8 -0
  18. data/doc/top-level-namespace.html +2 -2
  19. data/lib/anchormodel/attribute.rb +2 -2
  20. data/lib/anchormodel/model_mixin.rb +1 -1
  21. data/lib/anchormodel/version.rb +2 -2
  22. data/lib/anchormodel.rb +14 -1
  23. data/logo.svg +98 -0
  24. data/test/active_record_model/user_test.rb +51 -0
  25. data/test/dummy/.gitignore +29 -0
  26. data/test/dummy/Rakefile +6 -0
  27. data/test/dummy/app/anchormodels/locale.rb +6 -0
  28. data/test/dummy/app/anchormodels/role.rb +14 -0
  29. data/test/dummy/app/helpers/application_helper.rb +2 -0
  30. data/test/dummy/app/models/application_record.rb +5 -0
  31. data/test/dummy/app/models/concerns/.keep +0 -0
  32. data/test/dummy/app/models/user.rb +4 -0
  33. data/test/dummy/bin/rails +4 -0
  34. data/test/dummy/bin/rake +4 -0
  35. data/test/dummy/bin/setup +33 -0
  36. data/test/dummy/config/application.rb +37 -0
  37. data/test/dummy/config/boot.rb +3 -0
  38. data/test/dummy/config/credentials.yml.enc +1 -0
  39. data/test/dummy/config/database.yml +8 -0
  40. data/test/dummy/config/environment.rb +5 -0
  41. data/test/dummy/config/environments/test.rb +50 -0
  42. data/test/dummy/config/initializers/content_security_policy.rb +25 -0
  43. data/test/dummy/config/initializers/filter_parameter_logging.rb +8 -0
  44. data/test/dummy/config/initializers/inflections.rb +16 -0
  45. data/test/dummy/config/initializers/permissions_policy.rb +11 -0
  46. data/test/dummy/config/locales/en.yml +33 -0
  47. data/test/dummy/config/puma.rb +43 -0
  48. data/test/dummy/config/routes.rb +6 -0
  49. data/test/dummy/config.ru +6 -0
  50. data/test/dummy/db/migrate/20230107173151_create_users.rb +10 -0
  51. data/test/dummy/db/schema.rb +21 -0
  52. data/test/dummy/db/seeds.rb +7 -0
  53. data/test/dummy/lib/tasks/.keep +0 -0
  54. data/test/dummy/log/.keep +0 -0
  55. data/test/dummy/tmp/.keep +0 -0
  56. data/test/dummy/tmp/pids/.keep +0 -0
  57. data/test/test_helper.rb +21 -0
  58. metadata +150 -13
@@ -0,0 +1,50 @@
1
+ require 'active_support/core_ext/integer/time'
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+
8
+ Rails.application.configure do
9
+ # Settings specified here will take precedence over those in config/application.rb.
10
+
11
+ # Turn false under Spring and add config.action_view.cache_template_loading = true.
12
+ config.cache_classes = true
13
+
14
+ # Eager loading loads your whole application. When running a single test locally,
15
+ # this probably isn't necessary. It's a good idea to do in a continuous integration
16
+ # system, or in some way before deploying your code.
17
+ config.eager_load = ENV['CI'].present?
18
+
19
+ # Configure public file server for tests with Cache-Control for performance.
20
+ config.public_file_server.enabled = true
21
+ config.public_file_server.headers = {
22
+ 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
23
+ }
24
+
25
+ # Show full error reports and disable caching.
26
+ config.consider_all_requests_local = true
27
+ config.action_controller.perform_caching = false
28
+ config.cache_store = :null_store
29
+
30
+ # Raise exceptions instead of rendering exception templates.
31
+ config.action_dispatch.show_exceptions = false
32
+
33
+ # Disable request forgery protection in test environment.
34
+ config.action_controller.allow_forgery_protection = false
35
+
36
+ # Print deprecation notices to the stderr.
37
+ config.active_support.deprecation = :stderr
38
+
39
+ # Raise exceptions for disallowed deprecations.
40
+ config.active_support.disallowed_deprecation = :raise
41
+
42
+ # Tell Active Support which deprecation messages to disallow.
43
+ config.active_support.disallowed_deprecation_warnings = []
44
+
45
+ # Raises error for missing translations.
46
+ # config.i18n.raise_on_missing_translations = true
47
+
48
+ # Annotate rendered view with file names.
49
+ # config.action_view.annotate_rendered_view_with_filenames = true
50
+ end
@@ -0,0 +1,25 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Define an application-wide content security policy.
4
+ # See the Securing Rails Applications Guide for more information:
5
+ # https://guides.rubyonrails.org/security.html#content-security-policy-header
6
+
7
+ # Rails.application.configure do
8
+ # config.content_security_policy do |policy|
9
+ # policy.default_src :self, :https
10
+ # policy.font_src :self, :https, :data
11
+ # policy.img_src :self, :https, :data
12
+ # policy.object_src :none
13
+ # policy.script_src :self, :https
14
+ # policy.style_src :self, :https
15
+ # # Specify URI for violation reports
16
+ # # policy.report_uri "/csp-violation-report-endpoint"
17
+ # end
18
+ #
19
+ # # Generate session nonces for permitted importmap and inline scripts
20
+ # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
21
+ # config.content_security_policy_nonce_directives = %w(script-src)
22
+ #
23
+ # # Report violations without enforcing the policy.
24
+ # # config.content_security_policy_report_only = true
25
+ # end
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure parameters to be filtered from the log file. Use this to limit dissemination of
4
+ # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
5
+ # notations and behaviors.
6
+ Rails.application.config.filter_parameters += %i[
7
+ passw secret token _key crypt salt certificate otp ssn
8
+ ]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, "\\1en"
8
+ # inflect.singular /^(ox)en/i, "\\1"
9
+ # inflect.irregular "person", "people"
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym "RESTful"
16
+ # end
@@ -0,0 +1,11 @@
1
+ # Define an application-wide HTTP permissions policy. For further
2
+ # information see https://developers.google.com/web/updates/2018/06/feature-policy
3
+ #
4
+ # Rails.application.config.permissions_policy do |f|
5
+ # f.camera :none
6
+ # f.gyroscope :none
7
+ # f.microphone :none
8
+ # f.usb :none
9
+ # f.fullscreen :self
10
+ # f.payment :self, "https://secure.example.com"
11
+ # end
@@ -0,0 +1,33 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than 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
+ # The following keys must be escaped otherwise they will not be retrieved by
20
+ # the default I18n backend:
21
+ #
22
+ # true, false, on, off, yes, no
23
+ #
24
+ # Instead, surround them with single quotes.
25
+ #
26
+ # en:
27
+ # "true": "foo"
28
+ #
29
+ # To learn more, please read the Rails Internationalization guide
30
+ # available at https://guides.rubyonrails.org/i18n.html.
31
+
32
+ en:
33
+ hello: "Hello world"
@@ -0,0 +1,43 @@
1
+ # Puma can serve each request in a thread from an internal thread pool.
2
+ # The `threads` method setting takes two numbers: a minimum and maximum.
3
+ # Any libraries that use thread pools should be configured to match
4
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
+ # and maximum; this matches the default thread size of Active Record.
6
+ #
7
+ max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
8
+ min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
9
+ threads min_threads_count, max_threads_count
10
+
11
+ # Specifies the `worker_timeout` threshold that Puma will use to wait before
12
+ # terminating a worker in development environments.
13
+ #
14
+ worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development'
15
+
16
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
17
+ #
18
+ port ENV.fetch('PORT', 3000)
19
+
20
+ # Specifies the `environment` that Puma will run in.
21
+ #
22
+ environment ENV.fetch('RAILS_ENV') { 'development' }
23
+
24
+ # Specifies the `pidfile` that Puma will use.
25
+ pidfile ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' }
26
+
27
+ # Specifies the number of `workers` to boot in clustered mode.
28
+ # Workers are forked web server processes. If using threads and workers together
29
+ # the concurrency of the application would be max `threads` * `workers`.
30
+ # Workers do not work on JRuby or Windows (both of which do not support
31
+ # processes).
32
+ #
33
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
34
+
35
+ # Use the `preload_app!` method when specifying a `workers` number.
36
+ # This directive tells Puma to first boot the application and load code
37
+ # before forking the application. This takes advantage of Copy On Write
38
+ # process behavior so workers use less memory.
39
+ #
40
+ # preload_app!
41
+
42
+ # Allow puma to be restarted by `bin/rails restart` command.
43
+ plugin :tmp_restart
@@ -0,0 +1,6 @@
1
+ Rails.application.routes.draw do
2
+ # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
3
+
4
+ # Defines the root path route ("/")
5
+ # root "articles#index"
6
+ end
@@ -0,0 +1,6 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require_relative 'config/environment'
4
+
5
+ run Rails.application
6
+ Rails.application.load_server
@@ -0,0 +1,10 @@
1
+ class CreateUsers < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :users do |t|
4
+ t.string :role
5
+ t.string :locale
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,21 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # This file is the source Rails uses to define your schema when running `bin/rails
6
+ # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema[7.0].define(version: 2023_01_07_173151) do
14
+ create_table "users", force: :cascade do |t|
15
+ t.string "role"
16
+ t.string "locale"
17
+ t.datetime "created_at", null: false
18
+ t.datetime "updated_at", null: false
19
+ end
20
+
21
+ end
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
7
+ # Character.create(name: "Luke", movie: movies.first)
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,21 @@
1
+ # Configure Rails Environment
2
+ ENV['RAILS_ENV'] = 'test'
3
+ ENV['RAILS_ROOT'] ||= "#{File.dirname(__FILE__)}../../../test/dummy"
4
+
5
+ require_relative '../test/dummy/config/environment'
6
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path('../test/dummy/db/migrate', __dir__)]
7
+ require 'rails/test_help'
8
+
9
+ # Filter out the backtrace from minitest while preserving the one from other libraries.
10
+ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
11
+
12
+ require 'rails/test_unit/reporter'
13
+ Rails::TestUnitReporter.executable = 'bin/test'
14
+
15
+ # Load fixtures from the engine
16
+ if ActiveSupport::TestCase.respond_to?(:fixture_path=)
17
+ ActiveSupport::TestCase.fixture_path = File.expand_path('fixtures', __dir__)
18
+ ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
19
+ ActiveSupport::TestCase.file_fixture_path = "#{ActiveSupport::TestCase.fixture_path}/files"
20
+ ActiveSupport::TestCase.fixtures :all
21
+ end
metadata CHANGED
@@ -1,57 +1,155 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anchormodel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Kalbermatter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-17 00:00:00.000000000 Z
11
+ date: 2023-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '7.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '7.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 13.0.6
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 13.0.6
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.14.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.14.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.43.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.43.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.17.4
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.17.4
27
83
  - !ruby/object:Gem::Dependency
28
84
  name: yard
29
85
  requirement: !ruby/object:Gem::Requirement
30
86
  requirements:
31
- - - ">="
87
+ - - "~>"
32
88
  - !ruby/object:Gem::Version
33
89
  version: 0.9.28
34
90
  type: :development
35
91
  prerelease: false
36
92
  version_requirements: !ruby/object:Gem::Requirement
37
93
  requirements:
38
- - - ">="
94
+ - - "~>"
39
95
  - !ruby/object:Gem::Version
40
96
  version: 0.9.28
41
97
  - !ruby/object:Gem::Dependency
42
98
  name: yard-activesupport-concern
43
99
  requirement: !ruby/object:Gem::Requirement
44
100
  requirements:
45
- - - ">="
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.0.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.0.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: minitest
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 5.17.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 5.17.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: minitest-reporters
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 1.5.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 1.5.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: sqlite3
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
46
144
  - !ruby/object:Gem::Version
47
- version: '0'
145
+ version: 1.6.0
48
146
  type: :development
49
147
  prerelease: false
50
148
  version_requirements: !ruby/object:Gem::Requirement
51
149
  requirements:
52
- - - ">="
150
+ - - "~>"
53
151
  - !ruby/object:Gem::Version
54
- version: '0'
152
+ version: 1.6.0
55
153
  description:
56
154
  email:
57
155
  executables: []
@@ -61,6 +159,9 @@ files:
61
159
  - ".gitignore"
62
160
  - ".ruby-version"
63
161
  - ".yardopts"
162
+ - CHANGELOG.md
163
+ - Gemfile
164
+ - Gemfile.lock
64
165
  - LICENSE
65
166
  - README.md
66
167
  - Rakefile
@@ -89,8 +190,44 @@ files:
89
190
  - lib/anchormodel/attribute.rb
90
191
  - lib/anchormodel/model_mixin.rb
91
192
  - lib/anchormodel/version.rb
92
- homepage:
93
- licenses: []
193
+ - logo.svg
194
+ - test/active_record_model/user_test.rb
195
+ - test/dummy/.gitignore
196
+ - test/dummy/Rakefile
197
+ - test/dummy/app/anchormodels/locale.rb
198
+ - test/dummy/app/anchormodels/role.rb
199
+ - test/dummy/app/helpers/application_helper.rb
200
+ - test/dummy/app/models/application_record.rb
201
+ - test/dummy/app/models/concerns/.keep
202
+ - test/dummy/app/models/user.rb
203
+ - test/dummy/bin/rails
204
+ - test/dummy/bin/rake
205
+ - test/dummy/bin/setup
206
+ - test/dummy/config.ru
207
+ - test/dummy/config/application.rb
208
+ - test/dummy/config/boot.rb
209
+ - test/dummy/config/credentials.yml.enc
210
+ - test/dummy/config/database.yml
211
+ - test/dummy/config/environment.rb
212
+ - test/dummy/config/environments/test.rb
213
+ - test/dummy/config/initializers/content_security_policy.rb
214
+ - test/dummy/config/initializers/filter_parameter_logging.rb
215
+ - test/dummy/config/initializers/inflections.rb
216
+ - test/dummy/config/initializers/permissions_policy.rb
217
+ - test/dummy/config/locales/en.yml
218
+ - test/dummy/config/puma.rb
219
+ - test/dummy/config/routes.rb
220
+ - test/dummy/db/migrate/20230107173151_create_users.rb
221
+ - test/dummy/db/schema.rb
222
+ - test/dummy/db/seeds.rb
223
+ - test/dummy/lib/tasks/.keep
224
+ - test/dummy/log/.keep
225
+ - test/dummy/tmp/.keep
226
+ - test/dummy/tmp/pids/.keep
227
+ - test/test_helper.rb
228
+ homepage: https://github.com/kalsan/anchormodel
229
+ licenses:
230
+ - LGPL-3.0-or-later
94
231
  metadata: {}
95
232
  post_install_message:
96
233
  rdoc_options: []
@@ -107,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
244
  - !ruby/object:Gem::Version
108
245
  version: '0'
109
246
  requirements: []
110
- rubygems_version: 3.2.33
247
+ rubygems_version: 3.3.26
111
248
  signing_key:
112
249
  specification_version: 4
113
250
  summary: Bringing object-oriented programming to Rails enums