epitools 0.5.47 → 0.5.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a98fd7c24dd401ff1974baf48d291586e47ae273
4
- data.tar.gz: 9c661a5ad222be4c1e475710dbcc9749fd2f6010
3
+ metadata.gz: 31aba8c82626b4753d5c0d7276e5254843b7a89d
4
+ data.tar.gz: 1d286ca44911af0d2488a0545b28efb5b2a70a51
5
5
  SHA512:
6
- metadata.gz: 1bbc440a1110966310df0e1c7aaff92a7ad0f2a81f6457cbcd5ea33e21dc17d1a3c1397ab7654ce45bdd610016d3e5ac315dd50991eb8b296900525683428a2e
7
- data.tar.gz: 74c660f6282adf139e78c219632956f52759e4b3e147d7331d581dc94fdfa18e739fe369e149be390d3b68b419057b8b5641b494dacc279972db66db2fe910fe
6
+ metadata.gz: 6944b8becb25834b10cff325645e7205b41ccf3101d5a2cde1bb7bc7802ecc72a6fe3a60bf918a157bdf1dbd4cbffaf7d52715e8bf3138b1ed9604337bfe4954
7
+ data.tar.gz: db4e5771f84dcb040d33a9b2d13b8df61cf987040a512739240e74a0985a8f073310d667a9888e49ced2e7bcebdcfd78f861feef33a4636ee86c34a0fcb41bd2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.47
1
+ 0.5.49
@@ -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
@@ -245,6 +245,13 @@ class Integer
245
245
  result.map{|digit| BASE62_DIGITS[digit]}.join ''
246
246
  end
247
247
 
248
+ #
249
+ # Am I a prime number?
250
+ #
251
+ def prime?
252
+ Prime.prime? self
253
+ end
254
+
248
255
  #
249
256
  # Returns the all the prime factors of a number.
250
257
  #
@@ -170,5 +170,9 @@ class Object
170
170
  puts "* Benchmarking #{n} iterations..."
171
171
  Benchmark.bmbm(&benchblock)
172
172
  end
173
-
173
+
174
+ def present?
175
+ true
176
+ end
177
+
174
178
  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
  #
@@ -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'
@@ -67,8 +67,8 @@ describe Object do
67
67
  end
68
68
 
69
69
  it "nots" do
70
- 10.even?.should == true
71
- 10.not.even?.should == false
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.47
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-02-02 00:00:00.000000000 Z
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: