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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eeb24e8ffff128d18963b1b9b35b542b260a2ec3b0e298064201c108a58c0c6c
4
- data.tar.gz: 36adc49da54f8a4756d08dd0f33fbff9b6b5366115082682ff9b9fd46bd26687
3
+ metadata.gz: fbd0b561e866c45f6e850b592620df78d4573635165807cd2284ab45baed9e0c
4
+ data.tar.gz: 699be912aa836a55faa10886a3a1c1bb7b17c006f1db445694660d2fbe0ec0f4
5
5
  SHA512:
6
- metadata.gz: 992c3b99a75e3b0226d55cc6429072be5abac8248aab9e43903352a2aeb50b0ad29acdb3dd28993ae7ddabc46b3784440d5048afef958d1ffdae1bc9e6f4738c
7
- data.tar.gz: 4bc0a1cec3d59ae6db9e22e60504accc420e036ab197313e1c0b9f71219e3aae341acf82de1faa2f88984e6af79d19f1c4f825ad1fc5594b12db3497dcdc168c
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
@@ -7,5 +7,8 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
 
10
+ # Recommended for gems
11
+ /Gemfile.lock
12
+
10
13
  # rspec failure tracking
11
14
  .rspec_status
@@ -1,11 +1,41 @@
1
1
  This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
2
2
 
3
- ## [0.2.0] - 2019-07-03
3
+ ## Unreleased
4
4
 
5
- ### Changed
5
+ ## 0.7.0 - 2020-12-13
6
6
 
7
- * 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.
7
+ * **Breaking change:** Remove `optional` setting. To update find all `optional: true` and change to `default: nil` instead.
8
8
 
9
- ## [0.1.0]
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, optional: true
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
- attr_reader :name, :age, :favorite_fruit, :address
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
- self.class == other.class &&
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
- alias eql? ==
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
- attr_reader :street, :city
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
- self.class == other.class &&
73
- { street: street, city: city } == { street: other.street, city: other.city }
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
- alias eql? ==
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, optional: true
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=>{:optional=>false, :default=>nil}, :city=>{:optional=>false, :default=>nil}, :postcode=>{:optional=>false, :default=>nil}, :country=>{:optional=>true, :default=>[:return, nil]}}
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, optional: true
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, optional: true
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/master/CODE_OF_CONDUCT.md).
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).
@@ -4,26 +4,30 @@ require 'portrayal/schema'
4
4
  module Portrayal
5
5
  NULL = :_portrayal_value_not_set
6
6
 
7
- def keyword(name, optional: NULL, default: NULL, &block)
7
+ def keyword(name, default: NULL, define: nil, &block)
8
8
  unless respond_to?(:portrayal)
9
- class << self; attr_reader :portrayal end
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
- attr_reader name
20
+ attr_accessor name
21
+ protected "#{name}="
14
22
 
15
- portrayal.add_keyword(name, optional, default)
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
- keyword_class = Class.new(superclass) { extend Portrayal }
25
- keyword_class.class_eval(&block)
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
@@ -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
- def initialize
6
- @schema = {}
7
- @equality_defined = false
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
- def [](name)
11
- @schema[name]
12
- end
11
+ def ==(other)
12
+ return super unless other.class.is_a?(Portrayal)
13
13
 
14
- def keywords
15
- @schema.keys
16
- end
14
+ self.class.portrayal.attributes(self) ==
15
+ self.class.portrayal.attributes(other)
16
+ end
17
17
 
18
- def attributes(object)
19
- Hash[
20
- object.class.portrayal.keywords.map { |key| [key, object.send(key)] }
21
- ]
22
- end
18
+ def freeze
19
+ self.class.portrayal.attributes(self).values.each(&:freeze)
20
+ super
21
+ end
23
22
 
24
- def add_keyword(name, optional, default)
25
- optional, default =
26
- if optional == NULL && default == NULL
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
- @schema[name.to_sym] = { optional: optional, default: default }
37
- end
38
-
39
- def camelcase(string)
40
- string.to_s.gsub(/(?:^|_+)([^_])/) { $1.upcase }
41
- end
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 get_default(name)
44
- action, value = @schema[name][:default]
45
- action == :call ? value.call : value
46
- end
38
+ def initialize; @schema = {} end
39
+ def keywords; @schema.keys end
40
+ def [](name); @schema[name] end
47
41
 
48
- def default_strategy(value)
49
- (value.is_a?(Proc) && !value.lambda?) ? :call : :return
42
+ def attributes(object)
43
+ Hash[object.class.portrayal.keywords.map { |k| [k, object.send(k)] }]
50
44
  end
51
45
 
52
- def definition_of_initialize
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
- "def initialize(#{init_args}); #{init_assignments} end"
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 definition_of_equality
74
- <<-RUBY
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 equality_defined?
86
- @equality_defined
87
- end
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
- def mark_equality_defined
90
- @equality_defined = true
67
+ "def initialize(#{init_args}); #{init_assigns} end"
91
68
  end
92
69
  end
93
70
  end
@@ -1,3 +1,3 @@
1
1
  module Portrayal
2
- VERSION = "0.2.0"
2
+ VERSION = '0.7.0'
3
3
  end
@@ -1,6 +1,4 @@
1
- lib = File.expand_path('../lib', __FILE__)
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 (~120 loc, no dependencies) 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.'
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.0'
22
- spec.add_development_dependency 'rake', '~> 10.0'
23
- spec.add_development_dependency 'rspec', '~> 3.0'
24
- spec.add_development_dependency 'pry', '~> 0.12'
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.2.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: 2019-07-03 00:00:00.000000000 Z
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.0'
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.0'
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: '10.0'
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: '10.0'
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.0'
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.0'
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.12'
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.12'
68
+ version: '0.13'
69
69
  description: Inspired by dry-initializer and virtus, portrayal is a minimalist gem
70
- (~120 loc, no dependencies) that takes a somewhat different approach to building
71
- struct-like classes. It steps away from types, coersion, and writer methods in favor
72
- of encouraging well-designed constructors. Read more in the Philosophy section of
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
- post_install_message:
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: '0'
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.0.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: []
@@ -1,10 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.3
7
- - 2.4
8
- - 2.5
9
- - 2.6
10
- before_install: gem install bundler -v 2.0.1
@@ -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