structure 0.27.3 → 0.27.4

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: 543ffd06f050b41405d2760cd7acc6e5ba3fd4f7
4
- data.tar.gz: c8bb827aaed4acde43fd70386724d1c92c9bd759
3
+ metadata.gz: b67fbe24cad1e50983d1ea7d57cb72478f028805
4
+ data.tar.gz: b233d50e95cfeacf2083bea2578961b880d5524b
5
5
  SHA512:
6
- metadata.gz: 0a9a4282f5186062d454f901f1b518afd9054fd8041add41ac97339ba6a01cef52581113eb03bdb31244aa4b2f29d4db55b7f80553032beaeb5ac281132a101b
7
- data.tar.gz: 5484b1f51b1c8c6ff7fc0e6e0200fba2b703fddfa38de3782c1df37943ac9e387e858f7c227005a69bbd28d93839c928152828dba8ef9c11688a9a0c3af0f632
6
+ metadata.gz: a1451461d6a80e1ecd5072efea01f57916acbff487b1852b648409107b6a0a48dfa6f9cfbd77913cab39e1a4e2b96755d5853b9ec905203005767348551667b7
7
+ data.tar.gz: a1d4edb3c2bd35a30e53ac728c23f5aacc04af07b7276471fc6b2de6a149cb0d0e48a6096ca9bfa0cc4ccecac02dac2992b464cd6b338db22ea191c7ad5e8e57
data/structure.rb CHANGED
@@ -18,7 +18,13 @@ module Structure
18
18
  def inspect
19
19
  "#<#{self.class} #{
20
20
  attributes
21
- .map { |key, val| "#{key}=#{val.inspect}" }
21
+ .map { |key, val|
22
+ if val.is_a?(Array) && val.size > 3
23
+ "#{key}=[#{val.take(3).map(&:inspect).join(', ')}...]"
24
+ else
25
+ "#{key}=#{val.inspect}"
26
+ end
27
+ }
22
28
  .join(', ')
23
29
  }>"
24
30
  end
@@ -57,4 +57,12 @@ class StructureTest < MiniTest::Test
57
57
  assert_equal '#<Location latitude=10, longitude=20>', @location.inspect
58
58
  assert_equal @location.to_s, @location.inspect
59
59
  end
60
+
61
+ def test_truncates_long_arrays_when_pretty_inspecting
62
+ klass = Class.new { include Structure }
63
+ klass.attribute(:ary) { ['a'] }
64
+ assert_includes klass.new.inspect, 'ary=["a"]'
65
+ klass.attribute(:ary) { ('a'..'z').to_a }
66
+ assert_includes klass.new.inspect, 'ary=["a", "b", "c"...]'
67
+ end
60
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: structure
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.3
4
+ version: 0.27.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hakan Ensari
@@ -47,7 +47,7 @@ files:
47
47
  - LICENSE
48
48
  - README.md
49
49
  - structure.rb
50
- - structure_test.rb
50
+ - test.rb
51
51
  homepage:
52
52
  licenses: []
53
53
  metadata: {}