ice_nine 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/TODO +3 -0
- data/config/flay.yml +1 -1
- data/lib/ice_nine.rb +1 -1
- data/lib/ice_nine/freezer/array.rb +26 -0
- data/lib/ice_nine/freezer/struct.rb +1 -1
- data/lib/ice_nine/version.rb +1 -1
- data/spec/support/config_alias.rb +3 -0
- data/spec/unit/ice_nine/freezer/{enumerable → array}/class_methods/deep_freeze_spec.rb +4 -5
- data/spec/unit/ice_nine/freezer/class_methods/element_reference_spec.rb +3 -1
- data/spec/unit/ice_nine/freezer/false_class/class_methods/deep_freeze_spec.rb +2 -0
- data/spec/unit/ice_nine/freezer/nil_class/class_methods/deep_freeze_spec.rb +2 -0
- data/spec/unit/ice_nine/freezer/numeric/class_methods/deep_freeze_spec.rb +2 -0
- data/spec/unit/ice_nine/freezer/symbol/class_methods/deep_freeze_spec.rb +2 -0
- data/spec/unit/ice_nine/freezer/true_class/class_methods/deep_freeze_spec.rb +3 -0
- data/tasks/metrics/heckle.rake +2 -2
- data/tasks/spec.rake +4 -2
- metadata +46 -64
- data/lib/ice_nine/freezer/enumerable.rb +0 -29
data/TODO
CHANGED
data/config/flay.yml
CHANGED
data/lib/ice_nine.rb
CHANGED
@@ -7,7 +7,7 @@ require 'ice_nine/support/recursion_guard'
|
|
7
7
|
require 'ice_nine/freezer'
|
8
8
|
require 'ice_nine/freezer/object'
|
9
9
|
require 'ice_nine/freezer/no_freeze'
|
10
|
-
require 'ice_nine/freezer/
|
10
|
+
require 'ice_nine/freezer/array'
|
11
11
|
|
12
12
|
require 'ice_nine/freezer/false_class'
|
13
13
|
require 'ice_nine/freezer/hash'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module IceNine
|
4
|
+
class Freezer
|
5
|
+
|
6
|
+
# A freezer class for handling Array objects
|
7
|
+
class Array < Object
|
8
|
+
|
9
|
+
# Deep Freeze an Array
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# array = IceNine:Freezer::Array.deep_freeze(%w[a b c])
|
13
|
+
# array.select(&:frozen?) # => ['a', 'b', 'c']
|
14
|
+
#
|
15
|
+
# @param [Array] array
|
16
|
+
#
|
17
|
+
# @return [Array]
|
18
|
+
#
|
19
|
+
# @api public
|
20
|
+
def self.deep_freeze(array)
|
21
|
+
super array.each { |entry| IceNine.deep_freeze(entry) }
|
22
|
+
end
|
23
|
+
|
24
|
+
end # class Array
|
25
|
+
end # class Freezer
|
26
|
+
end # module IceNine
|
data/lib/ice_nine/version.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
-
require 'ice_nine
|
5
|
-
require 'ice_nine/freezer/enumerable'
|
4
|
+
require 'ice_nine'
|
6
5
|
|
7
|
-
describe IceNine::Freezer::
|
6
|
+
describe IceNine::Freezer::Array, '.deep_freeze' do
|
8
7
|
subject { object.deep_freeze(value) }
|
9
8
|
|
10
9
|
let(:object) { described_class }
|
11
10
|
|
12
|
-
context 'with an
|
11
|
+
context 'with an Array object' do
|
13
12
|
let(:value) { %w[a] }
|
14
13
|
|
15
14
|
it 'returns the object' do
|
@@ -20,7 +19,7 @@ describe IceNine::Freezer::Enumerable, '.deep_freeze' do
|
|
20
19
|
expect { subject }.should change(value, :frozen?).from(false).to(true)
|
21
20
|
end
|
22
21
|
|
23
|
-
it 'freezes each entry in the
|
22
|
+
it 'freezes each entry in the Array' do
|
24
23
|
subject.select(&:frozen?).should == subject
|
25
24
|
end
|
26
25
|
end
|
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
require 'ice_nine/freezer'
|
5
|
-
require 'ice_nine/freezer/
|
5
|
+
require 'ice_nine/freezer/object'
|
6
|
+
require 'ice_nine/freezer/array'
|
7
|
+
require 'ice_nine/freezer/struct'
|
6
8
|
|
7
9
|
describe IceNine::Freezer, '.[]' do
|
8
10
|
subject { object[mod] }
|
@@ -1,7 +1,10 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
+
require 'ice_nine/freezer'
|
5
|
+
require 'ice_nine/freezer/object'
|
4
6
|
require 'ice_nine/freezer/no_freeze'
|
7
|
+
require 'ice_nine/freezer/true_class'
|
5
8
|
|
6
9
|
describe IceNine::Freezer::TrueClass, '.deep_freeze' do
|
7
10
|
subject { object.deep_freeze(value) }
|
data/tasks/metrics/heckle.rake
CHANGED
@@ -203,8 +203,8 @@ begin
|
|
203
203
|
puts 'Well done! Your code withstood a heckling.'
|
204
204
|
end
|
205
205
|
end
|
206
|
-
rescue LoadError
|
206
|
+
rescue LoadError
|
207
207
|
task :heckle do
|
208
|
-
abort 'Heckle or mspec is not available. In order to run heckle, you must: gem install heckle mspec'
|
208
|
+
abort 'Heckle or mspec is not available. In order to run heckle, you must: gem install heckle mspec'
|
209
209
|
end
|
210
210
|
end
|
data/tasks/spec.rake
CHANGED
@@ -8,11 +8,13 @@ begin
|
|
8
8
|
|
9
9
|
namespace :spec do
|
10
10
|
Spec::Rake::SpecTask.new(:integration) do |t|
|
11
|
-
t.
|
11
|
+
t.ruby_opts = %w[ -r./spec/support/config_alias ]
|
12
|
+
t.pattern = 'spec/integration/**/*_spec.rb'
|
12
13
|
end
|
13
14
|
|
14
15
|
Spec::Rake::SpecTask.new(:unit) do |t|
|
15
|
-
t.
|
16
|
+
t.ruby_opts = %w[ -r./spec/support/config_alias ]
|
17
|
+
t.pattern = 'spec/unit/**/*_spec.rb'
|
16
18
|
end
|
17
19
|
end
|
18
20
|
rescue LoadError
|
metadata
CHANGED
@@ -1,67 +1,58 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ice_nine
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 4
|
9
|
-
- 0
|
10
|
-
version: 0.4.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Dan Kubb
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-10-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rake
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
18
|
+
requirements:
|
26
19
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 11
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
- 9
|
32
|
-
- 2
|
33
|
-
- 2
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 0.9.2.2
|
35
22
|
type: :development
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: rspec
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.9.2.2
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
41
33
|
none: false
|
42
|
-
requirements:
|
34
|
+
requirements:
|
43
35
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 31
|
46
|
-
segments:
|
47
|
-
- 1
|
48
|
-
- 3
|
49
|
-
- 2
|
36
|
+
- !ruby/object:Gem::Version
|
50
37
|
version: 1.3.2
|
51
38
|
type: :development
|
52
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.3.2
|
53
46
|
description: Deep Freeze Ruby Objects
|
54
|
-
email:
|
47
|
+
email:
|
55
48
|
- dan.kubb@gmail.com
|
56
49
|
executables: []
|
57
|
-
|
58
50
|
extensions: []
|
59
|
-
|
60
|
-
extra_rdoc_files:
|
51
|
+
extra_rdoc_files:
|
61
52
|
- LICENSE
|
62
53
|
- README.md
|
63
54
|
- TODO
|
64
|
-
files:
|
55
|
+
files:
|
65
56
|
- .gitignore
|
66
57
|
- .pelusa.yml
|
67
58
|
- .rvmrc
|
@@ -81,7 +72,7 @@ files:
|
|
81
72
|
- lib/ice_nine.rb
|
82
73
|
- lib/ice_nine/core_ext/object.rb
|
83
74
|
- lib/ice_nine/freezer.rb
|
84
|
-
- lib/ice_nine/freezer/
|
75
|
+
- lib/ice_nine/freezer/array.rb
|
85
76
|
- lib/ice_nine/freezer/false_class.rb
|
86
77
|
- lib/ice_nine/freezer/hash.rb
|
87
78
|
- lib/ice_nine/freezer/hash/state.rb
|
@@ -101,9 +92,10 @@ files:
|
|
101
92
|
- spec/rcov.opts
|
102
93
|
- spec/spec.opts
|
103
94
|
- spec/spec_helper.rb
|
95
|
+
- spec/support/config_alias.rb
|
104
96
|
- spec/unit/ice_nine/class_methods/deep_freeze_spec.rb
|
97
|
+
- spec/unit/ice_nine/freezer/array/class_methods/deep_freeze_spec.rb
|
105
98
|
- spec/unit/ice_nine/freezer/class_methods/element_reference_spec.rb
|
106
|
-
- spec/unit/ice_nine/freezer/enumerable/class_methods/deep_freeze_spec.rb
|
107
99
|
- spec/unit/ice_nine/freezer/false_class/class_methods/deep_freeze_spec.rb
|
108
100
|
- spec/unit/ice_nine/freezer/hash/class_methods/deep_freeze_spec.rb
|
109
101
|
- spec/unit/ice_nine/freezer/nil_class/class_methods/deep_freeze_spec.rb
|
@@ -128,37 +120,27 @@ files:
|
|
128
120
|
- tasks/yard.rake
|
129
121
|
homepage: https://github.com/dkubb/ice_nine
|
130
122
|
licenses: []
|
131
|
-
|
132
123
|
post_install_message:
|
133
124
|
rdoc_options: []
|
134
|
-
|
135
|
-
require_paths:
|
125
|
+
require_paths:
|
136
126
|
- lib
|
137
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
128
|
none: false
|
139
|
-
requirements:
|
140
|
-
- -
|
141
|
-
- !ruby/object:Gem::Version
|
142
|
-
|
143
|
-
|
144
|
-
- 0
|
145
|
-
version: "0"
|
146
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ! '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
134
|
none: false
|
148
|
-
requirements:
|
149
|
-
- -
|
150
|
-
- !ruby/object:Gem::Version
|
151
|
-
|
152
|
-
segments:
|
153
|
-
- 0
|
154
|
-
version: "0"
|
135
|
+
requirements:
|
136
|
+
- - ! '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
155
139
|
requirements: []
|
156
|
-
|
157
140
|
rubyforge_project:
|
158
|
-
rubygems_version: 1.8.
|
141
|
+
rubygems_version: 1.8.24
|
159
142
|
signing_key:
|
160
143
|
specification_version: 3
|
161
144
|
summary: Deep Freeze Ruby Objects
|
162
145
|
test_files: []
|
163
|
-
|
164
146
|
has_rdoc:
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module IceNine
|
4
|
-
class Freezer
|
5
|
-
|
6
|
-
# A freezer class for handling Enumerable objects
|
7
|
-
class Enumerable < Object
|
8
|
-
|
9
|
-
# Deep Freeze an Enumerable
|
10
|
-
#
|
11
|
-
# @example
|
12
|
-
# enumerable = IceNine:Freezer::Enumerable.deep_freeze(%w[a b c])
|
13
|
-
# enumerable.select(&:frozen?) # => ['a', 'b', 'c']
|
14
|
-
#
|
15
|
-
# @param [Enumerable] enumerable
|
16
|
-
#
|
17
|
-
# @return [Enumerable]
|
18
|
-
#
|
19
|
-
# @todo use super on #each when Struct#each returns self in Rubinius
|
20
|
-
#
|
21
|
-
# @api public
|
22
|
-
def self.deep_freeze(enumerable)
|
23
|
-
enumerable.each { |entry| IceNine.deep_freeze(entry) }
|
24
|
-
super enumerable
|
25
|
-
end
|
26
|
-
|
27
|
-
end # class Enumerable
|
28
|
-
end # class Freezer
|
29
|
-
end # module IceNine
|