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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4ff5d3aeb6f4aed20276acec36dd859f5fc1e7e8836d3d5414208d70ef9216f
4
- data.tar.gz: bb73f5257fcd66d69029cbaf080e52a53d8dd5e3101e540bb0eb48be5891ede7
3
+ metadata.gz: bcbb8468dcb54cae31c758fd34f4560e83efd8817a7d5eeb242e8b15293a12f5
4
+ data.tar.gz: 9cc2375503098535a28735cf97b044a8374fe819b41a8d4ebc0e43df0125ac0c
5
5
  SHA512:
6
- metadata.gz: 4d8db67bb3b5c5c083a0d7f8a42ce1ff0419409b44c8c45feb15865d4853253401a252fd9f550e320db5e4eda62993d3527088a094682dfcf1a7125e0d518552
7
- data.tar.gz: ea6e43b825c9e5d17f63a050122435fce3e98c8fc3f488a088f8df1f70e91abe6b24c08e676caec9dbb82a4ae14fc0f326135ac647254052b83de6772f820d56
6
+ metadata.gz: 0235750ae8ccce0830e75cf1b5be71b5bfb1417d71beb035484288648e26b07877538c47adf871f7b7725a736448192ce21884446aa2b58b8ce56edb4eed6013
7
+ data.tar.gz: d8f9c0cf27b34aa724e628129f883baf4b0d3ef7ae9772ee55c7904691e68deb6723b824b5b50456f73a4093f7a2b2ca48c907c938f14cb75a1deb8786a46fde
@@ -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
- # Mutant 0.8.24 introduces new mutations that cause infinite recursion inside
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ValueSemantics
2
- VERSION = "3.1.0"
2
+ VERSION = "3.2.0"
3
3
  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.1.0
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-06-30 00:00:00.000000000 Z
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
- rubygems_version: 3.0.4
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.