dpr 0.1.3 → 0.1.4
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 +4 -4
- data/README.md +4 -4
- data/dpr.gemspec +5 -4
- data/lib/dpr.rb +8 -3
- data/lib/dpr/version.rb +1 -1
- metadata +22 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f1be6a1921d72eb860121d9416c7015c3ae06b6c
|
|
4
|
+
data.tar.gz: fbd0a3a9b7d5fbce6f2f187f7c7b5883082b46b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 06d8ac51d0d5eb30de9952f750f6997a61ab43c08492bc761300d937be3241e3f11e02891ac7078ba28f37667e92fc072e591ec51fa36934bf9e7b6412e5e6c0
|
|
7
|
+
data.tar.gz: fb5f9d4a6bb030ea2917237a8da08089a83f09bc5c9a7c804dcbbba1ea0bba1621093bb540c7d9c31abd56b4ee68a64e10099d1dcaaffe3c26e5e0910b9e3baa
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Dpr
|
|
2
2
|
|
|
3
|
-
Dpr is the simplest Ruby Http client. It lets you do HTTP directly on URL strings. If a string can respond to_i and return the integer value of the string or 0 if it is not a integer, then it only makes sense to make it respond to http methods also.
|
|
3
|
+
Dpr is the simplest Ruby Http client. It lets you do HTTP directly on URL strings. If a string can respond to_i and return the integer value of the string or 0 if it is not a integer, then it only makes sense to make it respond to http methods also. If you want to do HTTP really fast without much setup or hassle in a pry or IRB session, then Dpr is what you want.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -28,9 +28,9 @@ code # -1
|
|
|
28
28
|
### Headers and Parameters
|
|
29
29
|
|
|
30
30
|
```ruby
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
slack_incoming_hook_url.http_post
|
|
32
|
+
headers: { "Content-Type" => "application/json" },
|
|
33
|
+
params: { text: 'Dpr is so cool yo!' }
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
### Methods
|
data/dpr.gemspec
CHANGED
|
@@ -19,11 +19,12 @@ Gem::Specification.new do |spec|
|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
20
20
|
spec.require_paths = ["lib"]
|
|
21
21
|
|
|
22
|
-
spec.add_development_dependency
|
|
23
|
-
spec.add_development_dependency
|
|
24
|
-
spec.add_development_dependency
|
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
25
25
|
spec.add_development_dependency 'guard', '~> 2.13', '>= 2.13.0'
|
|
26
26
|
spec.add_development_dependency 'guard-rspec', '~> 4.6', '>= 4.6.3'
|
|
27
27
|
spec.add_development_dependency 'pry', '>= 0.9.10', '< 0.11.0'
|
|
28
|
-
spec.add_runtime_dependency
|
|
28
|
+
spec.add_runtime_dependency 'rest-client', '~> 1.8'
|
|
29
|
+
spec.add_runtime_dependency 'addressable', '~> 2.3', '>= 2.3.2'
|
|
29
30
|
end
|
data/lib/dpr.rb
CHANGED
|
@@ -4,6 +4,7 @@ require 'rest-client'
|
|
|
4
4
|
require 'json'
|
|
5
5
|
require 'addressable/uri'
|
|
6
6
|
|
|
7
|
+
|
|
7
8
|
class String
|
|
8
9
|
def http_get params: {}, headers: {}, timeout: 10
|
|
9
10
|
to_resp method: :get, headers: headers, params: params, timeout: timeout
|
|
@@ -44,7 +45,7 @@ class String
|
|
|
44
45
|
end
|
|
45
46
|
http_response = RestClient::Request.execute(:method => :get, :url => url, :headers => headers, :timeout => timeout)
|
|
46
47
|
when :post
|
|
47
|
-
http_response = RestClient::Request.execute(:method => :post, :url => self, :payload => params, :headers => headers, :timeout => timeout)
|
|
48
|
+
http_response = RestClient::Request.execute(:method => :post, :url => self, :payload => params.to_json, :headers => headers, :timeout => timeout)
|
|
48
49
|
when :put
|
|
49
50
|
http_response = RestClient::Request.execute(:method => :put, :url => self, :payload => params, :headers => headers, :timeout => timeout)
|
|
50
51
|
when :delete
|
|
@@ -57,8 +58,12 @@ class String
|
|
|
57
58
|
rescue RestClient::Exception => e
|
|
58
59
|
http_response = e.response
|
|
59
60
|
end
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
|
|
62
|
+
begin
|
|
63
|
+
return JSON.parse(http_response.body), http_response.code
|
|
64
|
+
rescue JSON::ParserError
|
|
65
|
+
return {response: http_response.body}, http_response.code
|
|
66
|
+
end
|
|
62
67
|
else
|
|
63
68
|
return {}, -1
|
|
64
69
|
end
|
data/lib/dpr/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dpr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SudhagarS
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-04-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -126,6 +126,26 @@ dependencies:
|
|
|
126
126
|
- - "~>"
|
|
127
127
|
- !ruby/object:Gem::Version
|
|
128
128
|
version: '1.8'
|
|
129
|
+
- !ruby/object:Gem::Dependency
|
|
130
|
+
name: addressable
|
|
131
|
+
requirement: !ruby/object:Gem::Requirement
|
|
132
|
+
requirements:
|
|
133
|
+
- - "~>"
|
|
134
|
+
- !ruby/object:Gem::Version
|
|
135
|
+
version: '2.3'
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: 2.3.2
|
|
139
|
+
type: :runtime
|
|
140
|
+
prerelease: false
|
|
141
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - "~>"
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '2.3'
|
|
146
|
+
- - ">="
|
|
147
|
+
- !ruby/object:Gem::Version
|
|
148
|
+
version: 2.3.2
|
|
129
149
|
description: The simplest Ruby HTTP client. Dpr lets you do HTTP directly on URL strings.
|
|
130
150
|
email:
|
|
131
151
|
- sudhagar@isudhagar.in
|