portrayal 0.2.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +24 -0
- data/.gitignore +3 -0
- data/CHANGELOG.md +34 -4
- data/README.md +139 -14
- data/lib/portrayal.rb +16 -12
- data/lib/portrayal/default.rb +13 -0
- data/lib/portrayal/schema.rb +47 -70
- data/lib/portrayal/version.rb +1 -1
- data/portrayal.gemspec +11 -8
- metadata +24 -22
- data/.travis.yml +0 -10
- data/Gemfile.lock +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbd0b561e866c45f6e850b592620df78d4573635165807cd2284ab45baed9e0c
|
4
|
+
data.tar.gz: 699be912aa836a55faa10886a3a1c1bb7b17c006f1db445694660d2fbe0ec0f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58fc168ad299aee9555ec7e1a1355f533c65af5ff1620095a7e49829252b39e92f45714083cc03fd1cde2ccc027acabd98b3526618caae07fb226be7e294694b
|
7
|
+
data.tar.gz: 8d59938b7bdcc5b9a32683695b6146186cb12bf6132326ecfff5b01685b7740dbf78ef513a43fbf5ff58716c38848881229600e4eb2f059dc13efc530120d68d
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: RSpec
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ main ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ main ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby: [ '2.4', '2.5', '2.6', '2.7' ]
|
15
|
+
|
16
|
+
name: Ruby ${{ matrix.ruby }}
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v2
|
19
|
+
- uses: actions/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.ruby }}
|
22
|
+
- run: gem install bundler
|
23
|
+
- run: bundle install
|
24
|
+
- run: bundle exec rake
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,41 @@
|
|
1
1
|
This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
2
2
|
|
3
|
-
##
|
3
|
+
## Unreleased
|
4
4
|
|
5
|
-
|
5
|
+
## 0.7.0 - 2020-12-13
|
6
6
|
|
7
|
-
*
|
7
|
+
* **Breaking change:** Remove `optional` setting. To update find all `optional: true` and change to `default: nil` instead.
|
8
8
|
|
9
|
-
|
9
|
+
* **Breaking change:** Move `self` of default procs to `initialize` context. Before this change, default procs used to be executed naively in class context. Now they can access other keyword readers and instance methods since their `self` is now coming from `initialize`. To update, look through your default procs and replace any reference to current class's methods such as `method_name` with `self.class.method_name`.
|
10
|
+
|
11
|
+
## 0.6.0 - 2020-08-10
|
12
|
+
|
13
|
+
* Return keyword name from `keyword`, allowing usage such as `private keyword :foo`. [[commit]](https://github.com/scottscheapflights/portrayal/commit/9e9db2cafc7eae14789c5b84f70efd18898ace76)
|
14
|
+
|
15
|
+
## 0.5.0 - 2020-05-28
|
16
|
+
|
17
|
+
* Add option `define` for overriding nested class name. [[commit]](https://github.com/scottscheapflights/portrayal/commit/665ad297fb71fcdf5f641c672a457ccbe29e4a49)
|
18
|
+
|
19
|
+
## 0.4.0 - 2020-05-16
|
20
|
+
|
21
|
+
* Portrayal schema is deep-duped to subclasses. [[commit]](https://github.com/scottscheapflights/portrayal/commit/f346483a379ce9fbdece72cde8b0844f2d22b1cd)
|
22
|
+
|
23
|
+
## 0.3.1 - 2020-05-11
|
24
|
+
|
25
|
+
* Fix the issue introduced in 0.3.0 where `==` and `eql?` were always treating rhs as another portrayal class. [[commit]](https://github.com/scottscheapflights/portrayal/commit/f6ec8f373c6582f7e8d8f872d289222e4a58f8f6)
|
26
|
+
|
27
|
+
## 0.3.0 - 2020-05-09 (yanked)
|
28
|
+
|
29
|
+
* No longer compare classes in `==`, use `eql?` for that. [[commit]](https://github.com/scottscheapflights/portrayal/commit/9c5a37e4fb91e35d23b22e208344452930452af7)
|
30
|
+
* Define a protected writer for every keyword - useful when applying changes after `dup`/`clone`. [[commit]](https://github.com/scottscheapflights/portrayal/commit/1c0fa6c6357a09760dae39165e864238d231a08e)
|
31
|
+
* Add definition of `#hash` to fix hash equality. Now `hash[object]` will match if `object` is of the same class with the same keywords and values. [[commit]](https://github.com/scottscheapflights/portrayal/commit/ba9e390ab4aea4733ba084ac273da448e313ea53)
|
32
|
+
* Make `#freeze` propagate to all keyword values. [[commit]](https://github.com/scottscheapflights/portrayal/commit/0a734411a6eac08e2355c4277e09a2a70800d032)
|
33
|
+
* Make `#dup` and `#clone` propagate to all keyword values. [[commit]](https://github.com/scottscheapflights/portrayal/commit/010632d87d81a8d5b5ea5ff27d3d209cc667b0a5)
|
34
|
+
|
35
|
+
## 0.2.0 - 2019-07-03
|
36
|
+
|
37
|
+
* It's now possible to specify non-lambda default values, like `default: "foo"`. There is now also a distinction between a proc and a lambda default. Procs are `call`-ed, while lambdas or any other types are returned as-is. In the majority of cases defaults are static values, and there is no need for the performance overhead of making all defaults into anonymous functions. [[commit]](https://github.com/scottscheapflights/portrayal/commit/a1cc9d0fd40e413210f61b945d37b81c87280fee)
|
38
|
+
|
39
|
+
## 0.1.0
|
10
40
|
|
11
41
|
First version.
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
![RSpec](https://github.com/scottscheapflights/portrayal/workflows/RSpec/badge.svg)
|
2
|
+
|
1
3
|
# Portrayal
|
2
4
|
|
3
5
|
Inspired by:
|
@@ -13,7 +15,7 @@ class Person < MySuperClass
|
|
13
15
|
extend Portrayal
|
14
16
|
|
15
17
|
keyword :name
|
16
|
-
keyword :age,
|
18
|
+
keyword :age, default: nil
|
17
19
|
keyword :favorite_fruit, default: 'feijoa'
|
18
20
|
|
19
21
|
keyword :address do
|
@@ -30,8 +32,12 @@ end
|
|
30
32
|
When you call `keyword`:
|
31
33
|
|
32
34
|
* It defines an `attr_reader`
|
35
|
+
* It defines a protected `attr_writer`
|
33
36
|
* It defines `initialize`
|
34
37
|
* It defines `==` and `eql?`
|
38
|
+
* It defines `#hash` for hash equality
|
39
|
+
* It defines `#dup` and `#clone` that propagate to all keyword values
|
40
|
+
* It defines `#freeze` that propagates to all keyword values
|
35
41
|
* It creates a nested class when you supply a block
|
36
42
|
* It inherits parent's superclass when creating a nested class
|
37
43
|
|
@@ -39,7 +45,8 @@ The code above produces almost exactly the following ruby. There's a lot of boil
|
|
39
45
|
|
40
46
|
```ruby
|
41
47
|
class Person < MySuperClass
|
42
|
-
|
48
|
+
attr_accessor :name, :age, :favorite_fruit, :address
|
49
|
+
protected :name=, :age=, :favorite_fruit=, :address=
|
43
50
|
|
44
51
|
def initialize(name:, age: nil, favorite_fruit: 'feijoa', address:)
|
45
52
|
@name = name
|
@@ -48,16 +55,46 @@ class Person < MySuperClass
|
|
48
55
|
@address = address
|
49
56
|
end
|
50
57
|
|
58
|
+
def eql?(other)
|
59
|
+
self.class == other.class && self == other
|
60
|
+
end
|
61
|
+
|
51
62
|
def ==(other)
|
52
|
-
|
53
|
-
{ name: name, age: age, favorite_fruit: favorite_fruit, address: address } ==
|
63
|
+
{ name: name, age: age, favorite_fruit: favorite_fruit, address: address } ==
|
54
64
|
{ name: other.name, age: other.age, favorite_fruit: other.favorite_fruit, address: other.address }
|
55
65
|
end
|
56
66
|
|
57
|
-
|
67
|
+
def hash
|
68
|
+
[ self.class, { name: name, age: age, favorite_fruit: favorite_fruit, address: address } ].hash
|
69
|
+
end
|
70
|
+
|
71
|
+
def freeze
|
72
|
+
name.freeze
|
73
|
+
age.freeze
|
74
|
+
favorite_fruit.freeze
|
75
|
+
address.freeze
|
76
|
+
super
|
77
|
+
end
|
78
|
+
|
79
|
+
def initialize_dup(source)
|
80
|
+
@name = source.name.dup
|
81
|
+
@age = source.age.dup
|
82
|
+
@favorite_fruit = source.favorite_fruit.dup
|
83
|
+
@address = source.address.dup
|
84
|
+
super
|
85
|
+
end
|
86
|
+
|
87
|
+
def initialize_clone(source)
|
88
|
+
@name = source.name.clone
|
89
|
+
@age = source.age.clone
|
90
|
+
@favorite_fruit = source.favorite_fruit.clone
|
91
|
+
@address = source.address.clone
|
92
|
+
super
|
93
|
+
end
|
58
94
|
|
59
95
|
class Address < MySuperClass
|
60
|
-
|
96
|
+
attr_accessor :street, :city
|
97
|
+
protected :street=, :city=
|
61
98
|
|
62
99
|
def initialize(street:, city:)
|
63
100
|
@street = street
|
@@ -68,12 +105,35 @@ class Person < MySuperClass
|
|
68
105
|
"#{street}, #{city}"
|
69
106
|
end
|
70
107
|
|
108
|
+
def eql?(other)
|
109
|
+
self.class == other.class && self == other
|
110
|
+
end
|
111
|
+
|
71
112
|
def ==(other)
|
72
|
-
|
73
|
-
|
113
|
+
{ street: street, city: city } == { street: other.street, city: other.city }
|
114
|
+
end
|
115
|
+
|
116
|
+
def hash
|
117
|
+
[ self.class, { street: street, city: city } ].hash
|
118
|
+
end
|
119
|
+
|
120
|
+
def freeze
|
121
|
+
street.freeze
|
122
|
+
city.freeze
|
123
|
+
super
|
124
|
+
end
|
125
|
+
|
126
|
+
def initialize_dup(source)
|
127
|
+
@street = source.street.dup
|
128
|
+
@city = source.city.dup
|
129
|
+
super
|
74
130
|
end
|
75
131
|
|
76
|
-
|
132
|
+
def initialize_clone(source)
|
133
|
+
@street = source.street.clone
|
134
|
+
@city = source.city.clone
|
135
|
+
super
|
136
|
+
end
|
77
137
|
end
|
78
138
|
end
|
79
139
|
```
|
@@ -112,7 +172,7 @@ class Address < ApplicationStruct
|
|
112
172
|
keyword :street
|
113
173
|
keyword :city
|
114
174
|
keyword :postcode
|
115
|
-
keyword :country,
|
175
|
+
keyword :country, default: nil
|
116
176
|
end
|
117
177
|
```
|
118
178
|
|
@@ -138,6 +198,71 @@ Any other value works as normal.
|
|
138
198
|
keyword :foo, default: 4
|
139
199
|
```
|
140
200
|
|
201
|
+
#### Default procs
|
202
|
+
|
203
|
+
Default procs are executed as though they were called in your class's `initialize`, so they have access to other keywords and instance methods.
|
204
|
+
|
205
|
+
```ruby
|
206
|
+
keyword :name
|
207
|
+
keyword :greeting, default: proc { "Hello, #{name}" }
|
208
|
+
```
|
209
|
+
|
210
|
+
Defaults can also use results of other defaults.
|
211
|
+
|
212
|
+
```ruby
|
213
|
+
keyword :four, default: proc { 2 + 2 }
|
214
|
+
keyword :eight, default: proc { four * 2 }
|
215
|
+
```
|
216
|
+
|
217
|
+
Or instance methods of the class.
|
218
|
+
|
219
|
+
```ruby
|
220
|
+
keyword :id, default: proc { generate_id }
|
221
|
+
|
222
|
+
private
|
223
|
+
|
224
|
+
def generate_id
|
225
|
+
SecureRandom.alphanumeric
|
226
|
+
end
|
227
|
+
```
|
228
|
+
|
229
|
+
Note: The order in which you declare keywords matters when specifying defaults that depend on other keywords. This will not have the desired effect:
|
230
|
+
|
231
|
+
```ruby
|
232
|
+
keyword :greeting, default: proc { "Hello, #{name}" }
|
233
|
+
keyword :name
|
234
|
+
```
|
235
|
+
|
236
|
+
### Nested Classes
|
237
|
+
|
238
|
+
When you pass a block to a keyword, it creates a nested class named after camelized keyword name.
|
239
|
+
|
240
|
+
```ruby
|
241
|
+
class Person
|
242
|
+
extend Portrayal
|
243
|
+
|
244
|
+
keyword :address do
|
245
|
+
keyword :street
|
246
|
+
end
|
247
|
+
end
|
248
|
+
```
|
249
|
+
|
250
|
+
The above block created class `Person::Address`.
|
251
|
+
|
252
|
+
If you want to change the name of the created class, use the option `define`.
|
253
|
+
|
254
|
+
```ruby
|
255
|
+
class Person
|
256
|
+
extend Portrayal
|
257
|
+
|
258
|
+
keyword :visited_countries, define: 'Country' do
|
259
|
+
keyword :name
|
260
|
+
end
|
261
|
+
end
|
262
|
+
```
|
263
|
+
|
264
|
+
This defines `Person::Country`, while the accessor remains `visited_countries`.
|
265
|
+
|
141
266
|
### Schema
|
142
267
|
|
143
268
|
Every class that has at least one keyword defined in it automatically receives a class method called `portrayal`. This method is a schema of your object with some additional helpers.
|
@@ -164,7 +289,7 @@ Address.portrayal.attributes(address) # => {street: '34th st', city: 'NYC', post
|
|
164
289
|
Get everything portrayal knows about your keywords in one hash.
|
165
290
|
|
166
291
|
```ruby
|
167
|
-
Address.portrayal.schema # => {:street=>
|
292
|
+
Address.portrayal.schema # => {:street=>nil, :city=>nil, :postcode=>nil, :country=><Portrayal::Default @value=nil @callable=false>}
|
168
293
|
```
|
169
294
|
|
170
295
|
## Philosophy
|
@@ -198,7 +323,7 @@ class Address < ApplicationStruct
|
|
198
323
|
keyword :street
|
199
324
|
keyword :city
|
200
325
|
keyword :postcode
|
201
|
-
keyword :country,
|
326
|
+
keyword :country, default: nil
|
202
327
|
end
|
203
328
|
```
|
204
329
|
|
@@ -241,7 +366,7 @@ class Address < ApplicationStruct
|
|
241
366
|
keyword :street
|
242
367
|
keyword :city
|
243
368
|
keyword :postcode
|
244
|
-
keyword :country,
|
369
|
+
keyword :country, default: nil
|
245
370
|
end
|
246
371
|
```
|
247
372
|
|
@@ -270,4 +395,4 @@ The gem is available as open source under the terms of the [Apache License Versi
|
|
270
395
|
|
271
396
|
## Code of Conduct
|
272
397
|
|
273
|
-
Everyone interacting in the Portrayal project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/scottscheapflights/portrayal/blob/
|
398
|
+
Everyone interacting in the Portrayal project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/scottscheapflights/portrayal/blob/main/CODE_OF_CONDUCT.md).
|
data/lib/portrayal.rb
CHANGED
@@ -4,26 +4,30 @@ require 'portrayal/schema'
|
|
4
4
|
module Portrayal
|
5
5
|
NULL = :_portrayal_value_not_set
|
6
6
|
|
7
|
-
def keyword(name,
|
7
|
+
def keyword(name, default: NULL, define: nil, &block)
|
8
8
|
unless respond_to?(:portrayal)
|
9
|
-
class << self
|
9
|
+
class << self
|
10
|
+
attr_reader :portrayal
|
11
|
+
def inherited(base)
|
12
|
+
base.instance_variable_set('@portrayal', portrayal.dup)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
10
16
|
@portrayal = Schema.new
|
17
|
+
class_eval(Schema::DEFINITION_OF_OBJECT_ENHANCEMENTS)
|
11
18
|
end
|
12
19
|
|
13
|
-
|
20
|
+
attr_accessor name
|
21
|
+
protected "#{name}="
|
14
22
|
|
15
|
-
portrayal.add_keyword(name,
|
23
|
+
portrayal.add_keyword(name, default)
|
16
24
|
class_eval(portrayal.definition_of_initialize)
|
17
25
|
|
18
|
-
unless portrayal.equality_defined?
|
19
|
-
class_eval(portrayal.definition_of_equality)
|
20
|
-
portrayal.mark_equality_defined
|
21
|
-
end
|
22
|
-
|
23
26
|
if block_given?
|
24
|
-
|
25
|
-
|
26
|
-
const_set(portrayal.camelcase(name), keyword_class)
|
27
|
+
kw_class = Class.new(superclass) { extend Portrayal }
|
28
|
+
const_set(define || portrayal.camelize(name), kw_class).class_eval(&block)
|
27
29
|
end
|
30
|
+
|
31
|
+
name
|
28
32
|
end
|
29
33
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Portrayal
|
2
|
+
class Default
|
3
|
+
attr_reader :value
|
4
|
+
|
5
|
+
def initialize(value)
|
6
|
+
@value = value
|
7
|
+
@callable = value.is_a?(Proc) && !value.lambda?
|
8
|
+
end
|
9
|
+
|
10
|
+
def call?; @callable end
|
11
|
+
def initialize_dup(src); super; @value = src.value.dup end
|
12
|
+
end
|
13
|
+
end
|
data/lib/portrayal/schema.rb
CHANGED
@@ -1,93 +1,70 @@
|
|
1
|
+
require 'portrayal/default'
|
2
|
+
|
1
3
|
module Portrayal
|
2
4
|
class Schema
|
3
5
|
attr_reader :schema
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
7
|
+
DEFINITION_OF_OBJECT_ENHANCEMENTS = <<~RUBY.freeze
|
8
|
+
def eql?(other); self.class == other.class && self == other end
|
9
|
+
def hash; [self.class, self.class.portrayal.attributes(self)].hash end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
end
|
11
|
+
def ==(other)
|
12
|
+
return super unless other.class.is_a?(Portrayal)
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
self.class.portrayal.attributes(self) ==
|
15
|
+
self.class.portrayal.attributes(other)
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
18
|
+
def freeze
|
19
|
+
self.class.portrayal.attributes(self).values.each(&:freeze)
|
20
|
+
super
|
21
|
+
end
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
[false, nil]
|
28
|
-
elsif optional != NULL && default == NULL
|
29
|
-
[optional, optional ? [:return, nil] : nil]
|
30
|
-
elsif optional == NULL && default != NULL
|
31
|
-
[true, [default_strategy(default), default]]
|
32
|
-
else
|
33
|
-
[optional, optional ? [default_strategy(default), default] : nil]
|
23
|
+
def initialize_dup(source)
|
24
|
+
self.class.portrayal.attributes(source).each do |key, value|
|
25
|
+
instance_variable_set("@\#{key}", value.dup)
|
34
26
|
end
|
27
|
+
super
|
28
|
+
end
|
35
29
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
30
|
+
def initialize_clone(source)
|
31
|
+
self.class.portrayal.attributes(source).each do |key, value|
|
32
|
+
instance_variable_set("@\#{key}", value.clone)
|
33
|
+
end
|
34
|
+
super
|
35
|
+
end
|
36
|
+
RUBY
|
42
37
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
end
|
38
|
+
def initialize; @schema = {} end
|
39
|
+
def keywords; @schema.keys end
|
40
|
+
def [](name); @schema[name] end
|
47
41
|
|
48
|
-
def
|
49
|
-
|
42
|
+
def attributes(object)
|
43
|
+
Hash[object.class.portrayal.keywords.map { |k| [k, object.send(k)] }]
|
50
44
|
end
|
51
45
|
|
52
|
-
def
|
53
|
-
init_args =
|
54
|
-
@schema
|
55
|
-
.map { |name, config|
|
56
|
-
if config[:optional]
|
57
|
-
"#{name}: self.class.portrayal.get_default(:#{name})"
|
58
|
-
else
|
59
|
-
"#{name}:"
|
60
|
-
end
|
61
|
-
}
|
62
|
-
.join(',')
|
63
|
-
|
64
|
-
init_assignments =
|
65
|
-
@schema
|
66
|
-
.keys
|
67
|
-
.map { |name| "@#{name} = #{name}" }
|
68
|
-
.join('; ')
|
46
|
+
def camelize(string); string.to_s.gsub(/(?:^|_+)([^_])/) { $1.upcase } end
|
69
47
|
|
70
|
-
|
48
|
+
def add_keyword(name, default)
|
49
|
+
@schema[name.to_sym] = default.equal?(NULL) ? nil : Default.new(default)
|
71
50
|
end
|
72
51
|
|
73
|
-
def
|
74
|
-
|
75
|
-
def ==(other)
|
76
|
-
self.class == other.class &&
|
77
|
-
self.class.portrayal.attributes(self) ==
|
78
|
-
self.class.portrayal.attributes(other)
|
79
|
-
end
|
80
|
-
|
81
|
-
alias eql? ==
|
82
|
-
RUBY
|
52
|
+
def initialize_dup(other)
|
53
|
+
super; @schema = other.schema.transform_values(&:dup)
|
83
54
|
end
|
84
55
|
|
85
|
-
def
|
86
|
-
@
|
87
|
-
|
56
|
+
def definition_of_initialize
|
57
|
+
init_args = @schema.map { |name, default|
|
58
|
+
"#{name}:#{default && " self.class.portrayal[:#{name}]"}"
|
59
|
+
}.join(', ')
|
60
|
+
|
61
|
+
init_assigns = @schema.keys.map { |name|
|
62
|
+
"@#{name} = #{name}.is_a?(::Portrayal::Default) ? " \
|
63
|
+
"(#{name}.call? ? instance_exec(&#{name}.value) : #{name}.value) : " \
|
64
|
+
"#{name}"
|
65
|
+
}.join('; ')
|
88
66
|
|
89
|
-
|
90
|
-
@equality_defined = true
|
67
|
+
"def initialize(#{init_args}); #{init_assigns} end"
|
91
68
|
end
|
92
69
|
end
|
93
70
|
end
|
data/lib/portrayal/version.rb
CHANGED
data/portrayal.gemspec
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require 'portrayal/version'
|
1
|
+
require_relative 'lib/portrayal/version'
|
4
2
|
|
5
3
|
Gem::Specification.new do |spec|
|
6
4
|
spec.name = 'portrayal'
|
@@ -9,17 +7,22 @@ Gem::Specification.new do |spec|
|
|
9
7
|
spec.email = ['madfancier@gmail.com']
|
10
8
|
|
11
9
|
spec.summary = 'A minimal builder for struct-like classes'
|
12
|
-
spec.description = 'Inspired by dry-initializer and virtus, portrayal is a minimalist gem
|
10
|
+
spec.description = 'Inspired by dry-initializer and virtus, portrayal is a minimalist gem that takes a somewhat different approach to building struct-like classes. It steps away from types, coersion, and writer methods in favor of encouraging well-designed constructors. Read more in the Philosophy section of the README.'
|
13
11
|
spec.homepage = 'https://github.com/scottscheapflights/portrayal'
|
14
12
|
spec.license = 'Apache-2.0'
|
15
13
|
|
14
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
15
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
16
|
+
spec.metadata['changelog_uri'] = 'https://github.com/scottscheapflights/portrayal/blob/main/CHANGELOG.md'
|
17
|
+
|
18
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
|
16
19
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
17
20
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) }
|
18
21
|
end
|
19
22
|
spec.require_paths = ['lib']
|
20
23
|
|
21
|
-
spec.add_development_dependency 'bundler', '~> 2.
|
22
|
-
spec.add_development_dependency 'rake', '~>
|
23
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
24
|
-
spec.add_development_dependency 'pry', '~> 0.
|
24
|
+
spec.add_development_dependency 'bundler', '~> 2.1'
|
25
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.9'
|
27
|
+
spec.add_development_dependency 'pry', '~> 0.13'
|
25
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: portrayal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxim Chernyak
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,88 +16,90 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.1'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.9'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.9'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
61
|
+
version: '0.13'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
68
|
+
version: '0.13'
|
69
69
|
description: Inspired by dry-initializer and virtus, portrayal is a minimalist gem
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
the README.
|
70
|
+
that takes a somewhat different approach to building struct-like classes. It steps
|
71
|
+
away from types, coersion, and writer methods in favor of encouraging well-designed
|
72
|
+
constructors. Read more in the Philosophy section of the README.
|
74
73
|
email:
|
75
74
|
- madfancier@gmail.com
|
76
75
|
executables: []
|
77
76
|
extensions: []
|
78
77
|
extra_rdoc_files: []
|
79
78
|
files:
|
79
|
+
- ".github/workflows/rspec.yml"
|
80
80
|
- ".gitignore"
|
81
81
|
- ".rspec"
|
82
|
-
- ".travis.yml"
|
83
82
|
- CHANGELOG.md
|
84
83
|
- CODE_OF_CONDUCT.md
|
85
84
|
- Gemfile
|
86
|
-
- Gemfile.lock
|
87
85
|
- LICENSE.txt
|
88
86
|
- README.md
|
89
87
|
- Rakefile
|
90
88
|
- bin/console
|
91
89
|
- bin/setup
|
92
90
|
- lib/portrayal.rb
|
91
|
+
- lib/portrayal/default.rb
|
93
92
|
- lib/portrayal/schema.rb
|
94
93
|
- lib/portrayal/version.rb
|
95
94
|
- portrayal.gemspec
|
96
95
|
homepage: https://github.com/scottscheapflights/portrayal
|
97
96
|
licenses:
|
98
97
|
- Apache-2.0
|
99
|
-
metadata:
|
100
|
-
|
98
|
+
metadata:
|
99
|
+
homepage_uri: https://github.com/scottscheapflights/portrayal
|
100
|
+
source_code_uri: https://github.com/scottscheapflights/portrayal
|
101
|
+
changelog_uri: https://github.com/scottscheapflights/portrayal/blob/main/CHANGELOG.md
|
102
|
+
post_install_message:
|
101
103
|
rdoc_options: []
|
102
104
|
require_paths:
|
103
105
|
- lib
|
@@ -105,15 +107,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
107
|
requirements:
|
106
108
|
- - ">="
|
107
109
|
- !ruby/object:Gem::Version
|
108
|
-
version:
|
110
|
+
version: 2.4.0
|
109
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
112
|
requirements:
|
111
113
|
- - ">="
|
112
114
|
- !ruby/object:Gem::Version
|
113
115
|
version: '0'
|
114
116
|
requirements: []
|
115
|
-
rubygems_version: 3.
|
116
|
-
signing_key:
|
117
|
+
rubygems_version: 3.1.2
|
118
|
+
signing_key:
|
117
119
|
specification_version: 4
|
118
120
|
summary: A minimal builder for struct-like classes
|
119
121
|
test_files: []
|
data/.travis.yml
DELETED
data/Gemfile.lock
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
portrayal (0.2.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
coderay (1.1.2)
|
10
|
-
diff-lcs (1.3)
|
11
|
-
method_source (0.9.2)
|
12
|
-
pry (0.12.2)
|
13
|
-
coderay (~> 1.1.0)
|
14
|
-
method_source (~> 0.9.0)
|
15
|
-
rake (10.5.0)
|
16
|
-
rspec (3.8.0)
|
17
|
-
rspec-core (~> 3.8.0)
|
18
|
-
rspec-expectations (~> 3.8.0)
|
19
|
-
rspec-mocks (~> 3.8.0)
|
20
|
-
rspec-core (3.8.0)
|
21
|
-
rspec-support (~> 3.8.0)
|
22
|
-
rspec-expectations (3.8.3)
|
23
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
-
rspec-support (~> 3.8.0)
|
25
|
-
rspec-mocks (3.8.0)
|
26
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
-
rspec-support (~> 3.8.0)
|
28
|
-
rspec-support (3.8.0)
|
29
|
-
|
30
|
-
PLATFORMS
|
31
|
-
ruby
|
32
|
-
|
33
|
-
DEPENDENCIES
|
34
|
-
bundler (~> 2.0)
|
35
|
-
portrayal!
|
36
|
-
pry (~> 0.12)
|
37
|
-
rake (~> 10.0)
|
38
|
-
rspec (~> 3.0)
|
39
|
-
|
40
|
-
BUNDLED WITH
|
41
|
-
2.0.1
|