epitools 0.5.47 → 0.5.49
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/epitools/autoloads.rb +2 -0
- data/lib/epitools/core_ext/misc.rb +19 -0
- data/lib/epitools/core_ext/numbers.rb +7 -0
- data/lib/epitools/core_ext/object.rb +5 -1
- data/lib/epitools/core_ext/string.rb +8 -0
- data/lib/epitools/minimal.rb +25 -1
- data/spec/core_ext_spec.rb +29 -3
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31aba8c82626b4753d5c0d7276e5254843b7a89d
|
4
|
+
data.tar.gz: 1d286ca44911af0d2488a0545b28efb5b2a70a51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6944b8becb25834b10cff325645e7205b41ccf3101d5a2cde1bb7bc7802ecc72a6fe3a60bf918a157bdf1dbd4cbffaf7d52715e8bf3138b1ed9604337bfe4954
|
7
|
+
data.tar.gz: db4e5771f84dcb040d33a9b2d13b8df61cf987040a512739240e74a0985a8f073310d667a9888e49ced2e7bcebdcfd78f861feef33a4636ee86c34a0fcb41bd2
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.49
|
data/lib/epitools/autoloads.rb
CHANGED
@@ -18,6 +18,7 @@ autoload :Find, 'find'
|
|
18
18
|
autoload :Benchmark, 'benchmark'
|
19
19
|
autoload :Tracer, 'tracer'
|
20
20
|
autoload :CSV, 'csv'
|
21
|
+
autoload :Shellwords, 'shellwords'
|
21
22
|
autoload :Matrix, 'epitools/core_ext/matrix'
|
22
23
|
|
23
24
|
module Digest
|
@@ -53,6 +54,7 @@ autoload :Sys, 'epitools/sys'
|
|
53
54
|
## Gems (common)
|
54
55
|
|
55
56
|
autoreq :Nokogiri, 'nokogiri'
|
57
|
+
autoreq :Mechanize, 'mechanize'
|
56
58
|
autoreq :ANSI, 'ansi'
|
57
59
|
autoreq :BSON, 'bson'
|
58
60
|
autoreq :JSON, 'json'
|
@@ -253,3 +253,22 @@ class DateTime
|
|
253
253
|
def to_i; to_time.to_i; end
|
254
254
|
def to_f; to_time.to_f; end
|
255
255
|
end
|
256
|
+
|
257
|
+
|
258
|
+
class NilClass
|
259
|
+
|
260
|
+
def present?
|
261
|
+
false
|
262
|
+
end
|
263
|
+
|
264
|
+
def blank?
|
265
|
+
true
|
266
|
+
end
|
267
|
+
|
268
|
+
end
|
269
|
+
|
270
|
+
class FalseClass
|
271
|
+
def present?
|
272
|
+
false
|
273
|
+
end
|
274
|
+
end
|
@@ -17,6 +17,14 @@ class String
|
|
17
17
|
strip.size == 0
|
18
18
|
end
|
19
19
|
|
20
|
+
#
|
21
|
+
# Is there anything in the string? (ignoring whitespace/newlines)
|
22
|
+
#
|
23
|
+
def any?
|
24
|
+
not blank?
|
25
|
+
end
|
26
|
+
alias_method :present?, :any?
|
27
|
+
|
20
28
|
#
|
21
29
|
# Does this string contain something that means roughly "true"?
|
22
30
|
#
|
data/lib/epitools/minimal.rb
CHANGED
@@ -168,6 +168,7 @@ class Object
|
|
168
168
|
|
169
169
|
end
|
170
170
|
|
171
|
+
|
171
172
|
#
|
172
173
|
# Patch 'Module#const_missing' to support 'autoreq' (which can autoload gems)
|
173
174
|
#
|
@@ -202,6 +203,30 @@ class Module
|
|
202
203
|
end
|
203
204
|
|
204
205
|
|
206
|
+
module Kernel
|
207
|
+
|
208
|
+
#
|
209
|
+
# Executes a command and returns its output. (Like the backtick operator,
|
210
|
+
# but doesn't require shell ecaping arguments.)
|
211
|
+
#
|
212
|
+
def run(*cmd)
|
213
|
+
result = IO.popen(cmd) { |io| io.read }
|
214
|
+
result.empty? ? nil : result
|
215
|
+
end
|
216
|
+
alias_method :backtick, :run
|
217
|
+
|
218
|
+
#
|
219
|
+
# Same as shell, but includes stderr in the result.
|
220
|
+
#
|
221
|
+
def run_with_stderr(*cmd)
|
222
|
+
result = IO.popen(cmd, err: [:child, :out]) { |io| io.read }
|
223
|
+
result.empty? ? nil : result
|
224
|
+
end
|
225
|
+
alias_method :backtick_with_stderr, :run_with_stderr
|
226
|
+
|
227
|
+
end
|
228
|
+
|
229
|
+
|
205
230
|
class String
|
206
231
|
|
207
232
|
#
|
@@ -221,7 +246,6 @@ def Path(arg)
|
|
221
246
|
Path[arg]
|
222
247
|
end
|
223
248
|
|
224
|
-
|
225
249
|
####################################################################
|
226
250
|
|
227
251
|
require 'epitools/autoloads'
|
data/spec/core_ext_spec.rb
CHANGED
@@ -67,8 +67,8 @@ describe Object do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it "nots" do
|
70
|
-
10.
|
71
|
-
10.not.
|
70
|
+
10.should be_even
|
71
|
+
10.not.should_not be_even
|
72
72
|
end
|
73
73
|
|
74
74
|
it "alias_class_methods" do
|
@@ -198,6 +198,14 @@ end
|
|
198
198
|
|
199
199
|
describe String do
|
200
200
|
|
201
|
+
it "anys?" do
|
202
|
+
"".should_not be_any
|
203
|
+
"\n".should_not be_any
|
204
|
+
"YAY".should be_any
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
|
201
209
|
it "rot13s" do
|
202
210
|
message = "Unbreakable Code"
|
203
211
|
message.rot13.should_not == message
|
@@ -293,7 +301,7 @@ describe String do
|
|
293
301
|
e.should be_an Enumerator
|
294
302
|
e.to_a.should == %w[he ll ot he re !]
|
295
303
|
end
|
296
|
-
|
304
|
+
|
297
305
|
end
|
298
306
|
|
299
307
|
|
@@ -352,6 +360,10 @@ describe Integer do
|
|
352
360
|
256.factors.should == [2,2,2,2,2,2,2,2]
|
353
361
|
end
|
354
362
|
|
363
|
+
it "primes numbers" do
|
364
|
+
[3,5,7,11,13,17,23,3628273133].all? { |n| n.should be_prime }
|
365
|
+
end
|
366
|
+
|
355
367
|
end
|
356
368
|
|
357
369
|
|
@@ -797,4 +809,18 @@ describe File do
|
|
797
809
|
f.reverse_each.to_a.should == ["everyone!\n", "there\n", "hi\n"]
|
798
810
|
end
|
799
811
|
|
812
|
+
end
|
813
|
+
|
814
|
+
|
815
|
+
describe "Anything" do
|
816
|
+
|
817
|
+
it "is present" do
|
818
|
+
{
|
819
|
+
true => ["hello", 1, 2, 3, []],
|
820
|
+
false => [nil, "", false]
|
821
|
+
}.each do |truth, vals|
|
822
|
+
vals.each { |val| val.present?.should == truth }
|
823
|
+
end
|
824
|
+
end
|
825
|
+
|
800
826
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: epitools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.49
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- epitron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description: Miscellaneous utility libraries to make my life easier.
|
@@ -33,9 +33,9 @@ extra_rdoc_files:
|
|
33
33
|
- README.rdoc
|
34
34
|
- TODO
|
35
35
|
files:
|
36
|
-
- .document
|
37
|
-
- .gemspec
|
38
|
-
- .gitignore
|
36
|
+
- ".document"
|
37
|
+
- ".gemspec"
|
38
|
+
- ".gitignore"
|
39
39
|
- Guardfile
|
40
40
|
- LICENSE
|
41
41
|
- README.rdoc
|
@@ -115,12 +115,12 @@ require_paths:
|
|
115
115
|
- lib
|
116
116
|
required_ruby_version: !ruby/object:Gem::Requirement
|
117
117
|
requirements:
|
118
|
-
- -
|
118
|
+
- - ">="
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: '0'
|
121
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
@@ -130,4 +130,3 @@ signing_key:
|
|
130
130
|
specification_version: 3
|
131
131
|
summary: Not utils... METILS!
|
132
132
|
test_files: []
|
133
|
-
has_rdoc:
|