valued 0.4.0 → 0.4.1

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: c09b1d932113939667c5e36981e3256b25483679ebc222131d377985152a70a9
4
- data.tar.gz: 823e69bdf5587363b1cae66ce2bd68ed8f38aedcdca3bddac5e59b953c27414f
3
+ metadata.gz: 01e8a133b1b6b38c5ad222c7d03a3ea68ca57925700a81c305dc9d66b8cd83a9
4
+ data.tar.gz: a03c152ff273d2ba821a1f96d3bc456b011b78908ccddd2f54ad0e1f8b041765
5
5
  SHA512:
6
- metadata.gz: 7c050eb350406595297da5f44fddd9f8b87e7675ad72596eaf89b8de9075e4da48f873da3750d01f7bd47f986c56efe5dd295900a17f94c1d81aee22459d482f
7
- data.tar.gz: bd235452be8f966895982d83b31650bd468af5922e27d97680f04f95e8557cfd87f5c82ca982dc36880b0f2b2b767d9c56fb573ec6e42ed6396c16f433e183e1
6
+ metadata.gz: 456eb9787c0b033387957c1cd516ccf1e17a177eb6e4b9878351a38424d96ac309e1eadfc79b4db943d0ed213edbfcb07b9089ed0a03aadc03d25a7bc467c7f0
7
+ data.tar.gz: 5cea8f73ca85b74825ef922a21a684968195a88ac5466b9d33e8be2b27391c3a454494ce5364cd60c84c2ec44ac0b4e6c0de684f16d1d8a7522f58f66043d2ce
@@ -0,0 +1,35 @@
1
+ name: Continuous Integration
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ ruby-version: ["3.0"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - name: Setup Node.js 🖲
19
+ uses: actions/setup-node@v2.4.0
20
+ with:
21
+ node-version: 16.x
22
+ check-latest: true
23
+ - run: npm ci
24
+
25
+ - name: Check formatting 🔍
26
+ run: npm run lint
27
+
28
+ - name: Setup Ruby 💎
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{ matrix.ruby-version }}
32
+ bundler-cache: true
33
+
34
+ - name: Run tests ⚙️
35
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ node_modules
data/.tool-versions ADDED
@@ -0,0 +1,2 @@
1
+ ruby 3.0.2
2
+ nodejs 16.6.1
data/CHANGELOG.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.1
4
+
5
+ - fix bug that prevented setting an attribute to `nil` with `update`
6
+
7
+ ## 0.4.0
8
+
9
+ - remove possibility to use attributes with question marks
10
+
3
11
  ## 0.3.0
4
12
 
5
- - added a `update` method to all `Valued` and `Valued::Mutable` objects that
6
- allows creating a duplicate of an object with changed attributes
13
+ - added a `update` method to all `Valued` and `Valued::Mutable` objects that allows creating a duplicate of an object with changed attributes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- valued (0.4.0)
4
+ valued (0.4.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -14,7 +14,7 @@ GEM
14
14
  ast (~> 2.4.0)
15
15
  rainbow (3.0.0)
16
16
  rake (13.0.1)
17
- rexml (3.2.4)
17
+ rexml (3.2.5)
18
18
  rspec (3.9.0)
19
19
  rspec-core (~> 3.9.0)
20
20
  rspec-expectations (~> 3.9.0)
@@ -53,4 +53,4 @@ DEPENDENCIES
53
53
  valued!
54
54
 
55
55
  BUNDLED WITH
56
- 2.1.4
56
+ 2.2.22
data/lib/valued.rb CHANGED
@@ -3,12 +3,8 @@ require 'valued/version'
3
3
 
4
4
  module Valued
5
5
  module ClassMethods
6
- def self.define_method(attr, klass)
7
- klass.class_eval { attr_reader attr }
8
- end
9
-
10
6
  def attributes(*attributes)
11
- attributes.each { |attr| Valued::ClassMethods.define_method(attr, self) }
7
+ attributes.each { |attribute| self.class_eval { attr_reader attribute } }
12
8
  define_method('_attributes') { attributes }
13
9
  private :_attributes
14
10
  end
@@ -43,7 +39,11 @@ module Valued
43
39
  def update(new_attributes)
44
40
  self.class.new(
45
41
  _attributes.each_with_object({}) do |attribute, result|
46
- result[attribute] = new_attributes[attribute] || self.send(attribute)
42
+ if new_attributes.key?(attribute)
43
+ result[attribute] = new_attributes[attribute]
44
+ else
45
+ result[attribute] = self.send(attribute)
46
+ end
47
47
  end
48
48
  )
49
49
  end
@@ -74,9 +74,9 @@ module Valued
74
74
 
75
75
  def inspect
76
76
  inspected_attributes =
77
- _attributes.map do |attribute|
78
- "#{attribute}=#{send(attribute).inspect}"
79
- end.join(' ')
77
+ _attributes
78
+ .map { |attribute| "#{attribute}=#{send(attribute).inspect}" }
79
+ .join(' ')
80
80
  "#<#{self.class} #{inspected_attributes}>"
81
81
  end
82
82
  end
@@ -1,13 +1,9 @@
1
1
  module Valued
2
2
  module Mutable
3
3
  module ClassMethods
4
- def self.define_method(attr, klass)
5
- klass.class_eval { attr_accessor attr }
6
- end
7
-
8
4
  def attributes(*attributes)
9
- attributes.each do |attr|
10
- Valued::Mutable::ClassMethods.define_method(attr, self)
5
+ attributes.each do |attribute|
6
+ self.class_eval { attr_accessor attribute }
11
7
  end
12
8
  define_method('_attributes') { attributes }
13
9
  private :_attributes
@@ -40,7 +36,11 @@ module Valued
40
36
  def update(new_attributes)
41
37
  self.class.new(
42
38
  _attributes.each_with_object({}) do |attribute, result|
43
- result[attribute] = new_attributes[attribute] || self.send(attribute)
39
+ if new_attributes.key?(attribute)
40
+ result[attribute] = new_attributes[attribute]
41
+ else
42
+ result[attribute] = self.send(attribute)
43
+ end
44
44
  end
45
45
  )
46
46
  end
@@ -71,9 +71,9 @@ module Valued
71
71
 
72
72
  def inspect
73
73
  inspected_attributes =
74
- _attributes.map do |attribute|
75
- "#{attribute}=#{send(attribute).inspect}"
76
- end.join(' ')
74
+ _attributes
75
+ .map { |attribute| "#{attribute}=#{send(attribute).inspect}" }
76
+ .join(' ')
77
77
  "#<#{self.class} #{inspected_attributes}>"
78
78
  end
79
79
  end
@@ -1,3 +1,3 @@
1
1
  module Valued
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
data/package-lock.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "valued",
3
+ "lockfileVersion": 2,
4
+ "requires": true,
5
+ "packages": {
6
+ "": {
7
+ "devDependencies": {
8
+ "@prettier/plugin-ruby": "^1.6.1",
9
+ "prettier": "^2.3.2"
10
+ }
11
+ },
12
+ "node_modules/@prettier/plugin-ruby": {
13
+ "version": "1.6.1",
14
+ "resolved": "https://registry.npmjs.org/@prettier/plugin-ruby/-/plugin-ruby-1.6.1.tgz",
15
+ "integrity": "sha512-PGDCATgVTQz0s/NB9nStiXVCIr+hG/XnKeAO/kguaHrNf8VwCpP5Ul+/KQao0z0QFBy2PDY8kWptfDQCa7WMXg==",
16
+ "dev": true,
17
+ "dependencies": {
18
+ "prettier": ">=1.10"
19
+ }
20
+ },
21
+ "node_modules/prettier": {
22
+ "version": "2.3.2",
23
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.2.tgz",
24
+ "integrity": "sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==",
25
+ "dev": true,
26
+ "bin": {
27
+ "prettier": "bin-prettier.js"
28
+ },
29
+ "engines": {
30
+ "node": ">=10.13.0"
31
+ }
32
+ }
33
+ },
34
+ "dependencies": {
35
+ "@prettier/plugin-ruby": {
36
+ "version": "1.6.1",
37
+ "resolved": "https://registry.npmjs.org/@prettier/plugin-ruby/-/plugin-ruby-1.6.1.tgz",
38
+ "integrity": "sha512-PGDCATgVTQz0s/NB9nStiXVCIr+hG/XnKeAO/kguaHrNf8VwCpP5Ul+/KQao0z0QFBy2PDY8kWptfDQCa7WMXg==",
39
+ "dev": true,
40
+ "requires": {
41
+ "prettier": ">=1.10"
42
+ }
43
+ },
44
+ "prettier": {
45
+ "version": "2.3.2",
46
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.2.tgz",
47
+ "integrity": "sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==",
48
+ "dev": true
49
+ }
50
+ }
51
+ }
data/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "valued",
3
+ "scripts": {
4
+ "prettify": "prettier \"**/*.{ru,rb,yml,yaml,md}\" --ignore-path=\".gitignore\"",
5
+ "lint": "npm run prettify -- --check",
6
+ "format": "npm run prettify -- --write"
7
+ },
8
+ "devDependencies": {
9
+ "@prettier/plugin-ruby": "^1.6.1",
10
+ "prettier": "^2.3.2"
11
+ }
12
+ }
data/valued.gemspec CHANGED
@@ -17,10 +17,11 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.files =
19
19
  Dir.chdir(File.expand_path('..', __FILE__)) do
20
- `git ls-files -z`.split("\x0").reject do |f|
21
- f.match(%r{^(test|spec|features)/})
22
- end
20
+ `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features)/})
23
22
  end
23
+ end
24
+
24
25
  spec.bindir = 'exe'
25
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
27
  spec.require_paths = %w[lib]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valued
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Mainz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-19 00:00:00.000000000 Z
11
+ date: 2021-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,10 +87,11 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - ".github/workflows/ci.yml"
90
91
  - ".gitignore"
91
92
  - ".rspec"
92
93
  - ".rubocop.yml"
93
- - ".travis.yml"
94
+ - ".tool-versions"
94
95
  - CHANGELOG.md
95
96
  - Gemfile
96
97
  - Gemfile.lock
@@ -100,6 +101,8 @@ files:
100
101
  - lib/valued.rb
101
102
  - lib/valued/mutable.rb
102
103
  - lib/valued/version.rb
104
+ - package-lock.json
105
+ - package.json
103
106
  - valued.gemspec
104
107
  homepage: https://github.com/mmainz/valued
105
108
  licenses:
@@ -122,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
125
  - !ruby/object:Gem::Version
123
126
  version: '0'
124
127
  requirements: []
125
- rubygems_version: 3.1.2
128
+ rubygems_version: 3.2.22
126
129
  signing_key:
127
130
  specification_version: 4
128
131
  summary: A Ruby gem that makes it easy to create value objects.
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.7.0
7
- before_install: gem install bundler -v 2.0.2