immutable_struct_ex 0.2.3 → 1.0.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/CHANGELOG.md +9 -0
- data/Gemfile.lock +24 -24
- data/README.md +22 -7
- data/immutable_struct_ex.gemspec +1 -1
- data/lib/immutable_struct_ex/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2fce441affccae142eb67911aaecfdf0886a6ea60aa505bb7ee404217ec178d3
|
|
4
|
+
data.tar.gz: b39016ae4dcf0c28c4381d391cb5597f835497b92551459a54ffb3d79331138d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 411878a19d161a2784424180a7de70e1f4fdda4d6a115ae3e4af2f54fd0781bf345ea1a51977e0707e1d8a2579bbcd30208ddb782a225679ecbb517cec86e68b
|
|
7
|
+
data.tar.gz: fa0f13ecb0161bf674a24b272a4254c6a957e7b12df10d87adde9127b9b2542b0da4858e8392ba1fe91ab4ddcaecff8ada10e9e50bf5a6eb40626d9659987957
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
### 1.0.0
|
|
2
|
+
* Changes (not really a breaking change, but just wanted to bump to 1.0.0)
|
|
3
|
+
* Limit required ruby version to ~> 3.0.
|
|
4
|
+
* Update ruby gems.
|
|
5
|
+
|
|
6
|
+
### 0.3.0
|
|
7
|
+
* Changes
|
|
8
|
+
* Update README.md file with the correct gem name.
|
|
9
|
+
|
|
1
10
|
### 0.2.3
|
|
2
11
|
* Bug fix
|
|
3
12
|
* Fix bug in specs that failed to add criteria for passing tests (e.g. ".to eq true/false") so tests could not fail.
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
immutable_struct_ex (0.
|
|
4
|
+
immutable_struct_ex (1.0.0)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
@@ -17,50 +17,50 @@ GEM
|
|
|
17
17
|
parallel (1.22.1)
|
|
18
18
|
parser (3.1.2.1)
|
|
19
19
|
ast (~> 2.4.1)
|
|
20
|
-
pry (0.
|
|
20
|
+
pry (0.14.1)
|
|
21
21
|
coderay (~> 1.1)
|
|
22
22
|
method_source (~> 1.0)
|
|
23
|
-
pry-byebug (3.
|
|
23
|
+
pry-byebug (3.10.1)
|
|
24
24
|
byebug (~> 11.0)
|
|
25
|
-
pry (
|
|
25
|
+
pry (>= 0.13, < 0.15)
|
|
26
26
|
rainbow (3.1.1)
|
|
27
27
|
rake (13.0.6)
|
|
28
28
|
reek (6.1.1)
|
|
29
29
|
kwalify (~> 0.7.0)
|
|
30
30
|
parser (~> 3.1.0)
|
|
31
31
|
rainbow (>= 2.0, < 4.0)
|
|
32
|
-
regexp_parser (2.
|
|
32
|
+
regexp_parser (2.6.0)
|
|
33
33
|
rexml (3.2.5)
|
|
34
|
-
rspec (3.
|
|
35
|
-
rspec-core (~> 3.
|
|
36
|
-
rspec-expectations (~> 3.
|
|
37
|
-
rspec-mocks (~> 3.
|
|
38
|
-
rspec-core (3.
|
|
39
|
-
rspec-support (~> 3.
|
|
40
|
-
rspec-expectations (3.
|
|
34
|
+
rspec (3.12.0)
|
|
35
|
+
rspec-core (~> 3.12.0)
|
|
36
|
+
rspec-expectations (~> 3.12.0)
|
|
37
|
+
rspec-mocks (~> 3.12.0)
|
|
38
|
+
rspec-core (3.12.0)
|
|
39
|
+
rspec-support (~> 3.12.0)
|
|
40
|
+
rspec-expectations (3.12.0)
|
|
41
41
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
42
|
-
rspec-support (~> 3.
|
|
43
|
-
rspec-mocks (3.
|
|
42
|
+
rspec-support (~> 3.12.0)
|
|
43
|
+
rspec-mocks (3.12.0)
|
|
44
44
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
45
|
-
rspec-support (~> 3.
|
|
46
|
-
rspec-support (3.
|
|
47
|
-
rubocop (1.
|
|
45
|
+
rspec-support (~> 3.12.0)
|
|
46
|
+
rspec-support (3.12.0)
|
|
47
|
+
rubocop (1.38.0)
|
|
48
48
|
json (~> 2.3)
|
|
49
49
|
parallel (~> 1.10)
|
|
50
50
|
parser (>= 3.1.2.1)
|
|
51
51
|
rainbow (>= 2.2.2, < 4.0)
|
|
52
52
|
regexp_parser (>= 1.8, < 3.0)
|
|
53
53
|
rexml (>= 3.2.5, < 4.0)
|
|
54
|
-
rubocop-ast (>= 1.
|
|
54
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
|
55
55
|
ruby-progressbar (~> 1.7)
|
|
56
56
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
57
|
-
rubocop-ast (1.
|
|
57
|
+
rubocop-ast (1.23.0)
|
|
58
58
|
parser (>= 3.1.1.0)
|
|
59
|
-
rubocop-performance (1.
|
|
59
|
+
rubocop-performance (1.15.0)
|
|
60
60
|
rubocop (>= 1.7.0, < 2.0)
|
|
61
61
|
rubocop-ast (>= 0.4.0)
|
|
62
|
-
rubocop-rspec (2.
|
|
63
|
-
rubocop (~> 1.
|
|
62
|
+
rubocop-rspec (2.15.0)
|
|
63
|
+
rubocop (~> 1.33)
|
|
64
64
|
ruby-progressbar (1.11.0)
|
|
65
65
|
simplecov (0.21.2)
|
|
66
66
|
docile (~> 1.1)
|
|
@@ -68,7 +68,7 @@ GEM
|
|
|
68
68
|
simplecov_json_formatter (~> 0.1)
|
|
69
69
|
simplecov-html (0.12.3)
|
|
70
70
|
simplecov_json_formatter (0.1.4)
|
|
71
|
-
unicode-display_width (2.
|
|
71
|
+
unicode-display_width (2.3.0)
|
|
72
72
|
|
|
73
73
|
PLATFORMS
|
|
74
74
|
x86_64-darwin-19
|
|
@@ -86,4 +86,4 @@ DEPENDENCIES
|
|
|
86
86
|
simplecov (~> 0.21.2)
|
|
87
87
|
|
|
88
88
|
BUNDLED WITH
|
|
89
|
-
2.3.
|
|
89
|
+
2.3.22
|
data/README.md
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
[](#license)
|
|
10
10
|
|
|
11
|
-
#
|
|
11
|
+
# immutable_struct_ex
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
immutable_struct_ex is yet another immutable struct. What makes immutable_struct_ex different, is that it allows you to create immutable structs in one step _by default_. In other words, other immutable struct gems force you to first define the struct, then instantiate the struct object; or, define the struct and instantiate the struct object via chaining. For example:
|
|
14
14
|
|
|
15
15
|
## Other Immutable Structs
|
|
16
16
|
|
|
@@ -24,31 +24,38 @@ some_immutable_struct = SomeImmutableStruct.new(:first, :last, :phone)
|
|
|
24
24
|
.new(first: 'John', last: 'Doe', phone: '(201) 230-7281')
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
##
|
|
28
|
-
|
|
27
|
+
## immutable_struct_ex
|
|
28
|
+
immutable_struct_ex allows you to instantiate and initialize the object _in one step:_
|
|
29
29
|
|
|
30
30
|
```ruby
|
|
31
31
|
immutable_struct_ex = ImmutableStructEx.new(first: 'John', last: 'Doe', phone: '(201) 230-7281')
|
|
32
|
+
|
|
32
33
|
immutable_struct_ex.first
|
|
33
34
|
#=> 'John'
|
|
35
|
+
|
|
34
36
|
immutable_struct_ex[:first]
|
|
35
37
|
#=> 'John'
|
|
38
|
+
|
|
36
39
|
immutable_struct_ex.last
|
|
37
40
|
#=> 'Doe'
|
|
41
|
+
|
|
38
42
|
immutable_struct_ex.phone
|
|
39
43
|
#=> '(201) 230-7281'
|
|
40
44
|
```
|
|
41
45
|
### Immutable
|
|
42
|
-
Like other immutable structs,
|
|
46
|
+
Like other immutable structs, immutable_struct_ex also removes methods that change the state of the object, making it _immutable:_
|
|
47
|
+
|
|
43
48
|
```ruby
|
|
44
49
|
immutable_struct_ex.first = 'Joe'
|
|
45
50
|
#=> NoMethodError: undefined method `first='...
|
|
51
|
+
|
|
46
52
|
immutable_struct_ex[:first] = 'Joe'
|
|
47
53
|
#=> NoMethodError: undefined method `[]='...
|
|
48
54
|
```
|
|
49
55
|
|
|
50
56
|
### Blocks
|
|
51
|
-
Also, not unlike other immutable structs,
|
|
57
|
+
Also, not unlike other immutable structs, immutable_struct_ex also allows you to pass a block:
|
|
58
|
+
|
|
52
59
|
```ruby
|
|
53
60
|
# With a block
|
|
54
61
|
immutable_struct_ex = ImmutableStructEx.new(first: 'John', last: 'Doe', phone: '(201) 230-7281') do
|
|
@@ -56,14 +63,22 @@ immutable_struct_ex = ImmutableStructEx.new(first: 'John', last: 'Doe', phone: '
|
|
|
56
63
|
first == 'John'
|
|
57
64
|
end
|
|
58
65
|
end
|
|
66
|
+
|
|
59
67
|
immutable_struct_ex.john?
|
|
60
68
|
#=> true
|
|
61
69
|
```
|
|
62
70
|
|
|
63
71
|
### Other Examples
|
|
72
|
+
Get creative. Below is an example of an immutable struct that provides _redaction_:
|
|
73
|
+
|
|
64
74
|
```ruby
|
|
65
75
|
# Redactable, immutable struct
|
|
66
|
-
user = {
|
|
76
|
+
user = {
|
|
77
|
+
username: 'jdoe',
|
|
78
|
+
password: 'p@55w0rD',
|
|
79
|
+
ssn: '123-70-9182'
|
|
80
|
+
}
|
|
81
|
+
|
|
67
82
|
immutable_struct_ex = ImmutableStructEx.new(**user) do
|
|
68
83
|
REDACT = %i(password ssn).freeze
|
|
69
84
|
|
data/immutable_struct_ex.gemspec
CHANGED
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
|
14
14
|
spec.description = 'Creates an immutable struct in one step.'
|
|
15
15
|
spec.homepage = 'https://github.com/gangelo/immutable_struct_ex'
|
|
16
16
|
spec.license = 'MIT'
|
|
17
|
-
spec.required_ruby_version =
|
|
17
|
+
spec.required_ruby_version = Gem::Requirement.new("~> 3.0")
|
|
18
18
|
|
|
19
19
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
20
20
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: immutable_struct_ex
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gene M. Angelo, Jr.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-
|
|
11
|
+
date: 2022-11-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -203,16 +203,16 @@ require_paths:
|
|
|
203
203
|
- lib
|
|
204
204
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
205
205
|
requirements:
|
|
206
|
-
- - "
|
|
206
|
+
- - "~>"
|
|
207
207
|
- !ruby/object:Gem::Version
|
|
208
|
-
version: 3.0
|
|
208
|
+
version: '3.0'
|
|
209
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
210
|
requirements:
|
|
211
211
|
- - ">="
|
|
212
212
|
- !ruby/object:Gem::Version
|
|
213
213
|
version: '0'
|
|
214
214
|
requirements: []
|
|
215
|
-
rubygems_version: 3.
|
|
215
|
+
rubygems_version: 3.3.22
|
|
216
216
|
signing_key:
|
|
217
217
|
specification_version: 4
|
|
218
218
|
summary: Creates an immutable struct in one step.
|