hknife 0.1.2 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 802eece8a4e4495b3c5a611bcb35ceafd71dfa77
4
- data.tar.gz: 21ba7733da42413d7846819aec2b5ba858186c5c
3
+ metadata.gz: 29d450b378bd2791d5003e06fcdcda0219b2d5b3
4
+ data.tar.gz: 3094b06d0e024408da83ff37783b8533e0376b6b
5
5
  SHA512:
6
- metadata.gz: 94709900b637db4b4d04d6562465d4ee1b9927fa6c75b3c92817e9b9439a7a9d83e52eb0ac689fe01f9366619b7423a39be2f8712b9889e92b0f7bac9390a248
7
- data.tar.gz: aeb37ae7272d906beec3760b8a8d878dff760742d2008fd3f45cb3417a277575e909e90d5a2a89917ff41bd4c74eea9caf36ce25ed35ced785da0b863ea4a3f8
6
+ metadata.gz: bcfe4915df10c4d4874482619334998afd1892f80409baf015f151dc1caca147f1e11ef6795c96b8c931d79815a89d40e497a4f26d074d6991968796d5077cfc
7
+ data.tar.gz: a666db208f5a8d7a2697c0ffc179f2de8ee897d6d8e270806be20a10415094b1cf5ae28f9aac86965db2e2f378a8507cb853df20b5b8e197fed8cf8b036220d1
data/.travis.yml CHANGED
@@ -3,3 +3,11 @@ language: ruby
3
3
  rvm:
4
4
  - 2.2.5
5
5
  before_install: gem install bundler -v 1.12.2
6
+ deploy:
7
+ provider: rubygems
8
+ api_key:
9
+ secure: sS8zt7wkkRVC4teTUW7l3A0N2vWG7qQVNpYV8ExTNCwHsGCoUgOIsjpLiJDRGM0KNmpfBNDFK4YnYVeJNfJT0FOWiBScVC0JllHYRD9A1YdHwtN4vAKUB7bL+pYEy6LmNX9AiJnNH9j9y6eE5kwtfu0lNQkFoky5oBf3J5njPl21gD0qou7I4E3+Mp3h93zDHu71ghk/EO8BDpY6ZSEUFW8RG90Jgwo14fVKA/BVDMq3L8plGEnunovAka9sNoQ5Rf9sZbI2hqFt+ytbBjoqOVBLGti3L4iJvES6+ZIiH31Q6j9puL74zSx8H2f2RvxlZaHFT74GgzjAIL7eW4GgnKmhT0TK+3oYQVnQPXD5Cg6Ub8xF+YWatjtMwhlFIhPSCzETFWNk40/ngPL7fQD7rK7ZbB6xFxyqc2tkuPsg4vOePKAiaPt7iRsNw87ThOm+IkcXIQAm+IPp9o20x/SozD2MKNfm4NIpm4xRAihr2QPgEn7e4rbxu7jncMaOtz9U/d5g20orpWl1bt9FMv9OG0Tjw1DKioUPqAWLuUKKSN9rPS5IogQaFXHSptTCnJeeQX12izjhC9D/AVxxnXKieXdESS4mYheNGGWByc/lO/cD8wZcMGL64gY0DyTUV7bg0nhPVM26Oi1asoTxPko6dFHEBx97xkkrxrzaW/Qa+Uk=
10
+ gem: hknife
11
+ on:
12
+ tags: true
13
+ repo: nyamage/hknife
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in hknife.gemspec
4
4
  gemspec
5
+
6
+ group :test do
7
+ gem 'rake'
8
+ end
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # hknife
2
2
 
3
+ [![Build Status](https://travis-ci.org/nyamage/hknife.svg?branch=master)](https://travis-ci.org/nyamage/hknife)
4
+
3
5
  It's a client http library and inspired by sinatra.
4
6
  Focus on simpler and understand easily what request will be send from the code.
5
- Notice it's super alpha quality and stability of interface.
6
-
7
+ Notice it's super alpha quality.
8
+
7
9
  # How to use
8
10
 
9
11
  ## Sending get request
@@ -12,6 +14,8 @@ Notice it's super alpha quality and stability of interface.
12
14
  get('http://www.example.com').send
13
15
  ```
14
16
 
17
+ Request is not sent until calling send or response method.
18
+
15
19
  ## Sending get request and post request with reponse of previous get request
16
20
 
17
21
  ```ruby
@@ -19,7 +23,7 @@ res = get('http://www.example.com').response
19
23
  post_form('http://www.example.com/', id: res.body['id]).response
20
24
  ```
21
25
 
22
- ## Sending get request with customer header
26
+ ## Sending get request with specified header
23
27
 
24
28
  ```ruby
25
29
  get('http://93.184.216.34/').
@@ -51,8 +55,8 @@ post_form(reqs.response(0).body['uri'],
51
55
  "uri" => reqs.response(2).body['key1'] })
52
56
  ```
53
57
 
54
- ## Check response code
58
+ ## Get http response code
55
59
 
56
60
  ```ruby
57
61
  get('http://www.example.com').response.code
58
- ```
62
+ ```
data/lib/hknife.rb CHANGED
@@ -33,6 +33,22 @@ module Hknife
33
33
  self
34
34
  end
35
35
 
36
+ def delete(uri)
37
+ uriObj = URI.parse(uri)
38
+ @http_client = Net::HTTP.new(uriObj.host, uriObj.port)
39
+ @http_client.use_ssl = uriObj.scheme == 'https'
40
+ @request = Net::HTTP::Delete.new(uriObj.path)
41
+ @requestor = lambda do |request|
42
+ res = @http_client.request(request)
43
+ case res['Content-Type']
44
+ when /application\/json/ then
45
+ res.body = JSON.parse(res.body)
46
+ end
47
+ res
48
+ end
49
+ self
50
+ end
51
+
36
52
  def put(uri, data)
37
53
  uriObj = URI.parse(uri)
38
54
  @http_client = Net::HTTP.new(uriObj.host, uriObj.port)
@@ -108,6 +124,13 @@ module Hknife
108
124
  self
109
125
  end
110
126
 
127
+ def delete(uri)
128
+ req = Request.new()
129
+ req.delete(uri)
130
+ @queue << req
131
+ self
132
+ end
133
+
111
134
  def post_form(uri, data)
112
135
  req = Request.new()
113
136
  req.post_form(uri, data)
@@ -171,6 +194,17 @@ module Hknife
171
194
  obj
172
195
  end
173
196
 
197
+ def delete(uri)
198
+ obj = RequestQueue.new
199
+ obj.delete(uri)
200
+
201
+ if block_given?
202
+ yield obj.request, obj.response
203
+ end
204
+
205
+ obj
206
+ end
207
+
174
208
  def post_form(uri, data)
175
209
  obj = RequestQueue.new
176
210
  obj.post_form(uri, data)
@@ -216,7 +250,7 @@ module Hknife
216
250
  end
217
251
  end
218
252
 
219
- delegate :get, :post_form, :request, :header, :parallel, :put
253
+ delegate :get, :post_form, :request, :header, :parallel, :put, :delete
220
254
 
221
255
  class << self
222
256
  attr_accessor :target
@@ -1,3 +1,3 @@
1
1
  module Hknife
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hknife
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - nyamage
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-12 00:00:00.000000000 Z
11
+ date: 2017-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 2.4.5.1
109
+ rubygems_version: 2.4.8
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: hknife