deep-freeze 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/.ruby-version +1 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +24 -0
- data/LICENSE +21 -0
- data/README.md +3 -0
- data/Rakefile +8 -0
- data/deep-freeze.gemspec +17 -0
- data/lib/deep-freeze.rb +9 -0
- data/test/helper.rb +6 -0
- data/test/test-deep-freeze.rb +31 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fe638e38de55e6abfbe07e55ee4392b1d74aadf8026df3e4ecc1aa992ff4380f
|
4
|
+
data.tar.gz: ee3e4591a612b3af416eb29d95b1751fbfdf3cddc637d40466609564ec37f849
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fcf48e1e9cf6803dff28e33378611eb69e6916d9cd50f6d6d07e776aaf452635e40412a3e1fd87f34d0c4be74b49454e049ccf2a5f2585cb0b66b5c86ccba8dd
|
7
|
+
data.tar.gz: 9863780de58902af61917e0cad8b9db3f1a1718f4fa265a1fa0c41633a0e08030ab187d3a03231fdb52e900bf716dd24ce2ab577d981592ebafebfa10f731ab6
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.1
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
deep-freeze (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
power_assert (1.1.3)
|
10
|
+
rake (12.3.1)
|
11
|
+
test-unit (3.2.8)
|
12
|
+
power_assert
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
bundler (~> 1.7)
|
19
|
+
deep-freeze!
|
20
|
+
rake (~> 12.3)
|
21
|
+
test-unit (~> 3.2)
|
22
|
+
|
23
|
+
BUNDLED WITH
|
24
|
+
1.16.5
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Yaroslav Konoplov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
data/deep-freeze.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "deep-freeze"
|
6
|
+
s.version = "1.0.0"
|
7
|
+
s.author = "Yaroslav Konoplov"
|
8
|
+
s.email = "eahome00@gmail.com"
|
9
|
+
s.summary = "Deep freeze Ruby enumerables."
|
10
|
+
s.description = "The gem provides easy way to deep freeze Ruby enumerables."
|
11
|
+
s.homepage = "https://github.com/yivo/deep-freeze"
|
12
|
+
s.license = "MIT"
|
13
|
+
s.files = `git ls-files -z`.split("\x0")
|
14
|
+
s.test_files = `git ls-files -z -- {test,spec,features}/*`.split("\x0")
|
15
|
+
s.require_paths = ["lib"]
|
16
|
+
s.add_development_dependency "bundler", "~> 1.7"
|
17
|
+
end
|
data/lib/deep-freeze.rb
ADDED
data/test/helper.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "helper"
|
5
|
+
|
6
|
+
class DeepFreezeTest < Test::Unit::TestCase
|
7
|
+
test "Array#deep_freeze" do
|
8
|
+
array = [{ a: { b: [{ c: [], (d = Class.new) => Class.new }] } }]
|
9
|
+
assert_same array, array.deep_freeze
|
10
|
+
assert_true array.frozen?
|
11
|
+
assert_true array[0].frozen?
|
12
|
+
assert_true array[0][:a].frozen?
|
13
|
+
assert_true array[0][:a][:b].frozen?
|
14
|
+
assert_true array[0][:a][:b][0].frozen?
|
15
|
+
assert_true array[0][:a][:b][0][:c].frozen?
|
16
|
+
assert_true d.frozen? # Check if key is frozen.
|
17
|
+
assert_true array[0][:a][:b][0][d].frozen?
|
18
|
+
end
|
19
|
+
|
20
|
+
test "Hash#deep_freeze" do
|
21
|
+
hash = { a: { b: [{ c: [], (d = Class.new) => Class.new }] } }
|
22
|
+
assert_same hash, hash.deep_freeze
|
23
|
+
assert_true hash.frozen?
|
24
|
+
assert_true hash[:a].frozen?
|
25
|
+
assert_true hash[:a][:b].frozen?
|
26
|
+
assert_true hash[:a][:b][0].frozen?
|
27
|
+
assert_true hash[:a][:b][0][:c].frozen?
|
28
|
+
assert_true d.frozen? # Check if key is frozen.
|
29
|
+
assert_true hash[:a][:b][0][d].frozen?
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: deep-freeze
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yaroslav Konoplov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
description: The gem provides easy way to deep freeze Ruby enumerables.
|
28
|
+
email: eahome00@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- ".gitignore"
|
34
|
+
- ".ruby-version"
|
35
|
+
- Gemfile
|
36
|
+
- Gemfile.lock
|
37
|
+
- LICENSE
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- deep-freeze.gemspec
|
41
|
+
- lib/deep-freeze.rb
|
42
|
+
- test/helper.rb
|
43
|
+
- test/test-deep-freeze.rb
|
44
|
+
homepage: https://github.com/yivo/deep-freeze
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata: {}
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 2.7.6
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
67
|
+
summary: Deep freeze Ruby enumerables.
|
68
|
+
test_files:
|
69
|
+
- test/helper.rb
|
70
|
+
- test/test-deep-freeze.rb
|