eat 0.0.1 → 0.0.2

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.
Files changed (4) hide show
  1. data/README.rdoc +1 -1
  2. data/lib/eat.rb +4 -3
  3. data/lib/eat/version.rb +1 -1
  4. metadata +4 -4
@@ -15,7 +15,7 @@ Try
15
15
  ==Supported schemas
16
16
 
17
17
  * local filesystem (it will try to use <tt>sudo</tt> if it can't read the file)
18
- * http (the default timeout is 5 seconds)
18
+ * http (the timeout is 2 seconds)
19
19
  * https (it won't check the SSL certificate... if you want security, don't use this!)
20
20
 
21
21
  Copyright 2011 Seamus Abshere
data/lib/eat.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  require 'uri'
2
2
 
3
3
  module Eat
4
- def eat(filesystem_path_or_uri, remote_timeout = 5)
4
+ TIMEOUT = 2 # seconds
5
+ def eat(filesystem_path_or_uri)
5
6
  uri = ::URI.parse filesystem_path_or_uri
6
7
  case uri.scheme
7
8
  when nil
@@ -13,14 +14,14 @@ module Eat
13
14
  when 'http', 'https'
14
15
  require 'net/http'
15
16
  require 'net/https' if uri.scheme == 'https'
16
- (defined?(::SystemTimer) ? ::SystemTimer : ::Timeout).timeout(remote_timeout) do
17
+ (defined?(::SystemTimer) ? ::SystemTimer : ::Timeout).timeout(::Eat::TIMEOUT) do
17
18
  http = ::Net::HTTP.new uri.host, uri.port
18
19
  if uri.scheme == 'https'
19
20
  http.use_ssl = true
20
21
  # if you were trying to be real safe, you wouldn't use this library
21
22
  http.verify_mode = ::OpenSSL::SSL::VERIFY_NONE
22
23
  end
23
- http.request ::Net::HTTP::Get.new(uri.request_uri)
24
+ http.start { |session| session.get uri.request_uri }
24
25
  end.body
25
26
  end
26
27
  end
@@ -1,3 +1,3 @@
1
1
  module Eat
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eat
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Seamus Abshere
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-11 00:00:00 -06:00
18
+ date: 2011-01-12 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency