immutable-struct 2.4.1 → 2.5.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/.circleci/config.yml +117 -20
- data/.github/CODEOWNERS +11 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +7 -0
- data/.github/workflows/scheduled_cci.yml +14 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/.travis.yml +7 -5
- data/build-matrix.json +1 -2
- data/lib/immutable-struct.rb +9 -1
- data/owners.json +1 -1
- data/spec/immutable_struct_spec.rb +41 -0
- data/spec/spec_helper.rb +9 -1
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c06154021767382ddac96df4c5f0291ef6fe0b4492b835fc36295b700fed19b7
|
4
|
+
data.tar.gz: d05c85009279d86f545e9b0d07645a4680e88b45d149feb196419cdab3f7b6a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f636be7f8e287d9573a7d1df9ca1af2dee7cdc3aae4f5ec6295541e68b30d7e99efac0b9b6dd870f29888baf4f45515148e422f3617c8668b3ef18515253190
|
7
|
+
data.tar.gz: c35f53b3f63f6f3b493223041a986f37c7050b5f1eff441172d974a7bb026db42581b8131424c5458067562774bb2db768018698bc89afb922b9d226fd700be6
|
data/.circleci/config.yml
CHANGED
@@ -1,15 +1,81 @@
|
|
1
|
-
# DO NOT MODIFY - this is managed by Git Reduce in goro
|
1
|
+
# DO NOT MODIFY - this is managed by Git Reduce in goro and generated from build-matrix.json
|
2
2
|
#
|
3
3
|
---
|
4
|
-
version: 2
|
4
|
+
version: 2.1
|
5
|
+
|
6
|
+
############
|
7
|
+
## Github Actions Pipeline Params
|
8
|
+
############
|
9
|
+
|
10
|
+
parameters:
|
11
|
+
GHA_Event:
|
12
|
+
type: string
|
13
|
+
default: ""
|
14
|
+
GHA_Actor:
|
15
|
+
type: string
|
16
|
+
default: ""
|
17
|
+
GHA_Action:
|
18
|
+
type: string
|
19
|
+
default: ""
|
20
|
+
GHA_Meta:
|
21
|
+
type: string
|
22
|
+
default: ""
|
23
|
+
|
5
24
|
jobs:
|
6
|
-
|
25
|
+
generate-and-push-docs:
|
7
26
|
docker:
|
8
|
-
- image:
|
27
|
+
- image: cimg/ruby:3.3.7
|
28
|
+
auth:
|
29
|
+
username: "$DOCKERHUB_USERNAME"
|
30
|
+
password: "$DOCKERHUB_PASSWORD"
|
31
|
+
steps:
|
32
|
+
- checkout
|
33
|
+
- run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
|
34
|
+
- run: bundle install
|
35
|
+
- run:
|
36
|
+
name: Generate documentation
|
37
|
+
command: ' if [[ $(bundle exec rake -T docs:generate:custom) ]]; then echo
|
38
|
+
"Generating docs using rake task docs:generate:custom" ; bundle exec rake
|
39
|
+
docs:generate:custom ; elif [[ $(bundle exec rake -T docs:generate) ]];
|
40
|
+
then echo "Generating docs using rake task docs:generate" ; bundle exec
|
41
|
+
rake docs:generate ; else echo "Skipping doc generation" ; exit 0 ; fi '
|
42
|
+
- run:
|
43
|
+
name: Push documentation to Unwritten
|
44
|
+
command: if [[ $(bundle exec rake -T docs:push) ]]; then bundle exec rake
|
45
|
+
docs:push; fi
|
46
|
+
release:
|
47
|
+
docker:
|
48
|
+
- image: cimg/ruby:3.3.7
|
49
|
+
auth:
|
50
|
+
username: "$DOCKERHUB_USERNAME"
|
51
|
+
password: "$DOCKERHUB_PASSWORD"
|
52
|
+
steps:
|
53
|
+
- checkout
|
54
|
+
- run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
|
55
|
+
- run: bundle install
|
56
|
+
- run:
|
57
|
+
name: Artifactory login
|
58
|
+
command: mkdir -p ~/.gem && curl -u$ARTIFACTORY_USER:$ARTIFACTORY_TOKEN https://stitchfix01.jfrog.io/stitchfix01/api/gems/eng-gems/api/v1/api_key.yaml
|
59
|
+
> ~/.gem/credentials && chmod 0600 ~/.gem/credentials
|
60
|
+
- run:
|
61
|
+
name: Build/release gem to artifactory
|
62
|
+
command: bundle exec rake push_artifactory
|
63
|
+
ruby-3_3_7:
|
64
|
+
docker:
|
65
|
+
- image: cimg/ruby:3.3.7
|
66
|
+
auth:
|
67
|
+
username: "$DOCKERHUB_USERNAME"
|
68
|
+
password: "$DOCKERHUB_PASSWORD"
|
9
69
|
working_directory: "~/immutable-struct"
|
10
70
|
steps:
|
11
71
|
- checkout
|
12
|
-
- run:
|
72
|
+
- run:
|
73
|
+
name: Check for Gemfile.lock presence
|
74
|
+
command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see
|
75
|
+
https://github.com/stitchfix/eng-wiki/blob/main/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)"
|
76
|
+
1>&2 ; exit 1 ; else exit 0 ; fi '
|
77
|
+
- run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
|
78
|
+
- run: bundle install
|
13
79
|
- run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml
|
14
80
|
--format=doc
|
15
81
|
- run:
|
@@ -18,17 +84,26 @@ jobs:
|
|
18
84
|
fi
|
19
85
|
- run:
|
20
86
|
name: Notify Pager Duty
|
21
|
-
command:
|
87
|
+
command: bundle exec y-notify "#app-platform-ops"
|
22
88
|
when: on_fail
|
23
89
|
- store_test_results:
|
24
90
|
path: "/tmp/test-results"
|
25
|
-
ruby-
|
91
|
+
ruby-3_2_7:
|
26
92
|
docker:
|
27
|
-
- image:
|
93
|
+
- image: cimg/ruby:3.2.7
|
94
|
+
auth:
|
95
|
+
username: "$DOCKERHUB_USERNAME"
|
96
|
+
password: "$DOCKERHUB_PASSWORD"
|
28
97
|
working_directory: "~/immutable-struct"
|
29
98
|
steps:
|
30
99
|
- checkout
|
31
|
-
- run:
|
100
|
+
- run:
|
101
|
+
name: Check for Gemfile.lock presence
|
102
|
+
command: ' if (test -f Gemfile.lock) then echo "Dont commit Gemfile.lock (see
|
103
|
+
https://github.com/stitchfix/eng-wiki/blob/main/architecture-decisions/0009-rubygem-dependencies-will-be-managed-more-explicitly.md)"
|
104
|
+
1>&2 ; exit 1 ; else exit 0 ; fi '
|
105
|
+
- run: bundle config stitchfix01.jfrog.io $ARTIFACTORY_USER:$ARTIFACTORY_TOKEN
|
106
|
+
- run: bundle install
|
32
107
|
- run: bundle exec rspec --format RspecJunitFormatter --out /tmp/test-results/rspec.xml
|
33
108
|
--format=doc
|
34
109
|
- run:
|
@@ -37,28 +112,50 @@ jobs:
|
|
37
112
|
fi
|
38
113
|
- run:
|
39
114
|
name: Notify Pager Duty
|
40
|
-
command:
|
115
|
+
command: bundle exec y-notify "#app-platform-ops"
|
41
116
|
when: on_fail
|
42
117
|
- store_test_results:
|
43
118
|
path: "/tmp/test-results"
|
44
119
|
workflows:
|
45
120
|
version: 2
|
46
121
|
on-commit:
|
122
|
+
unless:
|
123
|
+
equal: [ "schedule", << pipeline.parameters.GHA_Event >> ]
|
47
124
|
jobs:
|
48
|
-
-
|
125
|
+
- release:
|
49
126
|
context: org-global
|
50
|
-
|
127
|
+
requires:
|
128
|
+
- ruby-3_3_7
|
129
|
+
- ruby-3_2_7
|
130
|
+
filters:
|
131
|
+
tags:
|
132
|
+
only: "/^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:(-|\\.)(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$/"
|
133
|
+
branches:
|
134
|
+
ignore: /.*/
|
135
|
+
- generate-and-push-docs:
|
51
136
|
context: org-global
|
52
|
-
|
53
|
-
|
54
|
-
- schedule:
|
55
|
-
cron: 4 21 * * 1,2,3,4,5
|
137
|
+
requires:
|
138
|
+
- release
|
56
139
|
filters:
|
140
|
+
tags:
|
141
|
+
only: "/^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:(-|\\.)(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$/"
|
57
142
|
branches:
|
58
|
-
|
59
|
-
|
143
|
+
ignore: /.*/
|
144
|
+
- ruby-3_3_7:
|
145
|
+
context: org-global
|
146
|
+
filters:
|
147
|
+
tags:
|
148
|
+
only: &1 /.*/
|
149
|
+
- ruby-3_2_7:
|
150
|
+
context: org-global
|
151
|
+
filters:
|
152
|
+
tags:
|
153
|
+
only: *1
|
154
|
+
scheduled:
|
155
|
+
when:
|
156
|
+
equal: [ "schedule", << pipeline.parameters.GHA_Event >> ]
|
60
157
|
jobs:
|
61
|
-
- ruby-
|
158
|
+
- ruby-3_3_7:
|
62
159
|
context: org-global
|
63
|
-
- ruby-
|
160
|
+
- ruby-3_2_7:
|
64
161
|
context: org-global
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# THIS FILE IS NOT THE SOURCE OF TRUTH for app ownership. If this app
|
2
|
+
# is transferred to another team, the app ownership should be changed
|
3
|
+
# in fixops.
|
4
|
+
#
|
5
|
+
# View current canonical app ownership on Unwritten:
|
6
|
+
# https://unwritten.stitchfix.com/docs/applications-and-services
|
7
|
+
#
|
8
|
+
# This file uses the GitHub CODEOWNERS convention to assign PR reviewers:
|
9
|
+
# https://help.github.com/articles/about-codeowners/
|
10
|
+
|
11
|
+
* @stitchfix/app-platform
|
@@ -0,0 +1,14 @@
|
|
1
|
+
on:
|
2
|
+
schedule:
|
3
|
+
- cron: '4 21 * * 1,2,3,4,5'
|
4
|
+
workflow_dispatch:
|
5
|
+
|
6
|
+
jobs:
|
7
|
+
trigger-circleci:
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
steps:
|
10
|
+
- name: CircleCI trigger on schedule
|
11
|
+
id: step1
|
12
|
+
uses: CircleCI-Public/trigger-circleci-pipeline-action@v1.0.5
|
13
|
+
env:
|
14
|
+
CCI_TOKEN: ${{ secrets.CCI_TOKEN || secrets.CCI_TOKEN_FOR_PUBLIC_REPOS }}
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
ruby-3.2.7
|
data/.travis.yml
CHANGED
data/build-matrix.json
CHANGED
data/lib/immutable-struct.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# will be evaluated as if it were inside a class definition, allowing you
|
7
7
|
# to add methods, include or extend modules, or do whatever else you want.
|
8
8
|
class ImmutableStruct
|
9
|
-
VERSION='2.
|
9
|
+
VERSION='2.5.0' #:nodoc:
|
10
10
|
# Create a new class with the given read-only attributes.
|
11
11
|
#
|
12
12
|
# attributes:: list of symbols or strings that can be used to create attributes.
|
@@ -121,6 +121,14 @@ class ImmutableStruct
|
|
121
121
|
end
|
122
122
|
(attribute_values + [self.class]).hash
|
123
123
|
end
|
124
|
+
|
125
|
+
def deconstruct_keys(keys)
|
126
|
+
if keys
|
127
|
+
to_h.slice(*keys)
|
128
|
+
else
|
129
|
+
to_h
|
130
|
+
end
|
131
|
+
end
|
124
132
|
end
|
125
133
|
klass.class_exec(&block) unless block.nil?
|
126
134
|
|
data/owners.json
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spec_helper.rb'
|
2
2
|
require 'json'
|
3
|
+
require 'set'
|
3
4
|
|
4
5
|
module TestModule
|
5
6
|
def hello; "hello"; end
|
@@ -189,6 +190,46 @@ describe ImmutableStruct do
|
|
189
190
|
end
|
190
191
|
end
|
191
192
|
|
193
|
+
describe "#deconstruct_keys" do
|
194
|
+
it "returns a hash with the specified keys" do
|
195
|
+
klass = ImmutableStruct.new(:a, :b, :c)
|
196
|
+
instance = klass.new(a: 1, b: 2, c: 3)
|
197
|
+
expect(instance.deconstruct_keys([:a, :c])).to eq({ a: 1, c: 3 })
|
198
|
+
end
|
199
|
+
|
200
|
+
context "when keys are specified that do not exist in the struct" do
|
201
|
+
it 'returns only the keys that do exist' do
|
202
|
+
klass = ImmutableStruct.new(:a, :b, :c)
|
203
|
+
instance = klass.new(a: 1, b: 2, c: 3)
|
204
|
+
expect(instance.deconstruct_keys([:a, :foo])).to eq({ a: 1 })
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
it "allows an instance to be used with pattern matching" do
|
209
|
+
klass = ImmutableStruct.new(:a, :b, :c)
|
210
|
+
instance = klass.new(a: 1, b: 2, c: 3)
|
211
|
+
expect {
|
212
|
+
case instance
|
213
|
+
in { a: 1 }
|
214
|
+
# good!
|
215
|
+
end
|
216
|
+
# a NoMatchingPatternError would be raised if the pattern didn't match
|
217
|
+
}.not_to raise_error
|
218
|
+
end
|
219
|
+
|
220
|
+
context "pattern matching against 'any key'" do
|
221
|
+
it 'returns all properties' do
|
222
|
+
klass = ImmutableStruct.new(:a, :b, :c)
|
223
|
+
instance = klass.new(a: 1, b: 2, c: 3)
|
224
|
+
case instance
|
225
|
+
in **rest
|
226
|
+
expect(rest).to eq({ a: 1, b: 2, c: 3 })
|
227
|
+
end
|
228
|
+
# a NoMatchingPatternError would be raised if the pattern didn't match
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
192
233
|
describe "merge" do
|
193
234
|
it "returns a new object as a result of merging attributes" do
|
194
235
|
klass = ImmutableStruct.new(:food, :snacks, :butter)
|
data/spec/spec_helper.rb
CHANGED
@@ -7,5 +7,13 @@ RSpec.configure do |config|
|
|
7
7
|
config.expect_with :rspec do |c|
|
8
8
|
c.syntax = [:expect]
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
|
+
config.mock_with :rspec do |mocks|
|
12
|
+
mocks.verify_partial_doubles = true
|
13
|
+
end
|
14
|
+
|
15
|
+
config.order = :random
|
16
|
+
Kernel.srand config.seed
|
17
|
+
|
18
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
11
19
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: immutable-struct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stitch Fix Engineering
|
8
8
|
- Dave Copeland
|
9
9
|
- Simeon Willbanks
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2025-02-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -79,6 +79,9 @@ extensions: []
|
|
79
79
|
extra_rdoc_files: []
|
80
80
|
files:
|
81
81
|
- ".circleci/config.yml"
|
82
|
+
- ".github/CODEOWNERS"
|
83
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
84
|
+
- ".github/workflows/scheduled_cci.yml"
|
82
85
|
- ".gitignore"
|
83
86
|
- ".ruby-gemset"
|
84
87
|
- ".ruby-version"
|
@@ -99,7 +102,7 @@ homepage: https://github.com/stitchfix/immutable-struct
|
|
99
102
|
licenses:
|
100
103
|
- MIT
|
101
104
|
metadata: {}
|
102
|
-
post_install_message:
|
105
|
+
post_install_message:
|
103
106
|
rdoc_options: []
|
104
107
|
require_paths:
|
105
108
|
- lib
|
@@ -114,8 +117,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
117
|
- !ruby/object:Gem::Version
|
115
118
|
version: '0'
|
116
119
|
requirements: []
|
117
|
-
rubygems_version: 3.
|
118
|
-
signing_key:
|
120
|
+
rubygems_version: 3.5.11
|
121
|
+
signing_key:
|
119
122
|
specification_version: 4
|
120
123
|
summary: Easily create value objects without the pain of Ruby's Struct (or its setters)
|
121
124
|
test_files:
|