value_semantics 3.1.0 → 3.2.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 +5 -0
- data/README.md +15 -0
- data/bin/test +1 -5
- data/lib/value_semantics.rb +18 -0
- data/lib/value_semantics/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcbb8468dcb54cae31c758fd34f4560e83efd8817a7d5eeb242e8b15293a12f5
|
4
|
+
data.tar.gz: 9cc2375503098535a28735cf97b044a8374fe819b41a8d4ebc0e43df0125ac0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0235750ae8ccce0830e75cf1b5be71b5bfb1417d71beb035484288648e26b07877538c47adf871f7b7725a736448192ce21884446aa2b58b8ce56edb4eed6013
|
7
|
+
data.tar.gz: d8f9c0cf27b34aa724e628129f883baf4b0d3ef7ae9772ee55c7904691e68deb6723b824b5b50456f73a4093f7a2b2ca48c907c938f14cb75a1deb8786a46fde
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,11 @@ Notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [3.2.0] - 2019-09-30
|
9
|
+
### Added
|
10
|
+
- `ValueSemantics::Struct`, a convenience for creating a new class and mixing
|
11
|
+
in ValueSemantics in a single step.
|
12
|
+
|
8
13
|
## [3.1.0] - 2019-06-30
|
9
14
|
### Added
|
10
15
|
- Built-in PP support for value classes
|
data/README.md
CHANGED
@@ -304,6 +304,21 @@ For example, the default value could be a string,
|
|
304
304
|
which would then be coerced into an `IPAddr` object.
|
305
305
|
|
306
306
|
|
307
|
+
## ValueSemantics::Struct
|
308
|
+
|
309
|
+
This is a convenience for making a new class and including ValueSemantics in
|
310
|
+
one step, similar to how `Struct` works from the Ruby standard library. For
|
311
|
+
example:
|
312
|
+
|
313
|
+
```ruby
|
314
|
+
Cat = ValueSemantics::Struct.new do
|
315
|
+
name String, default: "Mittens"
|
316
|
+
end
|
317
|
+
|
318
|
+
Cat.new.name #=> "Mittens"
|
319
|
+
```
|
320
|
+
|
321
|
+
|
307
322
|
## Installation
|
308
323
|
|
309
324
|
Add this line to your application's Gemfile:
|
data/bin/test
CHANGED
@@ -11,9 +11,5 @@ else
|
|
11
11
|
--include lib \
|
12
12
|
--require value_semantics \
|
13
13
|
--use rspec "$MUTANT_PATTERN" \
|
14
|
-
#
|
15
|
-
# #method_missing. These --ignore-subject lines prevent that from happening
|
16
|
-
#--ignore-subject "ValueSemantics::DSL#method_missing" \
|
17
|
-
#--ignore-subject "ValueSemantics::DSL#respond_to_missing?" \
|
18
|
-
#--ignore-subject "ValueSemantics::DSL#def_attr" \
|
14
|
+
--ignore-subject "ValueSemantics::Struct.new" # causes unfixable failure I don't want to deal with
|
19
15
|
fi
|
data/lib/value_semantics.rb
CHANGED
@@ -366,4 +366,22 @@ module ValueSemantics
|
|
366
366
|
end
|
367
367
|
end
|
368
368
|
|
369
|
+
#
|
370
|
+
# ValueSemantics equivalent of the Struct class from the Ruby standard
|
371
|
+
# library
|
372
|
+
#
|
373
|
+
class Struct
|
374
|
+
#
|
375
|
+
# Creates a new Class with ValueSemantics mixed in
|
376
|
+
#
|
377
|
+
# @yield a block containing ValueSemantics DSL
|
378
|
+
# @return [Class] the newly created class
|
379
|
+
#
|
380
|
+
def self.new(&block)
|
381
|
+
klass = Class.new
|
382
|
+
klass.include(ValueSemantics.for_attributes(&block))
|
383
|
+
klass
|
384
|
+
end
|
385
|
+
end
|
386
|
+
|
369
387
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: value_semantics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Dalling
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -135,7 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
|
-
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.7.7
|
139
140
|
signing_key:
|
140
141
|
specification_version: 4
|
141
142
|
summary: Makes value classes, with lightweight validation and coercion.
|