trick_bag 0.38.0 → 0.39.0

Sign up to get free protection for your applications and to get access to all the features.
data/RELEASE_NOTES.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## v0.39.0
2
+
3
+ * Added CoreTypes.clone_hash_except.
4
+ * Added FileLineReader.to_s.
5
+
6
+
1
7
  ## v0.38.0
2
8
 
3
9
  * Added documentation.
@@ -0,0 +1,13 @@
1
+ module TrickBag
2
+ module CoreTypes
3
+
4
+ module_function
5
+
6
+ def clone_hash_except(source_hash, keys_to_delete)
7
+ new_hash = source_hash.clone
8
+ keys_to_delete.each { |key| new_hash.delete(key) }
9
+ new_hash
10
+ end
11
+
12
+ end
13
+ end
@@ -111,6 +111,11 @@ class FileLineReader
111
111
  close_file(file)
112
112
  end
113
113
  end
114
+
115
+
116
+ def to_s
117
+ "#{self.class}: filespec: #{filespec}, start_pos: #{start_pos.inspect}, max_count: #{max_count.inspect}"
118
+ end
114
119
  end
115
120
  end
116
121
  end
@@ -1,3 +1,3 @@
1
1
  module TrickBag
2
- VERSION = "0.38.0"
2
+ VERSION = "0.39.0"
3
3
  end
@@ -0,0 +1,35 @@
1
+ require_relative '../spec_helper'
2
+ require 'trick_bag/core_types'
3
+
4
+ module TrickBag
5
+
6
+ describe CoreTypes do
7
+
8
+ include CoreTypes
9
+
10
+ specify 'deleting nonexistent keys should produce no error and return the original hash' do
11
+ h = { a: 1, b: 2 }
12
+ expect(clone_hash_except(h, [:x, :z])).to eq(h)
13
+ end
14
+
15
+
16
+ specify 'deleting keys is successful' do
17
+ h = { a: 1, b: 2, c: 3, d: 4 }
18
+ keys_to_delete = [:b, :d]
19
+ new_h = clone_hash_except(h, keys_to_delete)
20
+ keys_to_delete.each do |key|
21
+ expect(new_h.has_key?(key)).to be_false
22
+ end
23
+ end
24
+
25
+
26
+ specify 'original hash is unchanged even when keys are deleted' do
27
+ h = { a: 1, b: 2, c: 3, d: 4 }
28
+ h_sav = h.clone
29
+ keys_to_delete = [:b, :d]
30
+ _ = clone_hash_except(h, keys_to_delete)
31
+ expect(h).to eq(h_sav)
32
+ end
33
+ end
34
+ end
35
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trick_bag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.38.0
4
+ version: 0.39.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-24 00:00:00.000000000 Z
12
+ date: 2014-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: os
@@ -123,6 +123,7 @@ files:
123
123
  - Rakefile
124
124
  - lib/trick_bag.rb
125
125
  - lib/trick_bag/collections/linked_list.rb
126
+ - lib/trick_bag/core_types.rb
126
127
  - lib/trick_bag/enumerables/buffered_enumerable.rb
127
128
  - lib/trick_bag/enumerables/compound_enumerable.rb
128
129
  - lib/trick_bag/enumerables/endless_last_enumerable.rb
@@ -143,6 +144,7 @@ files:
143
144
  - lib/trick_bag/version.rb
144
145
  - spec/spec_helper.rb
145
146
  - spec/trick_bag/collections/linked_list_spec.rb
147
+ - spec/trick_bag/core_types_spec.rb
146
148
  - spec/trick_bag/enumerables/buffered_enumerable_spec.rb
147
149
  - spec/trick_bag/enumerables/compound_enumerable_spec.rb
148
150
  - spec/trick_bag/enumerables/endless_last_enumerable_spec.rb
@@ -189,6 +191,7 @@ summary: Miscellaneous general useful tools.
189
191
  test_files:
190
192
  - spec/spec_helper.rb
191
193
  - spec/trick_bag/collections/linked_list_spec.rb
194
+ - spec/trick_bag/core_types_spec.rb
192
195
  - spec/trick_bag/enumerables/buffered_enumerable_spec.rb
193
196
  - spec/trick_bag/enumerables/compound_enumerable_spec.rb
194
197
  - spec/trick_bag/enumerables/endless_last_enumerable_spec.rb