philiprehberger-assert 0.4.0 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5fea50ef7ac475426e9456b67e82f2be344f3b97fccba75f2e0d1fe944c1ae7
4
- data.tar.gz: 5fd7d6aca18f9c06d4ace4a050483b433f014203252d2cd7a0b8fc4c8fdbf5a4
3
+ metadata.gz: 806a389a510c91f4c13f8b09ed2b4defbeea816d0d6d9d5f3a1a452add6f12de
4
+ data.tar.gz: 915ce84054018103c7c27618f54d99e0e9ecd3f257056a6e60653f54433b55d7
5
5
  SHA512:
6
- metadata.gz: 8ef0576d1e93ec43284b49a11668e1d3fc8412576ab96919a0fbc997c282c1626be2ba91f0fa6118f6b1f7ef6ca0ec1a467402d79113e476914d667d778355a0
7
- data.tar.gz: 69aa855412b4409cea2b6071ab560919acee192daa546a4b5bbd18cf2d5a7938e3751ebd947a56dbaf0510f9780525e9791058cf970177799c3112ffa6ecfa6f
6
+ metadata.gz: d54316256352d71f704fe3988caf7f228661a1e86977f4acf3e9486bd2c9b57daf2c9bc70e9a23a927d4e7b206f6e814c16dbbb4798d71a103963c8fed229299
7
+ data.tar.gz: 6ee3a9ba4b4a5b78d2d39f72acf310cc2019391521978fd958d6006c76afa234db0efc203387bec98dc6574913daf92f4445db333a34cc570df8913574cf2fe0
data/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.5.0] - 2026-04-29
11
+
12
+ ### Added
13
+ - `Assert.postcondition(condition, message)` for Design by Contract postcondition checks, complementing the existing `precondition`
14
+
10
15
  ## [0.4.0] - 2026-04-15
11
16
 
12
17
  ### Added
data/README.md CHANGED
@@ -92,13 +92,25 @@ end
92
92
  Philiprehberger::Assert.precondition(user.active?, 'user must be active')
93
93
  ```
94
94
 
95
+ ### Postconditions (Design by Contract)
96
+
97
+ ```ruby
98
+ def withdraw(amount)
99
+ Philiprehberger::Assert.precondition(amount.positive?, 'amount must be positive')
100
+ result = perform_withdrawal(amount)
101
+ Philiprehberger::Assert.postcondition(result.balance >= 0, 'balance must not go negative')
102
+ result
103
+ end
104
+ ```
105
+
95
106
  ## API
96
107
 
97
108
  | Method | Description |
98
109
  |--------|-------------|
99
110
  | `Assert.that(value, message = nil)` | Start a chainable assertion |
100
111
  | `Assert.soft { \|a\| ... }` | Collect failures, raise at end |
101
- | `Assert.precondition(condition, message)` | Design by Contract check |
112
+ | `Assert.precondition(condition, message)` | Design by Contract precondition check |
113
+ | `Assert.postcondition(condition, message)` | Design by Contract postcondition check |
102
114
  | `Assertion#is_a(type)` | Assert value is an instance of type |
103
115
  | `Assertion#gte(num)` | Assert value >= num |
104
116
  | `Assertion#lte(num)` | Assert value <= num |
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Philiprehberger
4
4
  module Assert
5
- VERSION = '0.4.0'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
@@ -33,5 +33,14 @@ module Philiprehberger
33
33
  def self.precondition(condition, message)
34
34
  raise AssertionError, message unless condition
35
35
  end
36
+
37
+ # Design by Contract postcondition check.
38
+ #
39
+ # @param condition [Boolean] the condition to verify
40
+ # @param message [String] failure message
41
+ # @raise [AssertionError] if condition is false
42
+ def self.postcondition(condition, message)
43
+ raise AssertionError, message unless condition
44
+ end
36
45
  end
37
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: philiprehberger-assert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Rehberger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-15 00:00:00.000000000 Z
11
+ date: 2026-04-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A lightweight runtime assertion library for Ruby with chainable matchers,
14
14
  soft assertions, and Design by Contract preconditions.