net-http-local 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -1,36 +1,44 @@
1
1
  Net::HTTP::Local
2
2
  ================
3
3
 
4
- Net::HTTP::Local allows TCPSocket to bind a Net::HTTP request to a specified
5
- local address and port.
6
-
7
- If you are craving cURL's `interface` option, this is what you need.
4
+ Net::HTTP::Local binds a Net::HTTP request to a specified local address and
5
+ port.
8
6
 
9
7
  Installation
10
8
  ------------
11
9
 
12
10
  ```sh
13
- gem install net-http-local'
11
+ gem install net-http-local
14
12
  ```
15
13
 
16
14
  Usage
17
15
  -----
18
16
 
17
+ A contrived example:
18
+
19
19
  ```ruby
20
+ require 'json'
20
21
  require 'net/http'
22
+ require 'uri'
23
+
21
24
  require 'net/http/local'
22
25
 
26
+ ip = -> do
27
+ uri = URI.parse 'http://jsonip.com'
28
+ res = Net::HTTP.get_response uri
29
+ JSON.parse(res.body)['ip']
30
+ end
31
+
32
+ # The default IP address.
33
+ p ip.call => # 10.1.1.2
34
+
23
35
  # Bind to 10.1.1.3 in a block.
24
36
  Net::HTTP.bind '10.1.1.3' do
25
- res = Net::HTTP.get_response uri
26
- p JSON.parse(res.body)['ip'] # => 10.1.1.3
37
+ p ip.call # => 10.1.1.3
27
38
  end
28
39
 
29
40
  # Bind and unbind without a block.
30
41
  Net::HTTP.bind '10.1.1.3'
31
-
32
- res = Net::HTTP.get_response(uri)
33
- p JSON.parse(res.body)['ip'] # => 10.1.1.3
34
-
42
+ p ip.call # => 10.1.1.3
35
43
  Net::HTTP.unbind
36
44
  ```
@@ -1,7 +1,5 @@
1
- # Net::HTTP::Local allows TCPSocket to bind a Net::HTTP request to a specified
2
- # local address and port.
3
- #
4
- # If you are craving cURL's `interface` option, this is what you need.
1
+ # Net::HTTP::Local binds a Net::HTTP request to a specified local address and
2
+ # port.
5
3
  module Net::HTTP::Local
6
4
  # Binds to a local IP address.
7
5
  #
@@ -1,3 +1,3 @@
1
1
  module Net::HTTP::Local
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -11,8 +11,8 @@ Gem::Specification.new do |s|
11
11
  s.email = ['hakan.ensari@papercavalier.com']
12
12
  s.homepage = 'http://github.com/hakanensari/net-http-local'
13
13
  s.summary = %q{ Binds Net::HTTP requests to a local address and port }
14
- s.description = %q{ Net::HTTP::Local allows TCPSocket to bind Net::HTTP
15
- requests to a local address and port. }
14
+ s.description = %q{ Net::HTTP::Local binds Net::HTTP requests to a local
15
+ address and port. }
16
16
 
17
17
  s.files = `git ls-files`.split("\n")
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-http-local
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,8 +11,8 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2012-04-13 00:00:00.000000000 Z
13
13
  dependencies: []
14
- description: ! " Net::HTTP::Local allows TCPSocket to bind Net::HTTP\n requests
15
- to a local address and port. "
14
+ description: ! " Net::HTTP::Local binds Net::HTTP requests to a local\n address
15
+ and port. "
16
16
  email:
17
17
  - hakan.ensari@papercavalier.com
18
18
  executables: []