epitools 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.5
1
+ 0.4.6
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{epitools}
8
- s.version = "0.4.5"
8
+ s.version = "0.4.6"
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-01-20}
12
+ s.date = %q{2011-01-30}
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 = [
@@ -1,4 +1,18 @@
1
- __DIR__ = File.dirname(__FILE__)
1
+ class Object
2
+
3
+ unless defined?(__DIR__)
4
+ #
5
+ # This method is convenience for the `File.expand_path(File.dirname(__FILE__))` idiom.
6
+ # (taken from Michael Fellinger's Ramaze... thanx, dood! :D)
7
+ #
8
+ def __DIR__(*args)
9
+ filename = caller[0][/^(.*):/, 1]
10
+ dir = File.expand_path(File.dirname(filename))
11
+ ::File.expand_path(::File.join(dir, *args.map{|a| a.to_s}))
12
+ end
13
+ end
14
+
15
+ end
2
16
 
3
17
  require_wrapper = proc do |mod|
4
18
  begin
@@ -354,18 +354,6 @@ end
354
354
 
355
355
  class Object
356
356
 
357
- unless defined?(__DIR__)
358
- #
359
- # This method is convenience for the `File.expand_path(File.dirname(__FILE__))` idiom.
360
- # (taken from Michael Fellinger's Ramaze... thanx, dood! :D)
361
- #
362
- def __DIR__(*args)
363
- filename = caller[0][/^(.*):/, 1]
364
- dir = File.expand_path(File.dirname(filename))
365
- ::File.expand_path(::File.join(dir, *args.map{|a| a.to_s}))
366
- end
367
- end
368
-
369
357
  #
370
358
  # Instead of:
371
359
  # if cookie_jar.include? cookie
@@ -35,7 +35,6 @@ class CacheDB
35
35
  url = page.uri.to_s
36
36
 
37
37
  p [:page_uri, url]
38
- p [:original_url, url]
39
38
 
40
39
  if url != original_url
41
40
  # redirect original_url to url
@@ -49,7 +48,7 @@ class CacheDB
49
48
  )
50
49
  end
51
50
 
52
- compressed_body = page.body #Zlib::Deflate.deflate(page.body)
51
+ compressed_body = Zlib::Deflate.deflate(page.body)
53
52
  expire(url) if options[:overwrite]
54
53
  db.execute(
55
54
  "INSERT INTO cache VALUES ( ?, ?, ?, ? )",
@@ -72,7 +71,7 @@ class CacheDB
72
71
  if redirect
73
72
  get(redirect)
74
73
  else
75
- body = compressed_body #Zlib::Inflate.inflate(compressed_body)
74
+ body = Zlib::Inflate.inflate(compressed_body)
76
75
 
77
76
  Mechanize::Page.new(
78
77
  URI.parse(url),
@@ -151,10 +150,6 @@ class CacheDB
151
150
  create_tables
152
151
  end
153
152
 
154
- def delete!
155
- File.unlink @filename
156
- end
157
-
158
153
  private
159
154
 
160
155
  def list_tables
@@ -1,71 +1,14 @@
1
1
  require 'epitools/browser'
2
2
 
3
- #describe Browser do
4
- #
5
- # before :all do
6
- # @browser = Browser.new
7
- # end
8
- #
9
- # after :all do
10
- # @browser.cache.delete!
11
- # end
12
- #
13
- # it "googles" do
14
- # page = @browser.get("http://google.com")
15
- # page.body["Feeling Lucky"].should_not be_empty
16
- # end
17
- #
18
- #end
19
-
20
- class Mechanize::Page
21
- def url
22
- uri.to_s
23
- end
24
- end
25
-
26
- describe CacheDB do
3
+ describe Browser do
27
4
 
28
5
  before :all do
29
- @agent = Mechanize.new
30
- CacheDB.new(@agent).delete!
31
- @cache = CacheDB.new(@agent)
32
- end
33
-
34
- def new_page(body, url)
35
- Mechanize::Page.new(
36
- URI.parse(url),
37
- {'content-type'=>'text/html'},
38
- body,
39
- nil,
40
- @agent
41
- )
42
- end
43
-
44
- after :all do
45
- #@cache.delete!
6
+ @browser = Browser.new
46
7
  end
47
-
48
- it "writes and reads" do
49
- body = "Blah blah blah."
50
- url = "http://example.com/url.html"
51
-
52
- page = new_page(body, url)
53
-
54
- page.body.should == body
55
- page.url.should == url
56
-
57
- @cache.put page, url
58
-
59
- p @cache.urls
60
-
61
- @cache.includes?(url).should == true
62
-
63
- result = @cache.get url
64
-
65
- body.should == page.body
66
- body.should == result.body
67
- url.should == page.url
68
- url.should == result.url
8
+
9
+ it "googles" do
10
+ page = @browser.get("http://google.com")
11
+ page.body["Feeling Lucky"].should_not be_empty
69
12
  end
70
13
 
71
14
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epitools
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 3
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 4
8
- - 5
9
- version: 0.4.5
9
+ - 6
10
+ version: 0.4.6
10
11
  platform: ruby
11
12
  authors:
12
13
  - epitron
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-01-20 00:00:00 -05:00
18
+ date: 2011-01-30 00:00:00 -05:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -25,6 +26,7 @@ dependencies:
25
26
  requirements:
26
27
  - - ~>
27
28
  - !ruby/object:Gem::Version
29
+ hash: 7
28
30
  segments:
29
31
  - 2
30
32
  - 2
@@ -40,6 +42,7 @@ dependencies:
40
42
  requirements:
41
43
  - - ~>
42
44
  - !ruby/object:Gem::Version
45
+ hash: 23
43
46
  segments:
44
47
  - 1
45
48
  - 0
@@ -55,6 +58,7 @@ dependencies:
55
58
  requirements:
56
59
  - - ">="
57
60
  - !ruby/object:Gem::Version
61
+ hash: 3
58
62
  segments:
59
63
  - 0
60
64
  version: "0"
@@ -125,6 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
129
  requirements:
126
130
  - - ">="
127
131
  - !ruby/object:Gem::Version
132
+ hash: 3
128
133
  segments:
129
134
  - 0
130
135
  version: "0"
@@ -133,6 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
138
  requirements:
134
139
  - - ">="
135
140
  - !ruby/object:Gem::Version
141
+ hash: 3
136
142
  segments:
137
143
  - 0
138
144
  version: "0"