modeled_settings 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8512b7cd011ed428ea1f7acebad1c48b265122384b4e11790cb4124a7530882a
4
+ data.tar.gz: 30451e05f24c4f48e867ad702d9e0d3c7d27c9cbfee015f19559ef842482177e
5
+ SHA512:
6
+ metadata.gz: 4bc790a12a1652c283f12ce400360f9c0e19ed8903e492c1407c0f78fa191153ea6e7f08aff596fbb9031bea4bea13a5255e0f7647d203d48c65b7175aeaa464
7
+ data.tar.gz: 207edf567426e732214a1ee83c0209cfaeed60af1fa45c7e85d4c3b7586f974ee4040b22d0580cc84e93047492a6077787521a6c71c8e86eddff84e559b184d7
checksums.yaml.gz.sig ADDED
Binary file
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Modeled Settings Changelog
2
+
3
+ ## [Unreleased]
4
+
5
+ ## [0.1.0](https://github.com/tbhb/modeled_settings/releases/tag/v0.1.0)
6
+
7
+ - Initial release with barebones functionality
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) Tony Burns
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # Modeled Settings
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/modeled_settings.svg)](https://badge.fury.io/rb/modeled_settings) [![Required Ruby Version](https://img.shields.io/badge/ruby-%3E%3D%203.2-ruby.svg)](https://www.ruby-lang.org/en/downloads/) [![Required Rails Version](https://img.shields.io/badge/rails-%3E%3D%207.2-brightgreen.svg)](https://edgeguides.rubyonrails.org/) [![CI](https://github.com/tbhb/modeled_settings/actions/workflows/ci.yml/badge.svg)](https://github.com/tbhb/modeled_settings/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+
5
+ [ActiveModel](https://github.com/rails/rails/tree/main/activemodel)-based configuration for Rails applications and libraries.
6
+
7
+ > [!WARNING]
8
+ > This gem is currently in active development and should be considered alpha software. The API and functionality are subject to change without notice until a stable 1.0 release. See the [roadmap](https://github.com/users/tbhb/projects/7/views/1) for more details.
9
+
10
+ ## Prerequisites
11
+
12
+ - Ruby >= 3.2.0
13
+ - [activemodel](https://rubygems.org/gems/activemodel) >= 7.2.0
14
+ - [activesupport](https://rubygems.org/gems/activesupport) >= 7.2.0
15
+
16
+ ## License
17
+
18
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ModeledSettings
4
+ def self.deprecator # :nodoc:
5
+ @deprecator ||= ActiveSupport::Deprecation.new
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Base error class for Modeled Settings.
4
+ class ModeledSettings::Error < StandardError
5
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_model"
4
+ require "active_model/attributes"
5
+ require "active_model/model"
6
+
7
+ module ModeledSettings::Model
8
+ extend ActiveSupport::Concern
9
+
10
+ include ActiveModel::Model
11
+ include ActiveModel::Attributes
12
+
13
+ module ClassMethods
14
+ def setting(name, cast_type = nil, **options, &blk)
15
+ if block_given?
16
+ _setting_block(name, **options, &blk)
17
+ else
18
+ _setting_attribute(name, cast_type, **options)
19
+ end
20
+ end
21
+
22
+ private
23
+ def _setting_attribute(name, cast_type = nil, **options)
24
+ default = options.delete(:default)
25
+ attribute(name, cast_type, default:)
26
+
27
+ validations = {}
28
+ validations[:presence] = true if options.delete(:required)
29
+
30
+ validates(name, **validations) unless validations.empty?
31
+ true
32
+ end
33
+
34
+ def _setting_block(name, **options, &blk)
35
+ scope = Class.new do
36
+ include ModeledSettings::Model
37
+ end
38
+
39
+ scope.class_eval(&blk)
40
+
41
+ module_eval <<-RUBY, __FILE__, __LINE__ + 1
42
+ def #{name}=(settings)
43
+ if settings.is_a?(Hash)
44
+ #{name}.assign_attributes(settings)
45
+ else
46
+ super
47
+ end
48
+ end
49
+ RUBY
50
+
51
+ attribute(name, default: scope.new, **options)
52
+
53
+ validates_each(name) do |record, attr, value|
54
+ record.errors.add(attr, :invalid) unless value.valid?
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails"
4
+
5
+ require "modeled_settings"
6
+
7
+ module ModeledSettings
8
+ module Rails
9
+ # Engine for application-level configuration.
10
+ class Engine < ::Rails::Engine
11
+ isolate_namespace ModeledSettings
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ModeledSettings
4
+ module VERSION
5
+ MAJOR = 0
6
+ MINOR = 1
7
+ TINY = 0
8
+ PRE = nil
9
+
10
+ STRING = [ MAJOR, MINOR, TINY, PRE ].compact.join(".")
11
+ end
12
+
13
+ # Returns the currently loaded version of Modeled Settings as a +Gem::Version+.
14
+ def self.gem_version
15
+ Gem::Version.new VERSION::STRING
16
+ end
17
+
18
+ # Returns the currently loaded version of Modeled Settings as a string.
19
+ def self.version
20
+ VERSION::STRING
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support"
4
+ require "active_support/concern"
5
+
6
+ require_relative "modeled_settings/version"
7
+ require_relative "modeled_settings/deprecator"
8
+
9
+ module ModeledSettings
10
+ autoload :Model, "modeled_settings/model"
11
+ end
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ �p9(@��c�D���'�'J�Cv�K �a=��\��l����{��@��Z:Gx�7�IV�_�-�>��hch��������
2
+ %Nua�;{�`h��_�U�$]Q����M0�Cms�6R=oF��M�H��Y�u�n��� l��n�b��;�R��B1��ܟ餫��E�7���e�O��@rЛ�]��1yc�����މ�{Q�ť�P������D)��d�R��ୗ��C���kGVCQ�v�����&��
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: modeled_settings
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tony Burns
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MQ0wCwYDVQQDDAR0b255
14
+ MRkwFwYKCZImiZPyLGQBGRYJdG9ueWJ1cm5zMRMwEQYKCZImiZPyLGQBGRYDbmV0
15
+ MB4XDTI0MDcxNDAxMDg0OVoXDTI1MDcxNDAxMDg0OVowPzENMAsGA1UEAwwEdG9u
16
+ eTEZMBcGCgmSJomT8ixkARkWCXRvbnlidXJuczETMBEGCgmSJomT8ixkARkWA25l
17
+ dDCCAaIwDQYJKoZIhvc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GC6ZO8B+/FxtebityYd+WuwSIcGoZVdbnl/GUPzT/O+5VdEmOFfn9lG3RbL2
34
+ xZax49uLQDvhfCrzISFszjYMMzfBhgpR+j9kq0HvZhrhZJRvlu8r7KP9EDvWrkXG
35
+ Gso2iuR/JK+nlYYHnXZSMQgPTNEv7urC3s3YBLkEeZAyKSzTub/yFiZ0f1rZECNq
36
+ RdwSWsf01XE0bKBtz4/dixrX45mIFrPmGp1gobRN/q4Tq3lU
37
+ -----END CERTIFICATE-----
38
+ date: 2024-11-10 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: activemodel
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 7.2.0
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 7.2.0
54
+ - !ruby/object:Gem::Dependency
55
+ name: activesupport
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 7.2.0
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 7.2.0
68
+ - !ruby/object:Gem::Dependency
69
+ name: bundler
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 1.15.0
75
+ type: :runtime
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: 1.15.0
82
+ description: ActiveModel-based configuration for Rails applications and libraries.
83
+ email:
84
+ - tony@tonyburns.net
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - CHANGELOG.md
90
+ - MIT-LICENSE
91
+ - README.md
92
+ - lib/modeled_settings.rb
93
+ - lib/modeled_settings/deprecator.rb
94
+ - lib/modeled_settings/error.rb
95
+ - lib/modeled_settings/model.rb
96
+ - lib/modeled_settings/rails/engine.rb
97
+ - lib/modeled_settings/version.rb
98
+ homepage: https://github.com/tbhb/modeled_settings
99
+ licenses:
100
+ - MIT
101
+ metadata:
102
+ bug_tracker_uri: https://github.com/tbhb/modeled_settings/issues
103
+ changelog_uri: https://github.com/tbhb/modeled_settings/blob/v0.1.0/CHANGELOG.md
104
+ documentation_uri: https://github.com/tbhb/modeled_settings
105
+ mailing_list_uri: https://github.com/tbhb/modeled_settings/discussions
106
+ source_code_uri: https://github.com/tbhb/modeled_settings/tree/v0.1.0
107
+ rubygems_mfa_required: 'true'
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 3.2.0
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements: []
123
+ rubygems_version: 3.4.19
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: ActiveModel-based configuration for Rails applications and libraries.
127
+ test_files: []
metadata.gz.sig ADDED
Binary file