closed_struct 0.1.1 → 0.1.2

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: c669df732e5d918f8005a54828a942df5c4b23cd
4
- data.tar.gz: 30f9baf34069f32b26d7c37ad985d15907f35602
3
+ metadata.gz: 28546d4be83e1624fef9ec85a238cfd3d6debdfe
4
+ data.tar.gz: eac66537ba3862b2abeb1dca394ec160c1ac2563
5
5
  SHA512:
6
- metadata.gz: 5777a4b42559d29b0e502897f236e67b513788aa54a2930db64037d24ef3421b4e43ebf562b59912c709cea097f398fae245b703de45fb7f5cd01795e842c67b
7
- data.tar.gz: 7ba12f806c71741340cf3a50cd4bcb3df50b1e40b8c3068eb1bc73099943d80dd8f51dbd3944ab428c89e913fede8f7ff31e5e3987c7672ec53b066f1e6f7300
6
+ metadata.gz: d6eb380739825b3df92abe99441042d364c12a25f5b437f0f63d1a5a61d8dfe518018dde7e90801a52c5f1cec31ce384280167d8c8885b81670f37a59ee6c597
7
+ data.tar.gz: 70821c0e52ddd86aa837757aa876a0faa6c08b881ec3b65e0656641c61595e463cfae68016083f3e6abecb0dc47714c4e1366ae1f51ac7aebf23d519810c07ca
data/CHANGELOG CHANGED
@@ -1,2 +1,4 @@
1
+ 0.1.2
2
+ + Added #each_pair to iterate
1
3
  0.1.1
2
4
  + Added #empty? to check if there is any data
@@ -29,4 +29,12 @@ class ClosedStruct
29
29
  def empty?
30
30
  @contents.empty?
31
31
  end
32
+
33
+ def each_pair
34
+ return enum_for(:each_pair) unless block_given?
35
+
36
+ @contents.each_pair do |key, value|
37
+ yield key, value
38
+ end
39
+ end
32
40
  end
@@ -1,3 +1,3 @@
1
1
  class ClosedStruct
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -60,4 +60,25 @@ describe ClosedStruct do
60
60
  expect(ClosedStruct.new(:a => :b).empty?).to be_falsey
61
61
  end
62
62
 
63
+ describe "#each_pair" do
64
+ it "does not yield when empty" do
65
+ object = ClosedStruct.new({})
66
+ expect { |b| object.each_pair(&b) }.to_not yield_control
67
+ end
68
+
69
+ it "yields a key-value pair for a key in the hash" do
70
+ object = ClosedStruct.new(:a => :b)
71
+ expect { |b| object.each_pair(&b) }.to yield_with_args(:a, :b)
72
+ end
73
+
74
+ it "yields a key-value pair for each key in the hash" do
75
+ object = ClosedStruct.new(:a => :b, :c => :d)
76
+ expect { |b| object.each_pair(&b) }.to yield_successive_args([:a, :b], [:c, :d])
77
+ end
78
+
79
+ it "returns an enumerator if a block is not provided" do
80
+ expect(ClosedStruct.new(:a => :b).each_pair).to contain_exactly([:a, :b])
81
+ expect(ClosedStruct.new({}).each_pair).to_not include(anything)
82
+ end
83
+ end
63
84
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: closed_struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paweł Obrok
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-17 00:00:00.000000000 Z
11
+ date: 2017-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler