http_mini 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -0
  3. data/README.md +5 -2
  4. data/lib/http_mini.rb +7 -2
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 166acd0db0024022ec7e07c1de9c80541df9b499
4
- data.tar.gz: 876d20b39d257334c356b19196efa1b15417ecb7
3
+ metadata.gz: f93b2064b5592e3a408d787a8d798c743887657f
4
+ data.tar.gz: 2d60a389747a0cb5d16fddeda6a5b5fed41cb075
5
5
  SHA512:
6
- metadata.gz: 4dc9413dcbdb34d68a6b22a8949cb7596b3f5bae1a311facc2808bcc5a28028bfcef317fe834ca1a3981b0dcc1870c79ede099d177515c420b7bb4a8dc0ef845
7
- data.tar.gz: 7d90442a228947c494491a61775cc8d96e33b6d7a1ee09e130d77ee192ba2a9c8e688e45a5b4b4bf1a144b1cc41acfed15079bca5b894f3136d2e78bef3192cb
6
+ metadata.gz: a7d73bca6a2f198863beb89323b1208c531a1fd3e3292f83898f6cd3d9ade94bc3fd1352e82e09232118a85504105a6b7dbddfe84867964240509aa7a48c2841
7
+ data.tar.gz: 26362c645b4a158fdac79fb53cad10caf260def72cde89d9500589cf7f01154a5b729f95b28d222fa77120a337d5837a5dd06196633674ca6bdfcafc55baddad
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  ## vNEXT
2
2
 
3
+ ## v3.0.1
4
+ * Basic auth
5
+
3
6
  ## v3.0.0
4
7
  * Performance improvements
5
8
  * Refactoring. As part of the refactoring, there is now only one option for timeout used for both open and read
data/README.md CHANGED
@@ -34,6 +34,9 @@ a one liner to ping or get the response from a web server.
34
34
  # Set http headers
35
35
  puts HttpMini.new('http://www.google.com', headers: {'user-agent' => 'Fancy UserAgent Name'}).head.code
36
36
 
37
+ # Basic auth
38
+ puts HttpMini.new('http://foo:bar@www.acme.com').head.code
39
+
37
40
  ## HTTP verbs Support
38
41
 
39
42
  * HEAD
@@ -46,8 +49,8 @@ a one liner to ping or get the response from a web server.
46
49
  ## Request options
47
50
 
48
51
  * `:headers` - http headers, defaults to {}
49
- * `:open_timeout` - number of seconds to wait for the connection to open, defaults to 2
50
- * `:read_timeout` - number of seconds to wait for one block to be read, defaults to 2
52
+ * `:timeout` - number of seconds to wait for the connection to open, number of seconds to wait for one block to be read
53
+ * `:ignore_error` - ignore errors on poke, defaults to `true`
51
54
 
52
55
  ## Author
53
56
 
data/lib/http_mini.rb CHANGED
@@ -8,7 +8,7 @@ class HttpMini
8
8
  IGNORE_ERROR = true
9
9
 
10
10
  def self.VERSION
11
- '0.3.0'
11
+ '0.3.1'
12
12
  end
13
13
 
14
14
  def initialize(uri, opts = {})
@@ -77,7 +77,7 @@ class HttpMini
77
77
  end
78
78
 
79
79
  def request(req, data=nil)
80
- http.start { |http| http.request(req, data) }
80
+ http.start { |http| http.request(auth(req), data) }
81
81
  end
82
82
 
83
83
  def http
@@ -87,6 +87,11 @@ class HttpMini
87
87
  http
88
88
  end
89
89
 
90
+ def auth(req)
91
+ req.basic_auth(@uri.user, @uri.password) if @uri.user
92
+ req
93
+ end
94
+
90
95
  def headers
91
96
  opts[:headers] || {}
92
97
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_mini
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jerome Touffe-Blin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-09 00:00:00.000000000 Z
11
+ date: 2013-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra