epitools 0.4.20 → 0.4.21

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.20
1
+ 0.4.21
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.20"
8
+ s.version = "0.4.21"
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-04-02}
12
+ s.date = %q{2011-04-05}
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 = [
@@ -63,7 +63,7 @@ Gem::Specification.new do |s|
63
63
  s.homepage = %q{http://github.com/epitron/epitools}
64
64
  s.licenses = ["WTFPL"]
65
65
  s.require_paths = ["lib"]
66
- s.rubygems_version = %q{1.3.7}
66
+ s.rubygems_version = %q{1.5.2}
67
67
  s.summary = %q{NOT UTILS... METILS!}
68
68
  s.test_files = [
69
69
  "spec/basetypes_spec.rb",
@@ -82,7 +82,6 @@ Gem::Specification.new do |s|
82
82
  ]
83
83
 
84
84
  if s.respond_to? :specification_version then
85
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
86
85
  s.specification_version = 3
87
86
 
88
87
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -194,6 +194,14 @@ class Browser
194
194
  page
195
195
  end
196
196
 
197
+
198
+ # Delegation
199
+ [:head, :post, :put].each do |meth|
200
+ define_method meth do |*args|
201
+ agent.send(meth, *args)
202
+ end
203
+ end
204
+
197
205
  private
198
206
 
199
207
  def load_cookies!
@@ -1,4 +1,5 @@
1
1
  require 'epitools/basetypes'
2
+ require 'bigdecimal'
2
3
 
3
4
  class Numeric
4
5
 
@@ -27,13 +28,13 @@ class Numeric
27
28
  num = self.to_i
28
29
  end
29
30
 
30
- if (n = to_s.size) > 102
31
+ if (n = num.to_s.size) > 102
31
32
  return "more than a googol! (#{n} digits)"
32
33
  end
33
34
 
34
35
  whole_thing = []
35
36
 
36
- triplets = commatize.split(',')
37
+ triplets = num.commatize.split(',')
37
38
  num_triplets = triplets.size
38
39
 
39
40
  triplets.each_with_index do |triplet, i|
@@ -97,12 +98,24 @@ class Numeric
97
98
  # eg: 10.million #=> 10_000_000
98
99
  #
99
100
  def method_missing(meth, &block)
101
+
100
102
  if magnitude = NAMES_LARGE.index(meth.to_s)
101
- pow = (magnitude+1) * 3
102
- self * 10**pow
103
+
104
+ pow = (magnitude+1) * 3
105
+ factor = 10**pow
106
+
107
+ if is_a?(Float)
108
+ (BigDecimal(to_s) * factor).to_i
109
+ else
110
+ self * factor
111
+ end
112
+
103
113
  else
114
+
104
115
  super
116
+
105
117
  end
118
+
106
119
  end
107
120
 
108
121
  end
@@ -2,7 +2,7 @@ require 'epitools/basetypes'
2
2
 
3
3
  class Array
4
4
 
5
- alias_method :"*_without_permutations", :*
5
+ alias_method :multiply_without_permutations, :*
6
6
 
7
7
  #
8
8
  # Overloaded * operator.
@@ -13,18 +13,17 @@ class Array
13
13
  # array * array = Cartesian product of the two arrays
14
14
  #
15
15
  def *(other)
16
- case other
17
- when Array
18
- # cross-product
19
- result = []
20
- (0...self.size).each do |a|
21
- (0...other.size).each do |b|
22
- result << [self[a], other[b]]
23
- end
16
+ if other.is_a? Array
17
+ # cross-product
18
+ result = []
19
+ (0...self.size).each do |a|
20
+ (0...other.size).each do |b|
21
+ result << [self[a], other[b]]
24
22
  end
25
- result
26
- else
27
- send(:"*_without_permutations", other)
23
+ end
24
+ result
25
+ else
26
+ send(:multiply_without_permutations, other)
28
27
  end
29
28
  end
30
29
 
data/spec/browser_spec.rb CHANGED
@@ -24,7 +24,13 @@ describe Browser do
24
24
  end
25
25
 
26
26
  it "googles (cached)" do
27
- @browser.get("http://google.com").body
27
+ lambda{ @browser.get("http://google.com").body }.should_not raise_error
28
+ end
29
+
30
+ it "delegates" do
31
+ lambda{ @browser.head("http://google.com").body }.should_not raise_error
32
+ @browser.respond_to?(:post).should == true
33
+ @browser.respond_to?(:put).should == true
28
34
  end
29
35
 
30
36
  end
@@ -16,6 +16,8 @@ describe Numeric do
16
16
  }.each do |num, result|
17
17
  num.to_words.should == result
18
18
  end
19
+
20
+ lambda{ 1.523.million.billion.to_words }.should_not raise_error
19
21
  end
20
22
 
21
23
  it "has .thousand, .million, etc." do
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epitools
3
3
  version: !ruby/object:Gem::Version
4
- hash: 39
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 4
9
- - 20
10
- version: 0.4.20
4
+ prerelease:
5
+ version: 0.4.21
11
6
  platform: ruby
12
7
  authors:
13
8
  - epitron
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-04-02 00:00:00 -04:00
13
+ date: 2011-04-05 00:00:00 -04:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
@@ -26,11 +21,6 @@ dependencies:
26
21
  requirements:
27
22
  - - ~>
28
23
  - !ruby/object:Gem::Version
29
- hash: 7
30
- segments:
31
- - 2
32
- - 2
33
- - 0
34
24
  version: 2.2.0
35
25
  type: :development
36
26
  version_requirements: *id001
@@ -42,11 +32,6 @@ dependencies:
42
32
  requirements:
43
33
  - - ~>
44
34
  - !ruby/object:Gem::Version
45
- hash: 23
46
- segments:
47
- - 1
48
- - 0
49
- - 0
50
35
  version: 1.0.0
51
36
  type: :development
52
37
  version_requirements: *id002
@@ -58,9 +43,6 @@ dependencies:
58
43
  requirements:
59
44
  - - ">="
60
45
  - !ruby/object:Gem::Version
61
- hash: 3
62
- segments:
63
- - 0
64
46
  version: "0"
65
47
  type: :development
66
48
  version_requirements: *id003
@@ -130,23 +112,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
112
  requirements:
131
113
  - - ">="
132
114
  - !ruby/object:Gem::Version
133
- hash: 3
134
- segments:
135
- - 0
136
115
  version: "0"
137
116
  required_rubygems_version: !ruby/object:Gem::Requirement
138
117
  none: false
139
118
  requirements:
140
119
  - - ">="
141
120
  - !ruby/object:Gem::Version
142
- hash: 3
143
- segments:
144
- - 0
145
121
  version: "0"
146
122
  requirements: []
147
123
 
148
124
  rubyforge_project:
149
- rubygems_version: 1.3.7
125
+ rubygems_version: 1.5.2
150
126
  signing_key:
151
127
  specification_version: 3
152
128
  summary: NOT UTILS... METILS!