attribs 1.0.0 → 1.1.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
  SHA1:
3
- metadata.gz: 41d8896fb88e2a974780b53d830f1e1a59f89ec6
4
- data.tar.gz: ab506e5dd05cf412fe6c2b47117251ef871da5ca
3
+ metadata.gz: ec55d797b8ae1c3b339e09422501c905e9df0728
4
+ data.tar.gz: 7152836f91cd025073370f106dfe0230b1add314
5
5
  SHA512:
6
- metadata.gz: 8c6043299fe57754ebeca285fc1ab41100d3e01805a41126672f2d37151b0cbf3290aaf717a520ebb92e518668585ffacb3a4ea3538cd86a683691fa1ba391d9
7
- data.tar.gz: 9d6e0984bc0e21bbda2b3555857163762f8d64c42a32e4307432aa3af3c71580fdb233550e7a5de4c352b3067c8efcc25199aa13df1cd4d2f669345ea74d4ce6
6
+ metadata.gz: 0a8cd8ed6aeea533b7a5b1cd9fdc5c9515f32f9f3d012b69d106ff434bd155934b048fc19654dcccb473bcf15aa304cf9e639fcfd80ee07537a44daef0e5624d
7
+ data.tar.gz: f741038d5e4e786ff6003d90e62559d632b4fadbd5885c3e2f7a2aadfa436c1072c5b268dae830ed1d5cc52e5b84162f75883f15deacf3a3735f36817d0533f5
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "attribs"
5
- gem.version = "1.0.0"
5
+ gem.version = "1.1.0"
6
6
  gem.authors = ["Arne Brasseur"]
7
7
  gem.email = ["arne@arnebrasseur.net"]
8
- gem.summary = %q{Perfect Features Toggles}
9
- gem.description = %q{Multi-strategy feature flags.}
8
+ gem.summary = %q{Easy and flexible Ruby value objects.}
9
+ gem.description = %q{Easy and flexible Ruby value objects.}
10
10
  gem.homepage = "https://github.com/plexus/attribs"
11
11
  gem.license = "MIT"
12
12
 
@@ -21,7 +21,15 @@ class Attribs
21
21
 
22
22
  def pp
23
23
  indent = ->(str) { str.lines.map {|l| " #{l}"}.join }
24
- format = ->(val) { val.respond_to?(:pp) ? val.pp : val.inspect }
24
+ format = ->(val) do
25
+ if val.respond_to?(:pp)
26
+ val.pp
27
+ elsif val.is_a? Time
28
+ "Time.parse(\"#{val.inspect}\")"
29
+ else
30
+ val.inspect
31
+ end
32
+ end
25
33
 
26
34
  values = to_h_compact
27
35
 
@@ -67,7 +67,7 @@ RSpec.describe Attribs do
67
67
  end
68
68
 
69
69
  it 'should expect all attributes' do
70
- expect { subject.new(foo: 5) }.to raise_exception
70
+ expect { subject.new(foo: 5) }.to raise_exception(Anima::Error::Missing)
71
71
  end
72
72
  end
73
73
  end
@@ -99,7 +99,7 @@ RSpec.describe Attribs do
99
99
  end
100
100
 
101
101
  it 'should expect all attributes' do
102
- expect { subject.new(foo: 5, bar: 6) }.to raise_exception
102
+ expect { subject.new(foo: 5, bar: 6) }.to raise_exception(Anima::Error::Missing)
103
103
  end
104
104
  end
105
105
  end
@@ -113,7 +113,7 @@ RSpec.describe Attribs do
113
113
  end
114
114
 
115
115
  it 'should no longer recognize the old attributes' do
116
- expect { subject.new(foo: 3, bar: 3).bar }.to raise_error
116
+ expect { subject.new(foo: 3, bar: 3).bar }.to raise_error(Anima::Error::Unknown)
117
117
  end
118
118
  end
119
119
 
@@ -125,7 +125,7 @@ RSpec.describe Attribs do
125
125
  end
126
126
 
127
127
  it 'should no longer recognize the old attributes' do
128
- expect { subject.new(foo: 3).foo }.to raise_error
128
+ expect { subject.new(foo: 3).foo }.to raise_error(Anima::Error::Unknown)
129
129
  end
130
130
 
131
131
  it 'should keep the defaults' do
@@ -150,6 +150,13 @@ RSpec.describe Attribs::InstanceMethods do
150
150
  end
151
151
  end
152
152
 
153
+ let(:one_attr) do
154
+ Class.new do
155
+ include Attribs.new(:the_attr)
156
+ def self.name ; 'OneAttr' ; end
157
+ end
158
+ end
159
+
153
160
  let(:fixed_width) do
154
161
  Class.new do
155
162
  def initialize(width)
@@ -195,6 +202,11 @@ WidgetContainer.new(
195
202
  expect(widget.new(color: fixed_width.new(18), size: fixed_width.new(18)).pp).to match /\n/
196
203
  expect(widget.new(color: fixed_width.new(18), size: fixed_width.new(17)).pp).to_not match /\n/
197
204
  end
205
+
206
+ it 'should write out a readable representation of Time instanced' do
207
+ expect(one_attr.new(the_attr: Time.parse("2016-02-22 09:41:29 +1100")).pp)
208
+ .to eql 'OneAttr.new(the_attr: Time.parse("2016-02-22 09:41:29 +1100"))'
209
+ end
198
210
  end
199
211
 
200
212
  describe '#append_to' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attribs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arne Brasseur
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-01 00:00:00.000000000 Z
11
+ date: 2016-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anima
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: Multi-strategy feature flags.
69
+ description: Easy and flexible Ruby value objects.
70
70
  email:
71
71
  - arne@arnebrasseur.net
72
72
  executables: []
@@ -105,10 +105,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  requirements: []
107
107
  rubyforge_project:
108
- rubygems_version: 2.4.6
108
+ rubygems_version: 2.4.5
109
109
  signing_key:
110
110
  specification_version: 4
111
- summary: Perfect Features Toggles
111
+ summary: Easy and flexible Ruby value objects.
112
112
  test_files:
113
113
  - spec/attribs_spec.rb
114
114
  - spec/spec_helper.rb