rest_baby 0.1 → 0.2

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +13 -0
  3. data/README.md +2 -2
  4. data/Rakefile +8 -1
  5. data/doc/MockRestService.html +351 -0
  6. data/doc/PinchRestService.html +349 -0
  7. data/doc/RestBaby/Client.html +936 -0
  8. data/doc/RestBaby.html +170 -0
  9. data/doc/_index.html +182 -0
  10. data/doc/class_list.html +74 -0
  11. data/doc/css/common.css +1 -0
  12. data/doc/css/cucumber.css +227 -0
  13. data/doc/css/full_list.css +57 -0
  14. data/doc/css/style.css +338 -0
  15. data/doc/feature_list.html +245 -0
  16. data/doc/featuredirectories_list.html +179 -0
  17. data/doc/file.README.html +134 -0
  18. data/doc/file_list.html +76 -0
  19. data/doc/frames.html +28 -0
  20. data/doc/index.html +134 -0
  21. data/doc/js/app.js +214 -0
  22. data/doc/js/cucumber.js +305 -0
  23. data/doc/js/full_list.js +178 -0
  24. data/doc/js/jquery.js +4 -0
  25. data/doc/method_list.html +169 -0
  26. data/doc/requirements/features/header_options.html +1020 -0
  27. data/doc/requirements/features/headers/header_options.html +1020 -0
  28. data/doc/requirements/features/headers.html +157 -0
  29. data/doc/requirements/features/print_response.html +969 -0
  30. data/doc/requirements/features/rest_client.html +835 -0
  31. data/doc/requirements/features.html +199 -0
  32. data/doc/requirements/step_transformers.html +1508 -0
  33. data/doc/requirements/tags/authentication.html +169 -0
  34. data/doc/requirements/tags/core.html +187 -0
  35. data/doc/requirements/tags/delete.html +169 -0
  36. data/doc/requirements/tags/extended.html +223 -0
  37. data/doc/requirements/tags/get.html +178 -0
  38. data/doc/requirements/tags/headers.html +169 -0
  39. data/doc/requirements/tags/post.html +196 -0
  40. data/doc/requirements/tags/print.html +187 -0
  41. data/doc/requirements/tags/put.html +169 -0
  42. data/doc/requirements/tags.html +408 -0
  43. data/doc/requirements.html +213 -0
  44. data/doc/step_list.html +825 -0
  45. data/doc/stepdefinition_list.html +230 -0
  46. data/doc/tag_list.html +131 -0
  47. data/doc/top-level-namespace.html +244 -0
  48. data/features/{header_options.feature → headers/header_options.feature} +0 -0
  49. data/features/step_definitions/rest_client_steps.rb +5 -4
  50. data/features/support/env.rb +1 -18
  51. data/features/support/mock_rest_service.rb +1 -1
  52. data/lib/rest_baby/version.rb +1 -1
  53. data/lib/rest_baby.rb +62 -35
  54. metadata +49 -5
  55. data/LICENSE +0 -24
data/lib/rest_baby.rb CHANGED
@@ -4,20 +4,26 @@
4
4
 
5
5
  Dave McNulla
6
6
 
7
- == Revision Log
8
-
9
- 2013.07.30 initial files for a simple rest client
10
-
11
7
  =end
12
8
 
13
9
  require 'net/http'
14
10
  require 'net/https'
15
11
  require "rest_baby/version"
16
12
 
13
+ ##
14
+ # RestBaby is a small rest client. It encapsulates some of the details for creating and using the rest service.
17
15
  module RestBaby
16
+ # Sends and receives data to a restful web service
18
17
  class Client
19
- attr_accessor :contentType, :uri, :wsresponse, :headers
20
18
 
19
+ ##
20
+ # Creates a new rest client
21
+ #
22
+ # * +url+ = url of the rest service
23
+ # eg. http://myrestservice.com:80/time
24
+ # * +headers+ = default headers to use.
25
+ # eg. '{ \"Content-Type\" => \"application/json\"}'
26
+ # can be multiple headers
21
27
  def initialize(url, headers = {})
22
28
  @uri = URI.parse(url)
23
29
  @headers = headers
@@ -25,54 +31,73 @@ module RestBaby
25
31
  @password = nil
26
32
  end
27
33
 
34
+ ##
35
+ # Modifies the headers by merging new headers with current headers.
36
+ #
37
+ # * +headers+ = new headers to merge with current headers
28
38
  def set_headers(headers)
29
39
  @headers = @headers.merge(headers)
30
40
  end
31
41
 
42
+ ##
43
+ # Modifies the authentication for the rest client
44
+ #
45
+ # * +user+ = authorized username
46
+ # * +password+ = password for the user
32
47
  def set_auth(user, password)
33
- new_url = "#{uri.scheme}://#{user}:#{password}@#{uri.host}:#{uri.port}#{uri.path}"
48
+ new_url = "#{@uri.scheme}://#{user}:#{password}@#{@uri.host}:#{@uri.port}#{@uri.path}"
34
49
  @uri = URI.parse(new_url)
35
50
  end
36
51
 
37
- #Basic web services Get command
38
- # * url = url to send the command to
39
- # * headers = header parameters including authorization and Content-Type
52
+ ##
53
+ # Basic web services Get command
54
+ #
55
+ # * +url+ = url to send the command to
56
+ # * +headers+ = header parameters including authorization and Content-Type
40
57
  # The response from the rest server is returned
41
- def get(path, headers = {})
42
- return request(uri, Net::HTTP::Get.new(@uri.request_uri), headers)
58
+ def get(headers = {})
59
+ return request(@uri, Net::HTTP::Get.new(@uri.request_uri), headers)
43
60
  end
44
61
 
45
- #Basic web services Post command
46
- # * url = url to send the command to
47
- # * body = data to put in the body
48
- # * headers = header parameters including authorization and Content-Type
62
+ ##
63
+ # Basic web services Post command
64
+ #
65
+ # * +url+ = url to send the command to
66
+ # * +body+ = data to put in the body
67
+ # * +headers+ = header parameters including authorization and Content-Type
49
68
  # The response from the rest server is returned
50
- def post(path, body = nil, headers = {})
51
- return request(uri, Net::HTTP::Post.new(@uri.request_uri), body, headers)
69
+ def post(body = nil, headers = {})
70
+ return request(@uri, Net::HTTP::Post.new(@uri.request_uri), body, headers)
52
71
  end
53
72
 
54
- #Basic web services Delete command
55
- # * url = url to send the command to
56
- # * headers = header parameters including authorization and Content-Type
73
+ ##
74
+ # Basic web services Delete command
75
+ #
76
+ # * +url+ = url to send the command to
77
+ # * +headers+ = header parameters including authorization and Content-Type
57
78
  # The response from the rest server is returned
58
- def delete(path, headers = {})
59
- return request(uri, Net::HTTP::Delete.new(@uri.request_uri), headers)
79
+ def delete(headers = {})
80
+ return request(@uri, Net::HTTP::Delete.new(@uri.request_uri), headers)
60
81
  end
61
82
 
62
- #Basic web services Put command
63
- # * url = url to send the command to
64
- # * body = data to put in the body
65
- # * headers = header parameters including authorization and Content-Type
83
+ ##
84
+ # Basic web services Put command
85
+ #
86
+ # * +url+ = url to send the command to
87
+ # * +body+ = data to put in the body
88
+ # * +headers+ = header parameters including authorization and Content-Type
66
89
  # The response from the rest server is returned
67
- def put(path, body = nil, headers = {})
68
- return request(uri, Net::HTTP::Put.new(@uri.request_uri), body, headers)
90
+ def put(body = nil, headers = {})
91
+ return request(@uri, Net::HTTP::Put.new(@uri.request_uri), body, headers)
69
92
  end
70
93
 
71
- #Sending the web services command
72
- # * url = url to send the command to
73
- # * req = command to send as Net::HTTP:<command> class
74
- # * body = data to put in the body
75
- # * headers = header parameters including authorization and Content-Type
94
+ ##
95
+ # Sending the web services command
96
+ #
97
+ # * +url+ = url to send the command to
98
+ # * +req+ = command to send as Net::HTTP:<command> class
99
+ # * +body+ = data to put in the body
100
+ # * +headers+ = header parameters including authorization and Content-Type
76
101
  # The response from the rest server is returned
77
102
  def request(uri, request, body = nil, headers)
78
103
  @headers.merge(headers).each { |key, value| request[key] = value }
@@ -92,8 +117,10 @@ module RestBaby
92
117
  @wsresponse.code
93
118
  end
94
119
 
95
- # Pretty print the web services response
96
- # * response = web service response to print
120
+ ##
121
+ # Pretty print the web services last response
122
+ #
123
+ # The nice looking output is returned as a string
97
124
  def print_last_response
98
125
  output = "CODE = #{@wsresponse.code}\n"
99
126
  output << "MESSAGE = #{@wsresponse.message}\n"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rest_baby
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave McNulla
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-05 00:00:00.000000000 Z
11
+ date: 2013-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -129,14 +129,57 @@ executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
+ - ChangeLog
132
133
  - Gemfile
133
- - LICENSE
134
134
  - LICENSE.txt
135
135
  - README.md
136
136
  - Rakefile
137
137
  - config/environments/mock.yml
138
138
  - cucumber.yml
139
- - features/header_options.feature
139
+ - doc/MockRestService.html
140
+ - doc/PinchRestService.html
141
+ - doc/RestBaby.html
142
+ - doc/RestBaby/Client.html
143
+ - doc/_index.html
144
+ - doc/class_list.html
145
+ - doc/css/common.css
146
+ - doc/css/cucumber.css
147
+ - doc/css/full_list.css
148
+ - doc/css/style.css
149
+ - doc/feature_list.html
150
+ - doc/featuredirectories_list.html
151
+ - doc/file.README.html
152
+ - doc/file_list.html
153
+ - doc/frames.html
154
+ - doc/index.html
155
+ - doc/js/app.js
156
+ - doc/js/cucumber.js
157
+ - doc/js/full_list.js
158
+ - doc/js/jquery.js
159
+ - doc/method_list.html
160
+ - doc/requirements.html
161
+ - doc/requirements/features.html
162
+ - doc/requirements/features/header_options.html
163
+ - doc/requirements/features/headers.html
164
+ - doc/requirements/features/headers/header_options.html
165
+ - doc/requirements/features/print_response.html
166
+ - doc/requirements/features/rest_client.html
167
+ - doc/requirements/step_transformers.html
168
+ - doc/requirements/tags.html
169
+ - doc/requirements/tags/authentication.html
170
+ - doc/requirements/tags/core.html
171
+ - doc/requirements/tags/delete.html
172
+ - doc/requirements/tags/extended.html
173
+ - doc/requirements/tags/get.html
174
+ - doc/requirements/tags/headers.html
175
+ - doc/requirements/tags/post.html
176
+ - doc/requirements/tags/print.html
177
+ - doc/requirements/tags/put.html
178
+ - doc/step_list.html
179
+ - doc/stepdefinition_list.html
180
+ - doc/tag_list.html
181
+ - doc/top-level-namespace.html
182
+ - features/headers/header_options.feature
140
183
  - features/print_response.feature
141
184
  - features/rest_client.feature
142
185
  - features/step_definitions/header_steps.rb
@@ -173,7 +216,7 @@ signing_key:
173
216
  specification_version: 4
174
217
  summary: This is a small rest client developed for use in testing rest services.
175
218
  test_files:
176
- - features/header_options.feature
219
+ - features/headers/header_options.feature
177
220
  - features/print_response.feature
178
221
  - features/rest_client.feature
179
222
  - features/step_definitions/header_steps.rb
@@ -182,3 +225,4 @@ test_files:
182
225
  - features/support/mock_rest_service.rb
183
226
  - features/support/pinch_rest_service.rb
184
227
  - features/support/utility.rb
228
+ has_rdoc:
data/LICENSE DELETED
@@ -1,24 +0,0 @@
1
- This is free and unencumbered software released into the public domain.
2
-
3
- Anyone is free to copy, modify, publish, use, compile, sell, or
4
- distribute this software, either in source code form or as a compiled
5
- binary, for any purpose, commercial or non-commercial, and by any
6
- means.
7
-
8
- In jurisdictions that recognize copyright laws, the author or authors
9
- of this software dedicate any and all copyright interest in the
10
- software to the public domain. We make this dedication for the benefit
11
- of the public at large and to the detriment of our heirs and
12
- successors. We intend this dedication to be an overt act of
13
- relinquishment in perpetuity of all present and future rights to this
14
- software under copyright law.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
- IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
- OTHER DEALINGS IN THE SOFTWARE.
23
-
24
- For more information, please refer to <http://unlicense.org/>