epitools 0.4.44 → 0.4.45
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/epitools.gemspec +2 -2
- data/lib/epitools/basetypes.rb +5 -7
- data/lib/epitools/browser/cache.rb +1 -1
- data/lib/epitools/numwords.rb +18 -19
- data/lib/epitools/sys.rb +6 -1
- data/spec/numwords_spec.rb +4 -0
- metadata +40 -46
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.45
|
data/epitools.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{epitools}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.45"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["epitron"]
|
12
|
-
s.date = %q{2011-06-
|
12
|
+
s.date = %q{2011-06-23}
|
13
13
|
s.description = %q{Miscellaneous utility libraries to make my life easier.}
|
14
14
|
s.email = %q{chris@ill-logic.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/epitools/basetypes.rb
CHANGED
@@ -385,8 +385,7 @@ module Enumerable
|
|
385
385
|
alias_method :all, :to_a
|
386
386
|
|
387
387
|
#
|
388
|
-
# Split this enumerable into an array of
|
389
|
-
# boundary condition.
|
388
|
+
# Split this enumerable into chunks, given some boundary condition. (Returns an array of arrays.)
|
390
389
|
#
|
391
390
|
# Options:
|
392
391
|
# :include_boundary => true #=> include the element that you're splitting at in the results
|
@@ -404,10 +403,9 @@ module Enumerable
|
|
404
403
|
# chapters = File.read("ebook.txt").split(/Chapter \d+/, :include_boundary=>true)
|
405
404
|
# #=> [ ["Chapter 1", ...], ["Chapter 2", ...], etc. ]
|
406
405
|
#
|
407
|
-
# TODO:
|
408
|
-
# - Ruby 1.9 returns Enumerators for everything now. Maybe do that?
|
409
|
-
#
|
410
406
|
def split_at(matcher=nil, options={}, &block)
|
407
|
+
# TODO: Ruby 1.9 returns Enumerators for everything now. Maybe use that?
|
408
|
+
|
411
409
|
return self unless self.any?
|
412
410
|
|
413
411
|
include_boundary = options[:include_boundary] || false
|
@@ -458,7 +456,7 @@ module Enumerable
|
|
458
456
|
end
|
459
457
|
|
460
458
|
#
|
461
|
-
# Split the array into chunks,
|
459
|
+
# Split the array into chunks, cutting between the matched element and the next element.
|
462
460
|
#
|
463
461
|
# Example:
|
464
462
|
# [1,2,3,4].split_after{|e| e == 3 } #=> [ [1,2,3], [4] ]
|
@@ -470,7 +468,7 @@ module Enumerable
|
|
470
468
|
end
|
471
469
|
|
472
470
|
#
|
473
|
-
# Split the array into chunks
|
471
|
+
# Split the array into chunks, cutting between the matched element and the previous element.
|
474
472
|
#
|
475
473
|
# Example:
|
476
474
|
# [1,2,3,4].split_before{|e| e == 3 } #=> [ [1,2], [3,4] ]
|
@@ -87,7 +87,7 @@ class Browser
|
|
87
87
|
#body = compressed_body
|
88
88
|
body = Zlib::Inflate.inflate(compressed_body)
|
89
89
|
|
90
|
-
if content_type =~
|
90
|
+
if content_type =~ %r{^(text/html|text/xml|application/xhtml\+xml)}i
|
91
91
|
Mechanize::Page.new(
|
92
92
|
#initialize(uri=nil, response=nil, body=nil, code=nil, mech=nil)
|
93
93
|
URI.parse(url),
|
data/lib/epitools/numwords.rb
CHANGED
@@ -57,51 +57,50 @@ class Numeric
|
|
57
57
|
|
58
58
|
tens, hunds = nil, nil
|
59
59
|
|
60
|
-
|
60
|
+
digits = triplet.chars.to_a
|
61
61
|
|
62
|
-
raise "Error: Not a triplet: #{triplet}" if
|
62
|
+
raise "Error: Not a triplet: #{triplet}" if digits.size > 3 or digits.size < 1
|
63
63
|
|
64
|
-
if
|
65
|
-
|
66
|
-
hunds = NAMES_SMALL[
|
67
|
-
|
64
|
+
if digits.size == 3
|
65
|
+
digit = digits.shift.to_i
|
66
|
+
hunds = NAMES_SMALL[digit] + "-hundred" if digit > 0
|
67
|
+
digits.shift if digits.first == '0'
|
68
68
|
end
|
69
69
|
|
70
|
-
if
|
71
|
-
n =
|
70
|
+
if digits.size == 2
|
71
|
+
n = digits.join('').to_i
|
72
72
|
|
73
73
|
if n > 0 and n < 20
|
74
74
|
tens = NAMES_SMALL[n]
|
75
75
|
elsif n > 0
|
76
|
-
tens = NAMES_MEDIUM[
|
77
|
-
if
|
78
|
-
tens += "-" + NAMES_SMALL[
|
76
|
+
tens = NAMES_MEDIUM[digits.shift.to_i - 2]
|
77
|
+
if digits.first != '0'
|
78
|
+
tens += "-" + NAMES_SMALL[digits.shift.to_i]
|
79
79
|
else
|
80
|
-
|
80
|
+
digits.shift
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
-
if
|
86
|
-
n =
|
85
|
+
if digits.size == 1
|
86
|
+
n = digits.join('').to_i
|
87
87
|
tens = NAMES_SMALL[n] if n > 0
|
88
88
|
end
|
89
|
-
|
90
|
-
|
89
|
+
|
91
90
|
if hunds
|
92
91
|
if tens
|
93
92
|
result << "#{hunds} and #{tens}"
|
94
|
-
else
|
93
|
+
else
|
95
94
|
result << hunds
|
96
95
|
end
|
97
96
|
else
|
98
97
|
result << tens if tens
|
99
98
|
end
|
100
|
-
|
99
|
+
|
101
100
|
magnitude = (num_triplets - i)
|
102
101
|
result << NAMES_LARGE[magnitude-2] if magnitude > 1
|
103
102
|
|
104
|
-
whole_thing << result.join(' ')
|
103
|
+
whole_thing << result.join(' ') if result.any?
|
105
104
|
end
|
106
105
|
|
107
106
|
whole_thing.join ', '
|
data/lib/epitools/sys.rb
CHANGED
@@ -15,7 +15,12 @@ module Sys
|
|
15
15
|
return @os if @os
|
16
16
|
|
17
17
|
require 'rbconfig'
|
18
|
-
|
18
|
+
if defined? RbConfig
|
19
|
+
host_os = RbConfig::CONFIG['host_os']
|
20
|
+
else
|
21
|
+
host_os = Config::CONFIG['host_os']
|
22
|
+
end
|
23
|
+
|
19
24
|
case host_os
|
20
25
|
when /darwin/
|
21
26
|
@os = "Darwin"
|
data/spec/numwords_spec.rb
CHANGED
metadata
CHANGED
@@ -1,61 +1,58 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: epitools
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.45
|
4
5
|
prerelease:
|
5
|
-
version: 0.4.44
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- epitron
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
date: 2011-06-15 00:00:00 -04:00
|
12
|
+
date: 2011-06-23 00:00:00.000000000 -04:00
|
14
13
|
default_executable:
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
17
16
|
name: rspec
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: &85952530 !ruby/object:Gem::Requirement
|
20
18
|
none: false
|
21
|
-
requirements:
|
19
|
+
requirements:
|
22
20
|
- - ~>
|
23
|
-
- !ruby/object:Gem::Version
|
21
|
+
- !ruby/object:Gem::Version
|
24
22
|
version: 2.2.0
|
25
23
|
type: :development
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: mechanize
|
29
24
|
prerelease: false
|
30
|
-
|
25
|
+
version_requirements: *85952530
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: mechanize
|
28
|
+
requirement: &85952230 !ruby/object:Gem::Requirement
|
31
29
|
none: false
|
32
|
-
requirements:
|
30
|
+
requirements:
|
33
31
|
- - ~>
|
34
|
-
- !ruby/object:Gem::Version
|
32
|
+
- !ruby/object:Gem::Version
|
35
33
|
version: 1.0.0
|
36
34
|
type: :development
|
37
|
-
version_requirements: *id002
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: sqlite3-ruby
|
40
35
|
prerelease: false
|
41
|
-
|
36
|
+
version_requirements: *85952230
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: sqlite3-ruby
|
39
|
+
requirement: &85951950 !ruby/object:Gem::Requirement
|
42
40
|
none: false
|
43
|
-
requirements:
|
44
|
-
- -
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version:
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
47
45
|
type: :development
|
48
|
-
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *85951950
|
49
48
|
description: Miscellaneous utility libraries to make my life easier.
|
50
49
|
email: chris@ill-logic.com
|
51
50
|
executables: []
|
52
|
-
|
53
51
|
extensions: []
|
54
|
-
|
55
|
-
extra_rdoc_files:
|
52
|
+
extra_rdoc_files:
|
56
53
|
- LICENSE
|
57
54
|
- README.rdoc
|
58
|
-
files:
|
55
|
+
files:
|
59
56
|
- .document
|
60
57
|
- LICENSE
|
61
58
|
- README.rdoc
|
@@ -102,31 +99,28 @@ files:
|
|
102
99
|
- spec/zopen_spec.rb
|
103
100
|
has_rdoc: true
|
104
101
|
homepage: http://github.com/epitron/epitools
|
105
|
-
licenses:
|
102
|
+
licenses:
|
106
103
|
- WTFPL
|
107
104
|
post_install_message:
|
108
105
|
rdoc_options: []
|
109
|
-
|
110
|
-
require_paths:
|
106
|
+
require_paths:
|
111
107
|
- lib
|
112
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
109
|
none: false
|
114
|
-
requirements:
|
115
|
-
- -
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version:
|
118
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ! '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
115
|
none: false
|
120
|
-
requirements:
|
121
|
-
- -
|
122
|
-
- !ruby/object:Gem::Version
|
123
|
-
version:
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
124
120
|
requirements: []
|
125
|
-
|
126
121
|
rubyforge_project:
|
127
122
|
rubygems_version: 1.6.2
|
128
123
|
signing_key:
|
129
124
|
specification_version: 3
|
130
125
|
summary: NOT UTILS... METILS!
|
131
126
|
test_files: []
|
132
|
-
|