valuables 0.1.0 → 0.2.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: 42a28204127e78a53b98cb474d99647083f6a2d1
4
- data.tar.gz: c9e9ae645d5845b84eb0bf72a67de525dd16d896
3
+ metadata.gz: 45335de460564531a2dcb8df1a76e94925230148
4
+ data.tar.gz: 02e86a1af1315f6fd5a7033c65dd1e9e7abbbbd6
5
5
  SHA512:
6
- metadata.gz: 79c3f9a2c91f5debfec1af2128b0181f46ea04ec2c50dec7eea9db56682e9acab8fc94c536d0d376c6c8e2db5c5ab7e7d4b5733671d8166c45cc6b076c56015e
7
- data.tar.gz: 7110281df5e13ac135ff0c47dc501fd69e916f8683ce9a68a6072f6e4ad608a07aac967b065ab882153a2a7f10e957afeaca4ebd25f85265dd16162c28402326
6
+ metadata.gz: eeac19cbc9d449803e8283d385b14f309273d35d7620d3a834a493123428b4f887f07bf96afb1b7a7f87ea580926cbdb7d104f5bc973c69f6b46b51e42795d53
7
+ data.tar.gz: da7f0756f86a33674ccfb83b0f2a5ddedaac4a7ed155894f8217b536c7c4b1136065d72a73a237311e456e5d47d63acd681569d8138ab0abf49045b8c9d87d9c
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0
4
+
5
+ * Do not try to duplicate fixnums
6
+
7
+ ## 0.1.0
8
+
9
+ * initial release
@@ -13,19 +13,20 @@ module Valuables
13
13
 
14
14
  # Like Ruby's +#freeze+ but recurses into contained values.
15
15
  def deep_freeze(obj)
16
- if obj.respond_to?(:deep_freeze)
16
+ case obj
17
+ when ->(obj) { obj.respond_to?(:deep_freeze) }
17
18
  obj.deep_freeze
18
- elsif obj.kind_of?(Hash)
19
+ when Hash
19
20
  obj.reduce({}) do |acc, (key, value)|
20
21
  acc.merge deep_freeze(key) => deep_freeze(value)
21
22
  end.freeze
22
- elsif obj.kind_of?(Array)
23
+ when Array
23
24
  obj.reduce([]) do |acc, value|
24
25
  acc << deep_freeze(value)
25
26
  end.freeze
26
- elsif obj.kind_of?(Range)
27
+ when Range
27
28
  deep_freeze(obj.begin)..deep_freeze(obj.end).freeze
28
- elsif obj.kind_of?(Symbol)
29
+ when Symbol, Fixnum
29
30
  obj
30
31
  else
31
32
  obj.dup.freeze
@@ -1,3 +1,3 @@
1
1
  module Valuables
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: valuables
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arjan van der Gaag
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-10 00:00:00.000000000 Z
11
+ date: 2015-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -68,6 +68,7 @@ extra_rdoc_files: []
68
68
  files:
69
69
  - ".gitignore"
70
70
  - ".travis.yml"
71
+ - CHANGELOG.md
71
72
  - CODE_OF_CONDUCT.md
72
73
  - Gemfile
73
74
  - LICENSE.txt