http_mini 0.2.1 → 0.2.2

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 +31 -0
  3. data/README.md +3 -0
  4. data/lib/http_mini.rb +13 -4
  5. metadata +47 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 90ceb32fe48dec7cebf54cb0e76b07ec5255b6d6
4
- data.tar.gz: 36ba9760d330deee3f5cac63abbbe338162549bb
3
+ metadata.gz: 0619d2e911794c66aace9401b1b720b7023ea4f0
4
+ data.tar.gz: 57cd6f3882b48473a42477d9f62f009a466e1183
5
5
  SHA512:
6
- metadata.gz: e41a1399b41b597cf94a78444e07dcf027aeed572d629dff422494263333ad10cae721a1d71a65c1041d7fc435488d6936cb2d983cb3f6694e4ad8cd13f705a0
7
- data.tar.gz: d60a4da8832c48e0da143972500bf4c0e5c2d674137552c0d8ce6f14ad6186b8f1256892cea0c2a31aa326031447473d7c915afc910b6d6c221a95e29988f5f0
6
+ metadata.gz: 9d1d1229de8c2fc8b743c193aea9f3fd7b7e3e793829d18021c711d772d56c12b6b273852a7ef4a0dc8237c631a94ef5397275c0458215da4ff1619ef5c8217a
7
+ data.tar.gz: 3c5960d0b9f089b701a62ccf52ad252b674790fd5f78f27b4d673208884d85da4a52947679ad1e8426b6720657d2560a437a329e27ee72e160b0495c4e9eddbd
data/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ ## vNEXT
2
+
3
+ ## v0.2.1
4
+ * Add license to `gemspec`
5
+
6
+ ## v0.2.0
7
+ * Breaking change: ignore errors on `poke` only
8
+ * Allow chaining of `uri` and `path` methods to allow changing the target and chaining an HTTP request
9
+ * Add support for query string parameters
10
+
11
+ ## v0.1.1
12
+ * Improve handling of url without scheme
13
+ * Add support for `https` requests
14
+ * Add `poke` (alias `ping`) method that returns true or false if 200 <= status < 400 of HEAD request
15
+
16
+ ## v0.1.0
17
+ * Initial commit and push to Github
18
+ * Code refactoring
19
+
20
+ ## v0.0.1
21
+
22
+ * Initial gem publishing
23
+ * Basic support for following HTTP verbs
24
+ * HEAD
25
+ * GET
26
+ * POST
27
+ * UPDATE
28
+ * DELETE
29
+ * OPTIONS
30
+
31
+
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Http mini
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/http_mini.png)](http://badge.fury.io/rb/http_mini)
4
+ [![Build Status](https://travis-ci.org/jtblin/http_mini.png)](https://travis-ci.org/jtblin/http_mini)
5
+ [![Coverage Status](https://coveralls.io/repos/jtblin/http_mini/badge.png?branch=master)](https://coveralls.io/r/jtblin/http_mini?branch=master)
6
+ [![Code Climate](https://codeclimate.com/github/jtblin/http_mini.png)](https://codeclimate.com/github/jtblin/http_mini)
4
7
 
5
8
  A truly minimalist Http client for Ruby. When all you want is
6
9
  a one liner to ping or get the response from a web server.
data/lib/http_mini.rb CHANGED
@@ -10,7 +10,7 @@ class HttpMini
10
10
  IGNORE_ERROR = true
11
11
 
12
12
  def self.VERSION
13
- '0.2.1'
13
+ '0.2.2'
14
14
  end
15
15
 
16
16
  def initialize(url, opts = {})
@@ -53,7 +53,7 @@ class HttpMini
53
53
  alias_method :ping, :poke
54
54
 
55
55
  def uri(uri=nil)
56
- uri.nil? ? @uri : (self.uri = uri) and self
56
+ uri.nil? ? @uri : ((self.uri = uri) and self)
57
57
  end
58
58
 
59
59
  def host
@@ -71,7 +71,11 @@ class HttpMini
71
71
  private
72
72
 
73
73
  def uri=(uri)
74
- @uri = URI.parse(uri) unless uri.nil? || uri.empty?
74
+ @uri = URI.parse(handle_missing_scheme(uri)) unless uri.nil? || uri.empty?
75
+ end
76
+
77
+ def handle_missing_scheme(uri)
78
+ uri.match(/https?:\/\//) ? uri : "http://#{uri}"
75
79
  end
76
80
 
77
81
  def request
@@ -103,10 +107,15 @@ class HttpMini
103
107
  end
104
108
 
105
109
  def set_path(path)
106
- @uri.path = path
110
+ @uri.path = path.match(/\?/) ? handle_query(path) : path
107
111
  self
108
112
  end
109
113
 
114
+ def handle_query(path)
115
+ uri.query = path.gsub /.*\?/, ''
116
+ path.gsub /\?.*/, ''
117
+ end
118
+
110
119
  def timeouts
111
120
  [open_timeout, read_timeout]
112
121
  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.2.1
4
+ version: 0.2.2
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-08-04 00:00:00.000000000 Z
11
+ date: 2013-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -24,17 +24,61 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.3.0
27
- description: A thin wrapper over URI and Http::Net
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: webmock
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: A truly minimalist Http Ruby client
28
70
  email: jtblin@gmail.com
29
71
  executables: []
30
72
  extensions: []
31
73
  extra_rdoc_files:
32
74
  - LICENSE
33
75
  - README.md
76
+ - CHANGELOG.md
34
77
  files:
35
78
  - lib/http_mini.rb
36
79
  - LICENSE
37
80
  - README.md
81
+ - CHANGELOG.md
38
82
  homepage: https://github.com/jtblin/http_mini
39
83
  licenses:
40
84
  - BSD