rest_client_plus 0.0.2 → 0.0.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.
- data/Gemfile.lock +1 -1
- data/README.md +38 -0
- data/lib/array_helper.rb +5 -2
- data/lib/requests.rb +25 -0
- data/lib/rest_client_plus.rb +3 -21
- data/rest_client_plus.gemspec +1 -1
- metadata +2 -1
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,3 +2,41 @@ RestClientPlus
|
|
2
2
|
==============
|
3
3
|
|
4
4
|
Extensions to Ruby's RestClient
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'rest_client_plus'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install rest_client_plus
|
19
|
+
|
20
|
+
Require using:
|
21
|
+
|
22
|
+
$ require 'rest_client_plus'
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
RestClientPlus provides GET, POST and PUT methods which return a Ruby hash if json is received.
|
27
|
+
|
28
|
+
ArrayHelper.unwrap_from_array will unwrap a hash from a single-element array
|
29
|
+
|
30
|
+
## Running Tests
|
31
|
+
|
32
|
+
/ruby tests/*
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. Fork it
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Add Tests to the project
|
39
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
40
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
41
|
+
6. Create new Pull Request
|
42
|
+
|
data/lib/array_helper.rb
CHANGED
data/lib/requests.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
module RestClientPlus
|
2
|
+
|
3
|
+
module Requests
|
4
|
+
|
5
|
+
def self.post_json_to_url input_url, json_body
|
6
|
+
response = RestClient.post(input_url, json_body, :content_type => 'application/json')
|
7
|
+
response.code.should == 200
|
8
|
+
JSON.parse response.body
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.put_json_to_url input_url, json_body
|
12
|
+
response = RestClient.put(input_url, json_body, :content_type => 'application/json')
|
13
|
+
response.code.should == 200
|
14
|
+
JSON.parse response.body
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.get_json_from_url input_url
|
18
|
+
response = RestClient.get(input_url)
|
19
|
+
response.code.should == 200
|
20
|
+
JSON.parse response.body
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/lib/rest_client_plus.rb
CHANGED
@@ -1,25 +1,7 @@
|
|
1
|
-
require_relative 'rest_client_plus'
|
2
1
|
|
3
2
|
module RestClientPlus
|
4
|
-
class Requests
|
5
|
-
|
6
|
-
def self.post_json_to_url input_url, json_body
|
7
|
-
response = RestClient.post(input_url, json_body, :content_type => 'application/json')
|
8
|
-
response.code.should == 200
|
9
|
-
JSON.parse response.body
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.put_json_to_url input_url, json_body
|
13
|
-
response = RestClient.put(input_url, json_body, :content_type => 'application/json')
|
14
|
-
response.code.should == 200
|
15
|
-
JSON.parse response.body
|
16
|
-
end
|
17
3
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
JSON.parse response.body
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
4
|
+
require_relative 'array_helper'
|
5
|
+
require_relative 'requests'
|
6
|
+
|
25
7
|
end
|
data/rest_client_plus.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "rest_client_plus"
|
7
|
-
s.version = "0.0.
|
7
|
+
s.version = "0.0.3"
|
8
8
|
s.authors = ["John Wakeling", "Darren Bown"]
|
9
9
|
s.email = ["jwakeling23@gmail.com", "darren.bown@droidqa.co.uk"]
|
10
10
|
s.description = %q{Extensions to Ruby's RestClient}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest_client_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- README.md
|
60
60
|
- Rakefile
|
61
61
|
- lib/array_helper.rb
|
62
|
+
- lib/requests.rb
|
62
63
|
- lib/rest_client_plus.rb
|
63
64
|
- rest_client_plus.gemspec
|
64
65
|
- tests/array_helper_test.rb
|