gorillib 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/gorillib.gemspec +5 -2
- data/lib/gorillib/numeric/clamp.rb +8 -0
- data/spec/blank_spec.rb +1 -1
- data/spec/numeric_spec.rb +48 -0
- metadata +5 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/gorillib.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{gorillib}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Infochimps"]
|
12
|
-
s.date = %q{2011-04-
|
12
|
+
s.date = %q{2011-04-24}
|
13
13
|
s.description = %q{Gorillib: infochimps lightweight subset of ruby convenience methods}
|
14
14
|
s.email = %q{coders@infochimps.org}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -46,6 +46,7 @@ Gem::Specification.new do |s|
|
|
46
46
|
"lib/gorillib/metaprogramming/mattr_accessor.rb",
|
47
47
|
"lib/gorillib/metaprogramming/remove_method.rb",
|
48
48
|
"lib/gorillib/metaprogramming/singleton_class.rb",
|
49
|
+
"lib/gorillib/numeric/clamp.rb",
|
49
50
|
"lib/gorillib/object/blank.rb",
|
50
51
|
"lib/gorillib/some.rb",
|
51
52
|
"lib/gorillib/string/constantize.rb",
|
@@ -54,6 +55,7 @@ Gem::Specification.new do |s|
|
|
54
55
|
"lib/gorillib/string/truncate.rb",
|
55
56
|
"spec/blank_spec.rb",
|
56
57
|
"spec/gorillib_spec.rb",
|
58
|
+
"spec/numeric_spec.rb",
|
57
59
|
"spec/rcov.opts",
|
58
60
|
"spec/spec.opts",
|
59
61
|
"spec/spec_helper.rb",
|
@@ -92,6 +94,7 @@ Gem::Specification.new do |s|
|
|
92
94
|
s.test_files = [
|
93
95
|
"spec/blank_spec.rb",
|
94
96
|
"spec/gorillib_spec.rb",
|
97
|
+
"spec/numeric_spec.rb",
|
95
98
|
"spec/spec_helper.rb",
|
96
99
|
"test/abstract_unit.rb",
|
97
100
|
"test/array/compact_blank_test.rb",
|
data/spec/blank_spec.rb
CHANGED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'gorillib/numeric/clamp'
|
3
|
+
|
4
|
+
describe Numeric do
|
5
|
+
describe 'clamp' do
|
6
|
+
it 'should return self if neither min nor max are given' do
|
7
|
+
5.clamp().should == 5
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should return min if x < min' do
|
11
|
+
5.clamp(6).should == 6
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should return self if x >= min' do
|
15
|
+
5.clamp(4).should == 5
|
16
|
+
5.clamp(5).should == 5
|
17
|
+
5.clamp(nil).should == 5
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should return max if x > max' do
|
21
|
+
5.clamp(nil, 4).should == 4
|
22
|
+
5.clamp(4, 4).should == 4
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should return self if x <= max' do
|
26
|
+
5.clamp(4, 6).should == 5
|
27
|
+
5.clamp(5, 5).should == 5
|
28
|
+
5.clamp(nil, 6).should == 5
|
29
|
+
5.clamp(nil, 5).should == 5
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'lets me mix floats and ints' do
|
33
|
+
(5.0).clamp(4, 6).should == 5.0
|
34
|
+
(5).clamp(4.0, 6.0).should == 5.0
|
35
|
+
(5.0).clamp(6.0, 7.0).should == 6.0
|
36
|
+
(5.0).clamp(4, 6).should be_a_kind_of(Float)
|
37
|
+
(5.0).clamp(6, 6).should be_a_kind_of(Integer)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should raise if min > max' do
|
41
|
+
lambda{ 5.clamp(6, 3) }.should raise_error(ArgumentError)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'lets me set min == max' do
|
45
|
+
5.clamp(6, 6).should == 6
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: gorillib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Infochimps
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-24 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- lib/gorillib/metaprogramming/mattr_accessor.rb
|
86
86
|
- lib/gorillib/metaprogramming/remove_method.rb
|
87
87
|
- lib/gorillib/metaprogramming/singleton_class.rb
|
88
|
+
- lib/gorillib/numeric/clamp.rb
|
88
89
|
- lib/gorillib/object/blank.rb
|
89
90
|
- lib/gorillib/some.rb
|
90
91
|
- lib/gorillib/string/constantize.rb
|
@@ -93,6 +94,7 @@ files:
|
|
93
94
|
- lib/gorillib/string/truncate.rb
|
94
95
|
- spec/blank_spec.rb
|
95
96
|
- spec/gorillib_spec.rb
|
97
|
+
- spec/numeric_spec.rb
|
96
98
|
- spec/rcov.opts
|
97
99
|
- spec/spec.opts
|
98
100
|
- spec/spec_helper.rb
|
@@ -153,6 +155,7 @@ summary: include only what you need. No dependencies, no creep
|
|
153
155
|
test_files:
|
154
156
|
- spec/blank_spec.rb
|
155
157
|
- spec/gorillib_spec.rb
|
158
|
+
- spec/numeric_spec.rb
|
156
159
|
- spec/spec_helper.rb
|
157
160
|
- test/abstract_unit.rb
|
158
161
|
- test/array/compact_blank_test.rb
|