prop_initializer 0.2.0 → 0.4.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 +4 -4
- data/README.md +5 -1
- data/lib/prop_initializer/property.rb +4 -3
- data/lib/prop_initializer/railtie.rb +2 -0
- data/lib/prop_initializer/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 96c417df7010839148ad78bae4904f00cc9fd4384a35acb7745633b818beb8bd
|
|
4
|
+
data.tar.gz: ec4a050a9ef18d35e878675f44e93f0df30f076bd67b7d59a261cdd0449c0cc1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 944054343092908cf84a2a7e2f072ab1d6536ed943182d25714b80f68818afc68bc35cc0b95a8b7e92261938db453eb66fe40a2a84ccfb174e3b231943ac6124
|
|
7
|
+
data.tar.gz: fd1e6b8d424d7c8ff1b28461e2bc99b9acf263fd38eef77d5f17169ee94275f4ddcf2e39af1e5654ec9135466ab757d78a9bbef666eb9026bf09b9c3903954ac
|
data/README.md
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
<a href="https://badge.fury.io/rb/prop_initializer"><img src="https://badge.fury.io/rb/prop_initializer.svg" alt="Gem Version" height="18"></a>
|
|
2
|
+
|
|
1
3
|
# Prop Initializer
|
|
2
4
|
|
|
3
5
|
## Overview
|
|
4
6
|
|
|
5
7
|
The `prop_initializer` gem is a flexible tool for defining properties on Ruby classes.
|
|
6
8
|
|
|
9
|
+

|
|
10
|
+
|
|
7
11
|
It's a fork of the [Literal Gem](https://github.com/joeldrapper/literal), with a few tweaks. We sincerely thank [Joel Drapper](https://github.com/joeldrapper) for the inspiration and base code that made this possible.
|
|
8
12
|
|
|
9
13
|
With `prop_initializer`, you can easily declare properties for any class, giving you flexible options for default values and more. However, the scope is narrowed down by removing strict typing requirements, providing a more lightweight and adaptable interface.
|
|
@@ -107,7 +111,7 @@ component.size # => :lg
|
|
|
107
111
|
While `prop_initializer` is based on the [Literal Gem](https://github.com/joeldrapper/literal), there are some important differences:
|
|
108
112
|
|
|
109
113
|
- **No Type Requirement:** [Literal](https://github.com/joeldrapper/literal)'s properties system enforces types, while `prop_initializer` omits them for flexibility. You can define properties without needing to specify a type.
|
|
110
|
-
|
|
114
|
+
|
|
111
115
|
- **Simplified Initializer:** The initialization process has been modified to avoid requiring types at the time of property definition.
|
|
112
116
|
|
|
113
117
|
## Acknowledgements
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
class PropInitializer::Property
|
|
4
4
|
ORDER = { :positional => 0, :* => 1, :keyword => 2, :** => 3, :& => 4 }.freeze
|
|
5
5
|
RUBY_KEYWORDS = %i[alias and begin break case class def do else elsif end ensure false for if in module next nil not or redo rescue retry return self super then true undef unless until when while yield].to_h { |k| [k, "__#{k}__"] }.freeze
|
|
6
|
+
GENERATOR_PROPERTY_LOCAL = "__pi_prop"
|
|
6
7
|
|
|
7
8
|
VISIBILITY_OPTIONS = Set[false, :private, :protected, :public].freeze
|
|
8
9
|
KIND_OPTIONS = Set[:positional, :*, :keyword, :**, :&].freeze
|
|
@@ -126,7 +127,7 @@ class PropInitializer::Property
|
|
|
126
127
|
|
|
127
128
|
def generate_initializer_handle_property(buffer = +"")
|
|
128
129
|
buffer << " # " << @name.name << "\n" <<
|
|
129
|
-
"
|
|
130
|
+
" #{GENERATOR_PROPERTY_LOCAL} = properties[:" << @name.name << "]\n"
|
|
130
131
|
|
|
131
132
|
if @kind == :keyword && ruby_keyword?
|
|
132
133
|
generate_initializer_escape_keyword(buffer)
|
|
@@ -156,7 +157,7 @@ class PropInitializer::Property
|
|
|
156
157
|
def generate_initializer_coerce_property(buffer = +"")
|
|
157
158
|
buffer <<
|
|
158
159
|
escaped_name <<
|
|
159
|
-
"=
|
|
160
|
+
"= #{GENERATOR_PROPERTY_LOCAL}.coerce(" <<
|
|
160
161
|
escaped_name <<
|
|
161
162
|
", context: self)\n"
|
|
162
163
|
end
|
|
@@ -169,7 +170,7 @@ class PropInitializer::Property
|
|
|
169
170
|
escaped_name <<
|
|
170
171
|
"\n " <<
|
|
171
172
|
escaped_name <<
|
|
172
|
-
" =
|
|
173
|
+
" = #{GENERATOR_PROPERTY_LOCAL}.default_value\n end\n"
|
|
173
174
|
end
|
|
174
175
|
|
|
175
176
|
def generate_initializer_assign_value(buffer = +"")
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: prop_initializer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Paul Bob
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-05-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: zeitwerk
|
|
@@ -49,7 +49,7 @@ licenses:
|
|
|
49
49
|
- MIT
|
|
50
50
|
metadata:
|
|
51
51
|
homepage_uri: https://github.com/avo-hq/prop_initializer
|
|
52
|
-
post_install_message:
|
|
52
|
+
post_install_message:
|
|
53
53
|
rdoc_options: []
|
|
54
54
|
require_paths:
|
|
55
55
|
- lib
|
|
@@ -64,8 +64,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
64
64
|
- !ruby/object:Gem::Version
|
|
65
65
|
version: '0'
|
|
66
66
|
requirements: []
|
|
67
|
-
rubygems_version: 3.5.
|
|
68
|
-
signing_key:
|
|
67
|
+
rubygems_version: 3.5.22
|
|
68
|
+
signing_key:
|
|
69
69
|
specification_version: 4
|
|
70
70
|
summary: A flexible property initializer for Ruby classes inspired by the Literal
|
|
71
71
|
gem.
|