duct_tape 0.0.4 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +13 -2
- data/Gemfile.lock +68 -18
- data/LICENSE +1 -1
- data/README.md +17 -0
- data/REQUIRED_FILES +6 -0
- data/Rakefile +111 -4
- data/VERSION +1 -1
- data/duct_tape.gemspec +19 -14
- data/ext/mkrf_conf.rb +18 -4
- data/lib/duct_tape.rb +84 -1
- data/lib/ext/kernel.rb +65 -34
- data/lib/ext/pathname.rb +51 -9
- data/lib/ext/time.rb +10 -1
- data/lib/ext/uri.rb +6 -1
- data/spec/duct_tape/autoassociative_array_spec.rb +6 -6
- data/spec/ext/array_spec.rb +63 -63
- data/spec/ext/boolean_spec.rb +2 -2
- data/spec/ext/numeric_spec.rb +13 -13
- data/spec/ext/pathname_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -0
- metadata +54 -10
- data/git_hooks/env_vars.sh +0 -287
- data/git_hooks/post-commit +0 -43
- data/git_hooks/post-merge +0 -8
- data/git_hooks/pre-commit +0 -273
- data/install_git_hooks +0 -17
data/lib/ext/pathname.rb
CHANGED
@@ -7,7 +7,7 @@ class Pathname
|
|
7
7
|
def self.which(cmd)
|
8
8
|
paths = ENV['PATH'].split(File::PATH_SEPARATOR).uniq
|
9
9
|
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
10
|
-
names =
|
10
|
+
names = form_name_list(cmd, {:extensions => exts})
|
11
11
|
return do_search(paths, *names) { |f| f.executable? }
|
12
12
|
end
|
13
13
|
|
@@ -17,17 +17,25 @@ class Pathname
|
|
17
17
|
'/usr/local/lib',
|
18
18
|
'/usr/local/libdata',
|
19
19
|
'/opt/local/lib',
|
20
|
+
'/usr/lib/x86_64-linux-gnu',
|
20
21
|
'/usr/lib64',
|
21
22
|
'/usr/lib',
|
22
23
|
'/usr/X11/lib',
|
23
24
|
'/usr/share',
|
24
|
-
]
|
25
|
-
|
25
|
+
]
|
26
|
+
prefixes = [
|
27
|
+
"lib"
|
28
|
+
]
|
29
|
+
extensions = [
|
30
|
+
"",
|
31
|
+
".so"
|
32
|
+
]
|
26
33
|
|
27
34
|
if detect_os[:platform] == "windows"
|
28
|
-
|
29
|
-
|
30
|
-
"
|
35
|
+
extensions = [
|
36
|
+
"",
|
37
|
+
".dll",
|
38
|
+
".dll.a"
|
31
39
|
]
|
32
40
|
paths = [
|
33
41
|
calling_method_dirname,
|
@@ -37,9 +45,14 @@ class Pathname
|
|
37
45
|
ENV["SystemRoot"],
|
38
46
|
].compact.uniq
|
39
47
|
paths |= ENV['PATH'].split(File::PATH_SEPARATOR).uniq
|
48
|
+
elsif detect_os[:platform] == "darwin"
|
49
|
+
extensions << ".dylib"
|
40
50
|
end
|
51
|
+
names = form_name_list(lib, {:prefixes => prefixes, :extensions => extensions})
|
41
52
|
|
42
|
-
return do_search(paths, *names)
|
53
|
+
return do_search(paths, *names) do |f|
|
54
|
+
f.readable? && f.file? && extensions.any? { |ext| f =~ %r{#{Regexp.escape(ext)}\z} }
|
55
|
+
end
|
43
56
|
end
|
44
57
|
|
45
58
|
def self.header(hdr)
|
@@ -50,7 +63,13 @@ class Pathname
|
|
50
63
|
RbConfig::CONFIG["includedir"],
|
51
64
|
RbConfig::CONFIG["oldincludedir"],
|
52
65
|
].compact.uniq
|
53
|
-
|
66
|
+
extensions = [
|
67
|
+
".h",
|
68
|
+
".hh",
|
69
|
+
".hxx",
|
70
|
+
".hpp"
|
71
|
+
]
|
72
|
+
names = form_name_list(hdr, {:extensions => extensions})
|
54
73
|
return do_search(paths, *names) { |f| f.readable? && f.file? }
|
55
74
|
end
|
56
75
|
|
@@ -100,15 +119,38 @@ class Pathname
|
|
100
119
|
|
101
120
|
private
|
102
121
|
|
122
|
+
def self.form_name_list(name, opts={})
|
123
|
+
exts = opts[:exts] || opts[:extensions] || []
|
124
|
+
pfxs = opts[:pfxs] || opts[:prefixes] || []
|
125
|
+
exts.delete("")
|
126
|
+
pfxs.delete("")
|
127
|
+
exts.unshift("")
|
128
|
+
pfxs.unshift("")
|
129
|
+
|
130
|
+
ret = []
|
131
|
+
(pfxs * exts).each { |pfx,ext| ret << [pfx, name, ext].join("") }
|
132
|
+
ret
|
133
|
+
end
|
134
|
+
|
103
135
|
def self.do_search(paths, *try_names, &block)
|
104
136
|
try_names.flatten!
|
105
137
|
paths.each do |path|
|
106
138
|
pn = Pathname.new(path)
|
107
|
-
|
139
|
+
# Handle globs
|
140
|
+
globbed = try_names.map do |name|
|
141
|
+
if name["*"]
|
142
|
+
Dir.glob(pn + name)
|
143
|
+
else
|
144
|
+
name
|
145
|
+
end
|
146
|
+
end
|
147
|
+
globbed.flatten!
|
148
|
+
globbed.each do |name|
|
108
149
|
file = pn + name
|
109
150
|
return file if yield(file)
|
110
151
|
end
|
111
152
|
end
|
112
153
|
nil
|
113
154
|
end
|
155
|
+
private_class_method :do_search
|
114
156
|
end
|
data/lib/ext/time.rb
CHANGED
@@ -5,16 +5,25 @@ class Time
|
|
5
5
|
mins = secs / 60
|
6
6
|
hours = mins / 60
|
7
7
|
days = hours / 24
|
8
|
+
weeks = days / 7
|
9
|
+
months = days / 30
|
10
|
+
years = days / 365
|
8
11
|
|
9
12
|
secs = num if usecs
|
10
13
|
|
14
|
+
year_str = (years == 1 ? "year" : "years")
|
15
|
+
month_str = (months == 1 ? "month" : "months")
|
16
|
+
week_str = (weeks == 1 ? "week" : "weeks")
|
11
17
|
day_str = (days == 1 ? "day" : "days")
|
12
18
|
hour_str = (hours % 24 == 1 ? "hour" : "hours")
|
13
19
|
min_str = (mins % 60 == 1 ? "minute" : "minutes")
|
14
20
|
sec_str = (secs % 60 == 1 ? "second" : "seconds")
|
15
21
|
|
16
22
|
str_ary = []
|
17
|
-
str_ary << "#{
|
23
|
+
str_ary << "#{years} #{year_str}" if years > 0
|
24
|
+
str_ary << "#{months % 12} #{month_str}" if months > 0
|
25
|
+
str_ary << "#{weeks % 4} #{week_str}" if weeks > 0
|
26
|
+
str_ary << "#{days % 7} #{day_str}" if days > 0
|
18
27
|
str_ary << "#{hours % 24} #{hour_str}" if hours > 0
|
19
28
|
str_ary << "#{mins % 60} #{min_str}" if mins > 0
|
20
29
|
str_ary << "#{secs % 60} #{sec_str}" if secs > 0
|
data/lib/ext/uri.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'pathname'
|
2
|
-
require 'uri'
|
3
2
|
|
4
3
|
class URI::Generic
|
5
4
|
def relative_path?
|
@@ -13,4 +12,10 @@ class URI::Generic
|
|
13
12
|
def relative_scheme?
|
14
13
|
scheme.nil? && (!host.nil? || !path.empty?)
|
15
14
|
end
|
15
|
+
|
16
|
+
def origin
|
17
|
+
ret = (scheme ? "#{scheme}://" : "//")
|
18
|
+
ret += hostname
|
19
|
+
ret += (port && port != default_port ? ":#{port}" : "")
|
20
|
+
end
|
16
21
|
end
|
@@ -38,22 +38,22 @@ describe Containers::AutoassociativeArray, "#partial_match" do
|
|
38
38
|
it "returns the matches with the most query matches" do
|
39
39
|
aa = Containers::AutoassociativeArray.new
|
40
40
|
aa << [1,2,3] << [2,3,4] << [3,4,5]
|
41
|
-
aa.partial_match(1,4,5).
|
41
|
+
expect(aa.partial_match(1,4,5)).to eq([3,4,5])
|
42
42
|
end
|
43
43
|
|
44
44
|
it "returns all of the matches with the most query matches" do
|
45
45
|
aa = Containers::AutoassociativeArray.new
|
46
46
|
aa << [1,2,3] << [2,3,4] << [3,4,5]
|
47
|
-
aa.partial_match(1,5).
|
48
|
-
aa.partial_match(1,3,5).
|
49
|
-
aa.partial_match(2,4).
|
47
|
+
expect(aa.partial_match(1,5)).to eq([[1,2,3], [3,4,5]])
|
48
|
+
expect(aa.partial_match(1,3,5)).to eq([[1,2,3], [3,4,5]])
|
49
|
+
expect(aa.partial_match(2,4)).to eq([2,3,4])
|
50
50
|
end
|
51
51
|
|
52
52
|
it "returns the matches with the most query matches with the most matches" do
|
53
53
|
aa = Containers::AutoassociativeArray.new
|
54
54
|
aa << [1,2,3] << [2,3,4] << [3,4,5]
|
55
|
-
aa.partial_match(1,4).
|
56
|
-
aa.partial_match(2,5).
|
55
|
+
expect(aa.partial_match(1,4)).to eq([[2,3,4], [3,4,5]])
|
56
|
+
expect(aa.partial_match(2,5)).to eq([[1,2,3], [2,3,4]])
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
data/spec/ext/array_spec.rb
CHANGED
@@ -7,21 +7,21 @@ describe Array, "#deep_merge" do
|
|
7
7
|
it "remains unchanged" do
|
8
8
|
ary = [1,2,3,4,5]
|
9
9
|
ary.deep_merge([6,7,8])
|
10
|
-
ary.
|
10
|
+
expect(ary).to eq([1,2,3,4,5])
|
11
11
|
end
|
12
12
|
|
13
13
|
it "merges flat arrays properly" do
|
14
14
|
ary = [1,2,3,4,5]
|
15
15
|
val = ary.deep_merge([4,5,6])
|
16
|
-
val.
|
17
|
-
(val.__id__ == ary.__id__).
|
16
|
+
expect(val).to eq([1,2,3,4,5,6])
|
17
|
+
expect((val.__id__ == ary.__id__)).to be_false
|
18
18
|
end
|
19
19
|
|
20
20
|
it "merges nested arrays properly" do
|
21
21
|
ary = [1,2,[3,4,5]]
|
22
22
|
val = ary.deep_merge([3,4,[5,6,7]])
|
23
|
-
val.
|
24
|
-
(val.__id__ == ary.__id__).
|
23
|
+
expect(val).to eq([1,2,[3,4,5,6,7],3,4])
|
24
|
+
expect((val.__id__ == ary.__id__)).to be_false
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -32,33 +32,33 @@ describe Array, "#deep_merge!" do
|
|
32
32
|
it "changes" do
|
33
33
|
ary = [1,2,3,4,5]
|
34
34
|
val = ary.deep_merge!([6,7,8])
|
35
|
-
ary.
|
36
|
-
(val.__id__ == ary.__id__).
|
35
|
+
expect(ary).to eq([1,2,3,4,5,6,7,8])
|
36
|
+
expect((val.__id__ == ary.__id__)).to be_true
|
37
37
|
end
|
38
38
|
|
39
39
|
it "returns nil if nothing was changed" do
|
40
40
|
ary = [1,2,3,4,5]
|
41
41
|
val = ary.deep_merge!([4,5])
|
42
|
-
val.
|
42
|
+
expect(val).to be_nil
|
43
43
|
end
|
44
44
|
|
45
45
|
it "returns self if it changed" do
|
46
46
|
ary = [1,2,3,4,5]
|
47
47
|
val = ary.deep_merge!([4,5,6])
|
48
|
-
val.
|
49
|
-
(val.__id__ == ary.__id__).
|
48
|
+
expect(val).to eq([1,2,3,4,5,6])
|
49
|
+
expect((val.__id__ == ary.__id__)).to be_true
|
50
50
|
end
|
51
51
|
|
52
52
|
it "merges flat arrays properly" do
|
53
53
|
ary = [1,2,3,4,5]
|
54
54
|
ary.deep_merge!([4,5,6])
|
55
|
-
ary.
|
55
|
+
expect(ary).to eq([1,2,3,4,5,6])
|
56
56
|
end
|
57
57
|
|
58
58
|
it "merges nested arrays properly" do
|
59
59
|
ary = [1,2,[3,4,5]]
|
60
60
|
ary.deep_merge!([3,4,[5,6,7]])
|
61
|
-
ary.
|
61
|
+
expect(ary).to eq([1,2,[3,4,5,6,7],3,4])
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -69,34 +69,34 @@ describe Array, "#*" do
|
|
69
69
|
it "remains unchanged" do
|
70
70
|
ary = [1,2,3]
|
71
71
|
val1 = ary * 2; val2 = ary * ","; val3 = ary * ary
|
72
|
-
ary.
|
73
|
-
(val1.__id__ == ary.__id__).
|
74
|
-
(val2.__id__ == ary.__id__).
|
75
|
-
(val3.__id__ == ary.__id__).
|
72
|
+
expect(ary).to eq([1,2,3])
|
73
|
+
expect((val1.__id__ == ary.__id__)).to be_false
|
74
|
+
expect((val2.__id__ == ary.__id__)).to be_false
|
75
|
+
expect((val3.__id__ == ary.__id__)).to be_false
|
76
76
|
end
|
77
77
|
|
78
78
|
it "concats correctly" do
|
79
79
|
ary = [1,2,3]
|
80
80
|
|
81
|
-
(ary * 0).
|
82
|
-
(ary * 1).
|
83
|
-
(ary * 2).
|
81
|
+
expect((ary * 0)).to eq([])
|
82
|
+
expect((ary * 1)).to eq([1,2,3])
|
83
|
+
expect((ary * 2)).to eq([1,2,3,1,2,3])
|
84
84
|
end
|
85
85
|
|
86
86
|
it "joins correctly" do
|
87
87
|
ary = [1,2,3]
|
88
88
|
|
89
|
-
(ary * "").
|
90
|
-
(ary * ",").
|
89
|
+
expect((ary * "")).to eq("123")
|
90
|
+
expect((ary * ",")).to eq("1,2,3")
|
91
91
|
end
|
92
92
|
|
93
93
|
it "cross-multiplies correctly" do
|
94
94
|
ary = [0,1]
|
95
95
|
|
96
|
-
(ary * []).
|
97
|
-
(ary * [0]).
|
98
|
-
(ary * ary).
|
99
|
-
(ary * [0,1,2]).
|
96
|
+
expect((ary * [])).to eq([])
|
97
|
+
expect((ary * [0])).to eq([[0,0],[1,0]])
|
98
|
+
expect((ary * ary)).to eq([[0,0],[0,1],[1,0],[1,1]])
|
99
|
+
expect((ary * [0,1,2])).to eq([[0,0],[0,1],[0,2],[1,0],[1,1],[1,2]])
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
@@ -107,17 +107,17 @@ describe Array, "#**" do
|
|
107
107
|
it "remains unchanged" do
|
108
108
|
ary = [0,1]
|
109
109
|
val = ary ** 2
|
110
|
-
ary.
|
111
|
-
(val.__id__ == ary.__id__).
|
110
|
+
expect(ary).to eq([0,1])
|
111
|
+
expect((val.__id__ == ary.__id__)).to be_false
|
112
112
|
end
|
113
113
|
|
114
114
|
it "multiplies correctly" do
|
115
115
|
ary = [0,1]
|
116
|
-
(ary ** -1).
|
117
|
-
(ary ** 0).
|
118
|
-
(ary ** 1).
|
119
|
-
(ary ** 2).
|
120
|
-
(ary ** 3).
|
116
|
+
expect((ary ** -1)).to eq([])
|
117
|
+
expect((ary ** 0)).to eq([])
|
118
|
+
expect((ary ** 1)).to eq([[0],[1]])
|
119
|
+
expect((ary ** 2)).to eq([[0,0],[0,1],[1,0],[1,1]])
|
120
|
+
expect((ary ** 3)).to eq([[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]])
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
@@ -128,14 +128,14 @@ describe Array, "#uniq_by" do
|
|
128
128
|
it "remains unchanged" do
|
129
129
|
ary = [0,0]
|
130
130
|
val = ary.uniq_by { |i| i }
|
131
|
-
ary.
|
132
|
-
(val.__id__ == ary.__id__).
|
131
|
+
expect(ary).to eq([0,0])
|
132
|
+
expect((val.__id__ == ary.__id__)).to be_false
|
133
133
|
end
|
134
134
|
|
135
135
|
it "filters by the return value of the block" do
|
136
136
|
ary = [0,1]
|
137
137
|
val = ary.uniq_by { |i| true }
|
138
|
-
val.
|
138
|
+
expect(val).to eq([0])
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
@@ -146,28 +146,28 @@ describe Array, "#unanimous?" do
|
|
146
146
|
it "remains unchanged" do
|
147
147
|
ary = [0,0]
|
148
148
|
val = ary.unanimous?
|
149
|
-
ary.
|
150
|
-
(val.__id__ == ary.__id__).
|
149
|
+
expect(ary).to eq([0,0])
|
150
|
+
expect((val.__id__ == ary.__id__)).to be_false
|
151
151
|
end
|
152
152
|
|
153
153
|
it "returns true and false with no argument and no block" do
|
154
|
-
[0,0].unanimous
|
155
|
-
[0,1].unanimous
|
154
|
+
expect([0,0].unanimous?).to be_true
|
155
|
+
expect([0,1].unanimous?).to be_false
|
156
156
|
end
|
157
157
|
|
158
158
|
it "returns true and false with an argument and no block" do
|
159
|
-
[0,0].unanimous?(0).
|
160
|
-
[0,0].unanimous?(1).
|
159
|
+
expect([0,0].unanimous?(0)).to be_true
|
160
|
+
expect([0,0].unanimous?(1)).to be_false
|
161
161
|
end
|
162
162
|
|
163
163
|
it "returns true and false with no argument and with a block" do
|
164
|
-
[0,0].unanimous? { |i| i == 1 }.
|
165
|
-
[0,1].unanimous? { |i| i == 1 }.
|
164
|
+
expect([0,0].unanimous? { |i| i == 1 }).to be_true
|
165
|
+
expect([0,1].unanimous? { |i| i == 1 }).to be_false
|
166
166
|
end
|
167
167
|
|
168
168
|
it "returns true and false with an argument and a block" do
|
169
|
-
[0,0].unanimous?(false) { |i| i.odd? }.
|
170
|
-
[0,0].unanimous?(true) { |i| i.odd? }.
|
169
|
+
expect([0,0].unanimous?(false) { |i| i.odd? }).to be_true
|
170
|
+
expect([0,0].unanimous?(true) { |i| i.odd? }).to be_false
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
@@ -178,51 +178,51 @@ describe Array, "#to_h" do
|
|
178
178
|
it "remains unchanged" do
|
179
179
|
ary = [0,0]
|
180
180
|
val = ary.to_h
|
181
|
-
ary.
|
182
|
-
(val.__id__ == ary.__id__).
|
181
|
+
expect(ary).to eq([0,0])
|
182
|
+
expect((val.__id__ == ary.__id__)).to be_false
|
183
183
|
end
|
184
184
|
|
185
185
|
it "converts flat arrays" do
|
186
|
-
%w{a b c}.to_h.
|
187
|
-
%w{a b}.to_h.
|
188
|
-
['a'].to_h.
|
189
|
-
[].to_h.
|
186
|
+
expect(%w{a b c}.to_h).to eq({0=>"a", 1=>"b", 2=>"c"})
|
187
|
+
expect(%w{a b}.to_h).to eq({0=>"a", 1=>"b"})
|
188
|
+
expect(['a'].to_h).to eq({0=>"a"})
|
189
|
+
expect([].to_h).to eq({})
|
190
190
|
end
|
191
191
|
|
192
192
|
it "converts an array of pairs" do
|
193
|
-
[[1,2], [3,4]].to_h.
|
194
|
-
[[1,2]].to_h.
|
193
|
+
expect([[1,2], [3,4]].to_h).to eq({1=>2, 3=>4})
|
194
|
+
expect([[1,2]].to_h).to eq({1=>2})
|
195
195
|
end
|
196
196
|
|
197
197
|
it "converts an array of hashes (without conflicts)" do
|
198
|
-
[{1=>2}, {3=>4}].to_h.
|
199
|
-
[{1=>2}].to_h.
|
198
|
+
expect([{1=>2}, {3=>4}].to_h).to eq({1=>2, 3=>4})
|
199
|
+
expect([{1=>2}].to_h).to eq({1=>2})
|
200
200
|
end
|
201
201
|
|
202
202
|
it "converts an array of hashes (with conflicts)" do
|
203
|
-
[{1=>2}, {3=>4, 1=>5}].to_h.
|
204
|
-
[{1=>2}].to_h.
|
203
|
+
expect([{1=>2}, {3=>4, 1=>5}].to_h).to eq({1=>[2,5], 3=>4})
|
204
|
+
expect([{1=>2}].to_h).to eq({1=>2})
|
205
205
|
end
|
206
206
|
|
207
207
|
it "converts an array of hashes with common name and value keys" do
|
208
208
|
ary = [{"name" => 1, "value" => 2}, {"name" => 3, "value" => 4}]
|
209
|
-
ary.to_h.
|
209
|
+
expect(ary.to_h).to eq({1=>2, 3=>4})
|
210
210
|
|
211
211
|
ary = [{:name => 1, :value => 2}, {:name => 3, :value => 4}]
|
212
|
-
ary.to_h.
|
212
|
+
expect(ary.to_h).to eq({1=>2, 3=>4})
|
213
213
|
|
214
214
|
ary = [{:x => 1, :y => 2}, {:x => 3, :y => 4}]
|
215
|
-
ary.to_h(:x, :y).
|
215
|
+
expect(ary.to_h(:x, :y)).to eq({1=>2, 3=>4})
|
216
216
|
|
217
217
|
ary = [{:x => 1, :y => 2}, {:x => 3, :y => 4}]
|
218
|
-
ary.to_h("x", "y").
|
218
|
+
expect(ary.to_h("x", "y")).to eq({1=>2, 3=>4})
|
219
219
|
end
|
220
220
|
|
221
221
|
it "converts a hash-turned-array back to the original hash" do
|
222
222
|
hsh = {1=>{2=>3}}
|
223
223
|
val = hsh.to_a.to_h
|
224
|
-
hsh.
|
225
|
-
(val.__id__ == hsh.__id__).
|
224
|
+
expect(hsh).to eq(val)
|
225
|
+
expect((val.__id__ == hsh.__id__)).to be_false
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
data/spec/ext/boolean_spec.rb
CHANGED
@@ -5,7 +5,7 @@ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
|
|
5
5
|
#
|
6
6
|
describe TrueClass, "#is_a? Boolean" do
|
7
7
|
it "is a Boolean" do
|
8
|
-
true.
|
8
|
+
expect(true).to be_a_kind_of Boolean
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
@@ -14,6 +14,6 @@ end
|
|
14
14
|
#
|
15
15
|
describe FalseClass, "#is_a? Boolean" do
|
16
16
|
it "is a Boolean" do
|
17
|
-
false.
|
17
|
+
expect(false).to be_a_kind_of Boolean
|
18
18
|
end
|
19
19
|
end
|
data/spec/ext/numeric_spec.rb
CHANGED
@@ -5,22 +5,22 @@ require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
|
|
5
5
|
#
|
6
6
|
describe Numeric, "units" do
|
7
7
|
it "chronological sizes" do
|
8
|
-
3.years.
|
9
|
-
3.weeks.
|
10
|
-
3.days.
|
11
|
-
3.hours.
|
12
|
-
3.minutes.
|
13
|
-
3.mseconds.
|
14
|
-
3.useconds.
|
8
|
+
expect(3.years).to eq(3*365*24*60*60)
|
9
|
+
expect(3.weeks).to eq(3*7*24*60*60)
|
10
|
+
expect(3.days).to eq(3*24*60*60)
|
11
|
+
expect(3.hours).to eq(3*60*60)
|
12
|
+
expect(3.minutes).to eq(3*60)
|
13
|
+
expect(3.mseconds).to eq(3 / 1000.0)
|
14
|
+
expect(3.useconds).to eq(3 / 1000000.0)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "byte sizes" do
|
18
|
-
3.eb.
|
19
|
-
3.pb.
|
20
|
-
3.tb.
|
21
|
-
3.gb.
|
22
|
-
3.mb.
|
23
|
-
3.kb.
|
18
|
+
expect(3.eb).to eq(3*(2**60))
|
19
|
+
expect(3.pb).to eq(3*(2**50))
|
20
|
+
expect(3.tb).to eq(3*(2**40))
|
21
|
+
expect(3.gb).to eq(3*(2**30))
|
22
|
+
expect(3.mb).to eq(3*(2**20))
|
23
|
+
expect(3.kb).to eq(3*(2**10))
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
data/spec/ext/pathname_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: duct_tape
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,10 +9,26 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-06-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: facets
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.9.3
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.9.3
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: backports
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
17
33
|
none: false
|
18
34
|
requirements:
|
@@ -28,14 +44,14 @@ dependencies:
|
|
28
44
|
- !ruby/object:Gem::Version
|
29
45
|
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
47
|
+
name: bundler
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
33
49
|
none: false
|
34
50
|
requirements:
|
35
51
|
- - ! '>='
|
36
52
|
- !ruby/object:Gem::Version
|
37
53
|
version: '0'
|
38
|
-
type: :
|
54
|
+
type: :runtime
|
39
55
|
prerelease: false
|
40
56
|
version_requirements: !ruby/object:Gem::Requirement
|
41
57
|
none: false
|
@@ -91,6 +107,38 @@ dependencies:
|
|
91
107
|
- - ! '>='
|
92
108
|
- !ruby/object:Gem::Version
|
93
109
|
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rake
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: simplecov
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
94
142
|
description: A general-purpose utility library for Ruby
|
95
143
|
email:
|
96
144
|
- tw.rodriguez@gmail.com
|
@@ -105,15 +153,11 @@ files:
|
|
105
153
|
- Gemfile.lock
|
106
154
|
- LICENSE
|
107
155
|
- README.md
|
156
|
+
- REQUIRED_FILES
|
108
157
|
- Rakefile
|
109
158
|
- VERSION
|
110
159
|
- duct_tape.gemspec
|
111
160
|
- ext/mkrf_conf.rb
|
112
|
-
- git_hooks/env_vars.sh
|
113
|
-
- git_hooks/post-commit
|
114
|
-
- git_hooks/post-merge
|
115
|
-
- git_hooks/pre-commit
|
116
|
-
- install_git_hooks
|
117
161
|
- lib/algorithms/containers.rb
|
118
162
|
- lib/algorithms/containers/heap.rb
|
119
163
|
- lib/algorithms/containers/priority_queue.rb
|
@@ -176,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
220
|
version: '0'
|
177
221
|
requirements: []
|
178
222
|
rubyforge_project:
|
179
|
-
rubygems_version: 1.8.
|
223
|
+
rubygems_version: 1.8.23.2
|
180
224
|
signing_key:
|
181
225
|
specification_version: 3
|
182
226
|
summary: A bunch of useful patches for core Ruby classes
|