restfully 0.6.3 → 0.7.0.pre

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 (73) hide show
  1. data/README.md +166 -0
  2. data/Rakefile +35 -35
  3. data/bin/restfully +68 -10
  4. data/lib/restfully.rb +8 -14
  5. data/lib/restfully/collection.rb +70 -90
  6. data/lib/restfully/error.rb +2 -0
  7. data/lib/restfully/http.rb +3 -3
  8. data/lib/restfully/http/error.rb +1 -20
  9. data/lib/restfully/http/helper.rb +49 -0
  10. data/lib/restfully/http/request.rb +60 -24
  11. data/lib/restfully/http/response.rb +55 -24
  12. data/lib/restfully/link.rb +32 -24
  13. data/lib/restfully/media_type.rb +70 -0
  14. data/lib/restfully/media_type/abstract_media_type.rb +162 -0
  15. data/lib/restfully/media_type/application_json.rb +21 -0
  16. data/lib/restfully/media_type/application_vnd_bonfire_xml.rb +177 -0
  17. data/lib/restfully/media_type/application_x_www_form_urlencoded.rb +33 -0
  18. data/lib/restfully/media_type/grid5000.rb +67 -0
  19. data/lib/restfully/media_type/wildcard.rb +27 -0
  20. data/lib/restfully/rack.rb +1 -0
  21. data/lib/restfully/rack/basic_auth.rb +26 -0
  22. data/lib/restfully/resource.rb +134 -197
  23. data/lib/restfully/session.rb +127 -70
  24. data/lib/restfully/version.rb +3 -0
  25. data/spec/fixtures/bonfire-collection-with-fragments.xml +6 -0
  26. data/spec/fixtures/bonfire-compute-existing.xml +43 -0
  27. data/spec/fixtures/bonfire-empty-collection.xml +4 -0
  28. data/spec/fixtures/bonfire-experiment-collection.xml +51 -0
  29. data/spec/fixtures/bonfire-network-collection.xml +35 -0
  30. data/spec/fixtures/bonfire-network-existing.xml +6 -0
  31. data/spec/fixtures/bonfire-root.xml +5 -0
  32. data/spec/fixtures/grid5000-rennes-jobs.json +988 -146
  33. data/spec/fixtures/grid5000-rennes.json +63 -0
  34. data/spec/restfully/collection_spec.rb +87 -0
  35. data/spec/restfully/http/helper_spec.rb +18 -0
  36. data/spec/restfully/http/request_spec.rb +97 -0
  37. data/spec/restfully/http/response_spec.rb +53 -0
  38. data/spec/restfully/link_spec.rb +80 -0
  39. data/spec/restfully/media_type/application_vnd_bonfire_xml_spec.rb +153 -0
  40. data/spec/restfully/media_type_spec.rb +117 -0
  41. data/spec/restfully/resource_spec.rb +109 -0
  42. data/spec/restfully/session_spec.rb +229 -0
  43. data/spec/spec_helper.rb +10 -9
  44. metadata +162 -83
  45. data/.document +0 -5
  46. data/CHANGELOG +0 -62
  47. data/README.rdoc +0 -146
  48. data/TODO.rdoc +0 -3
  49. data/VERSION +0 -1
  50. data/examples/grid5000.rb +0 -33
  51. data/examples/scratch.rb +0 -37
  52. data/lib/restfully/extensions.rb +0 -34
  53. data/lib/restfully/http/adapters/abstract_adapter.rb +0 -29
  54. data/lib/restfully/http/adapters/patron_adapter.rb +0 -16
  55. data/lib/restfully/http/adapters/rest_client_adapter.rb +0 -75
  56. data/lib/restfully/http/headers.rb +0 -20
  57. data/lib/restfully/parsing.rb +0 -66
  58. data/lib/restfully/special_array.rb +0 -5
  59. data/lib/restfully/special_hash.rb +0 -5
  60. data/restfully.gemspec +0 -114
  61. data/spec/collection_spec.rb +0 -120
  62. data/spec/fixtures/configuration_file.yml +0 -4
  63. data/spec/fixtures/grid5000-sites.json +0 -540
  64. data/spec/http/error_spec.rb +0 -18
  65. data/spec/http/headers_spec.rb +0 -17
  66. data/spec/http/request_spec.rb +0 -49
  67. data/spec/http/response_spec.rb +0 -19
  68. data/spec/http/rest_client_adapter_spec.rb +0 -35
  69. data/spec/link_spec.rb +0 -61
  70. data/spec/parsing_spec.rb +0 -40
  71. data/spec/resource_spec.rb +0 -320
  72. data/spec/restfully_spec.rb +0 -16
  73. data/spec/session_spec.rb +0 -171
data/spec/spec_helper.rb CHANGED
@@ -1,19 +1,20 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
-
4
1
  require 'webmock/rspec'
5
- include WebMock
6
-
7
2
  require 'restfully'
8
- require 'spec'
9
- require 'spec/autorun'
10
3
  require 'json'
11
4
 
5
+ require 'restfully/media_type/application_vnd_bonfire_xml'
12
6
 
13
7
  def fixture(filename)
14
8
  File.read(File.join(File.dirname(__FILE__), "fixtures", filename))
15
9
  end
16
10
 
17
- Spec::Runner.configure do |config|
18
-
11
+ RSpec.configure do |config|
12
+
13
+ config.before(:each) do
14
+ Restfully::MediaType.reset
15
+ end
16
+
17
+ # == Mock Framework
18
+ config.mock_with :rspec
19
+
19
20
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restfully
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
5
- prerelease:
4
+ hash: 961916028
5
+ prerelease: 6
6
6
  segments:
7
7
  - 0
8
- - 6
9
- - 3
10
- version: 0.6.3
8
+ - 7
9
+ - 0
10
+ - pre
11
+ version: 0.7.0.pre
11
12
  platform: ruby
12
13
  authors:
13
14
  - Cyril Rohr
@@ -15,42 +16,41 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-04-14 00:00:00 +02:00
19
- default_executable: restfully
19
+ date: 2011-04-28 00:00:00 +02:00
20
+ default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
- name: rest-client
23
+ name: json
23
24
  prerelease: false
24
25
  requirement: &id001 !ruby/object:Gem::Requirement
25
26
  none: false
26
27
  requirements:
27
- - - ">="
28
+ - - ~>
28
29
  - !ruby/object:Gem::Version
29
- hash: 7
30
+ hash: 5
30
31
  segments:
31
32
  - 1
32
- - 4
33
- version: "1.4"
33
+ - 5
34
+ version: "1.5"
34
35
  type: :runtime
35
36
  version_requirements: *id001
36
37
  - !ruby/object:Gem::Dependency
37
- name: json
38
+ name: rest-client
38
39
  prerelease: false
39
40
  requirement: &id002 !ruby/object:Gem::Requirement
40
41
  none: false
41
42
  requirements:
42
- - - ">="
43
+ - - ~>
43
44
  - !ruby/object:Gem::Version
44
- hash: 31
45
+ hash: 3
45
46
  segments:
46
47
  - 1
47
- - 2
48
- - 0
49
- version: 1.2.0
48
+ - 6
49
+ version: "1.6"
50
50
  type: :runtime
51
51
  version_requirements: *id002
52
52
  - !ruby/object:Gem::Dependency
53
- name: backports
53
+ name: rest-client-components
54
54
  prerelease: false
55
55
  requirement: &id003 !ruby/object:Gem::Requirement
56
56
  none: false
@@ -64,7 +64,7 @@ dependencies:
64
64
  type: :runtime
65
65
  version_requirements: *id003
66
66
  - !ruby/object:Gem::Dependency
67
- name: webmock
67
+ name: rack-cache
68
68
  prerelease: false
69
69
  requirement: &id004 !ruby/object:Gem::Requirement
70
70
  none: false
@@ -75,10 +75,10 @@ dependencies:
75
75
  segments:
76
76
  - 0
77
77
  version: "0"
78
- type: :development
78
+ type: :runtime
79
79
  version_requirements: *id004
80
80
  - !ruby/object:Gem::Dependency
81
- name: rspec
81
+ name: backports
82
82
  prerelease: false
83
83
  requirement: &id005 !ruby/object:Gem::Requirement
84
84
  none: false
@@ -89,10 +89,10 @@ dependencies:
89
89
  segments:
90
90
  - 0
91
91
  version: "0"
92
- type: :development
92
+ type: :runtime
93
93
  version_requirements: *id005
94
94
  - !ruby/object:Gem::Dependency
95
- name: json
95
+ name: addressable
96
96
  prerelease: false
97
97
  requirement: &id006 !ruby/object:Gem::Requirement
98
98
  none: false
@@ -103,69 +103,141 @@ dependencies:
103
103
  segments:
104
104
  - 0
105
105
  version: "0"
106
- type: :development
106
+ type: :runtime
107
107
  version_requirements: *id006
108
- description: Experimental code for auto-generation of wrappers on top of RESTful APIs that follow HATEOAS principles and provide OPTIONS methods and/or Allow headers.
109
- email: cyril.rohr@gmail.com
108
+ - !ruby/object:Gem::Dependency
109
+ name: rake
110
+ prerelease: false
111
+ requirement: &id007 !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ~>
115
+ - !ruby/object:Gem::Version
116
+ hash: 27
117
+ segments:
118
+ - 0
119
+ - 8
120
+ version: "0.8"
121
+ type: :development
122
+ version_requirements: *id007
123
+ - !ruby/object:Gem::Dependency
124
+ name: rspec
125
+ prerelease: false
126
+ requirement: &id008 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ~>
130
+ - !ruby/object:Gem::Version
131
+ hash: 7
132
+ segments:
133
+ - 2
134
+ version: "2"
135
+ type: :development
136
+ version_requirements: *id008
137
+ - !ruby/object:Gem::Dependency
138
+ name: webmock
139
+ prerelease: false
140
+ requirement: &id009 !ruby/object:Gem::Requirement
141
+ none: false
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ hash: 3
146
+ segments:
147
+ - 0
148
+ version: "0"
149
+ type: :development
150
+ version_requirements: *id009
151
+ - !ruby/object:Gem::Dependency
152
+ name: autotest
153
+ prerelease: false
154
+ requirement: &id010 !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ hash: 3
160
+ segments:
161
+ - 0
162
+ version: "0"
163
+ type: :development
164
+ version_requirements: *id010
165
+ - !ruby/object:Gem::Dependency
166
+ name: autotest-growl
167
+ prerelease: false
168
+ requirement: &id011 !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ hash: 3
174
+ segments:
175
+ - 0
176
+ version: "0"
177
+ type: :development
178
+ version_requirements: *id011
179
+ description: Consume RESTful APIs effortlessly
180
+ email:
181
+ - cyril.rohr@gmail.com
110
182
  executables:
111
183
  - restfully
112
184
  extensions: []
113
185
 
114
186
  extra_rdoc_files:
115
187
  - LICENSE
116
- - README.rdoc
188
+ - README.md
117
189
  files:
118
- - .document
119
- - CHANGELOG
120
- - LICENSE
121
- - README.rdoc
122
- - Rakefile
123
- - TODO.rdoc
124
- - VERSION
125
190
  - bin/restfully
126
- - examples/grid5000.rb
127
- - lib/restfully.rb
128
191
  - lib/restfully/collection.rb
129
192
  - lib/restfully/error.rb
130
- - lib/restfully/extensions.rb
131
- - lib/restfully/http.rb
132
- - lib/restfully/http/adapters/abstract_adapter.rb
133
- - lib/restfully/http/adapters/patron_adapter.rb
134
- - lib/restfully/http/adapters/rest_client_adapter.rb
135
193
  - lib/restfully/http/error.rb
136
- - lib/restfully/http/headers.rb
194
+ - lib/restfully/http/helper.rb
137
195
  - lib/restfully/http/request.rb
138
196
  - lib/restfully/http/response.rb
197
+ - lib/restfully/http.rb
139
198
  - lib/restfully/link.rb
140
- - lib/restfully/parsing.rb
199
+ - lib/restfully/media_type/abstract_media_type.rb
200
+ - lib/restfully/media_type/application_json.rb
201
+ - lib/restfully/media_type/application_vnd_bonfire_xml.rb
202
+ - lib/restfully/media_type/application_x_www_form_urlencoded.rb
203
+ - lib/restfully/media_type/grid5000.rb
204
+ - lib/restfully/media_type/wildcard.rb
205
+ - lib/restfully/media_type.rb
206
+ - lib/restfully/rack/basic_auth.rb
207
+ - lib/restfully/rack.rb
141
208
  - lib/restfully/resource.rb
142
209
  - lib/restfully/session.rb
143
- - lib/restfully/special_array.rb
144
- - lib/restfully/special_hash.rb
145
- - restfully.gemspec
146
- - spec/collection_spec.rb
147
- - spec/fixtures/configuration_file.yml
210
+ - lib/restfully/version.rb
211
+ - lib/restfully.rb
212
+ - spec/fixtures/bonfire-collection-with-fragments.xml
213
+ - spec/fixtures/bonfire-compute-existing.xml
214
+ - spec/fixtures/bonfire-empty-collection.xml
215
+ - spec/fixtures/bonfire-experiment-collection.xml
216
+ - spec/fixtures/bonfire-network-collection.xml
217
+ - spec/fixtures/bonfire-network-existing.xml
218
+ - spec/fixtures/bonfire-root.xml
148
219
  - spec/fixtures/grid5000-rennes-jobs.json
149
- - spec/fixtures/grid5000-sites.json
150
- - spec/http/error_spec.rb
151
- - spec/http/headers_spec.rb
152
- - spec/http/request_spec.rb
153
- - spec/http/response_spec.rb
154
- - spec/http/rest_client_adapter_spec.rb
155
- - spec/link_spec.rb
156
- - spec/parsing_spec.rb
157
- - spec/resource_spec.rb
158
- - spec/restfully_spec.rb
159
- - spec/session_spec.rb
220
+ - spec/fixtures/grid5000-rennes.json
221
+ - spec/restfully/collection_spec.rb
222
+ - spec/restfully/http/helper_spec.rb
223
+ - spec/restfully/http/request_spec.rb
224
+ - spec/restfully/http/response_spec.rb
225
+ - spec/restfully/link_spec.rb
226
+ - spec/restfully/media_type/application_vnd_bonfire_xml_spec.rb
227
+ - spec/restfully/media_type_spec.rb
228
+ - spec/restfully/resource_spec.rb
229
+ - spec/restfully/session_spec.rb
160
230
  - spec/spec_helper.rb
161
- - examples/scratch.rb
231
+ - Rakefile
232
+ - LICENSE
233
+ - README.md
162
234
  has_rdoc: true
163
235
  homepage: http://github.com/crohr/restfully
164
236
  licenses: []
165
237
 
166
238
  post_install_message:
167
- rdoc_options: []
168
-
239
+ rdoc_options:
240
+ - --charset=UTF-8
169
241
  require_paths:
170
242
  - lib
171
243
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -173,38 +245,45 @@ required_ruby_version: !ruby/object:Gem::Requirement
173
245
  requirements:
174
246
  - - ">="
175
247
  - !ruby/object:Gem::Version
176
- hash: 3
248
+ hash: 31
177
249
  segments:
178
- - 0
179
- version: "0"
250
+ - 1
251
+ - 8
252
+ version: "1.8"
180
253
  required_rubygems_version: !ruby/object:Gem::Requirement
181
254
  none: false
182
255
  requirements:
183
256
  - - ">="
184
257
  - !ruby/object:Gem::Version
185
- hash: 3
258
+ hash: 9
186
259
  segments:
187
- - 0
188
- version: "0"
260
+ - 1
261
+ - 3
262
+ version: "1.3"
189
263
  requirements: []
190
264
 
191
265
  rubyforge_project:
192
266
  rubygems_version: 1.5.2
193
267
  signing_key:
194
268
  specification_version: 3
195
- summary: Experimental code for auto-generation of wrappers on top of RESTful APIs that follow some specific conventions.
269
+ summary: Consume RESTful APIs effortlessly
196
270
  test_files:
197
- - examples/grid5000.rb
198
- - examples/scratch.rb
199
- - spec/collection_spec.rb
200
- - spec/http/error_spec.rb
201
- - spec/http/headers_spec.rb
202
- - spec/http/request_spec.rb
203
- - spec/http/response_spec.rb
204
- - spec/http/rest_client_adapter_spec.rb
205
- - spec/link_spec.rb
206
- - spec/parsing_spec.rb
207
- - spec/resource_spec.rb
208
- - spec/restfully_spec.rb
209
- - spec/session_spec.rb
271
+ - spec/fixtures/bonfire-collection-with-fragments.xml
272
+ - spec/fixtures/bonfire-compute-existing.xml
273
+ - spec/fixtures/bonfire-empty-collection.xml
274
+ - spec/fixtures/bonfire-experiment-collection.xml
275
+ - spec/fixtures/bonfire-network-collection.xml
276
+ - spec/fixtures/bonfire-network-existing.xml
277
+ - spec/fixtures/bonfire-root.xml
278
+ - spec/fixtures/grid5000-rennes-jobs.json
279
+ - spec/fixtures/grid5000-rennes.json
280
+ - spec/restfully/collection_spec.rb
281
+ - spec/restfully/http/helper_spec.rb
282
+ - spec/restfully/http/request_spec.rb
283
+ - spec/restfully/http/response_spec.rb
284
+ - spec/restfully/link_spec.rb
285
+ - spec/restfully/media_type/application_vnd_bonfire_xml_spec.rb
286
+ - spec/restfully/media_type_spec.rb
287
+ - spec/restfully/resource_spec.rb
288
+ - spec/restfully/session_spec.rb
210
289
  - spec/spec_helper.rb
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/CHANGELOG DELETED
@@ -1,62 +0,0 @@
1
- 0.6.1
2
- * Removed unnecessary logging.
3
-
4
- 0.6.0
5
- * Fixed collection traversal.
6
- * Query parameters that are Arrays are no longer joined.
7
- * Added 'next' as valid link relationship.
8
-
9
- 0.5.10
10
- * Direct lookup to the resource if it cannot be found in the collection (for APIs that do not return all the items in a collection) (priteau)
11
- * Automatically load next pages of a collection when iterating through it
12
-
13
- 0.5.9
14
- * fixed bug in #http_methods that made a resource not removable unless force reloading it
15
-
16
- 0.5.8
17
- * explicit dependency on 'json' >= 1.2.0
18
-
19
- 0.5.7
20
- * fixed bug due to the way RestClient handles custom headers (esp. the Accept HTTP header)
21
- * added PUT method
22
-
23
- 0.5.6
24
- * requires rest-client 1.4+
25
-
26
- 0.5.5
27
- * raise an error if Content-Type of the response is nil or empty
28
- * start to use webmock for better tests
29
-
30
- 0.5.4
31
- * refactored Restfully::Parsing module. Allow to define its own parsers for specific content types
32
- * automatically load root resource when calling session.root
33
-
34
- 0.5.3
35
- * can handle text/* content, useful when using low-level methods on a session object (session.{get,post,delete,put})
36
- * can now find a collection item using collection[:symbol] even if item uid is an integer: collection[:'12345']
37
- * default_headers no longer overwrite custom headers set by user
38
- * fixed bug with latest version of rest-client
39
-
40
- 0.5.2
41
- * support for DELETE requests. Use resource.delete(options)
42
- * fixed bug in resource.load(:reload => true)
43
-
44
- 0.5.1
45
- * fixed bug in resource.reload
46
-
47
- 0.5.0
48
- * support for POST requests. Use resource.submit(payload, options)
49
-
50
- 0.4.1
51
- * added a require 'yaml' in restfully.rb (priteau);
52
- * added an introductory message when using the command-line tool;
53
- * removed [root_path] from the list of options in command-line client 'Usage' banner (priteau);
54
- * added test for :configuration_file option;
55
- * tests are no longer failing on ruby1.9;
56
-
57
- 0.4.0
58
- * removed 'root_path' option: 'base_uri' must point to the starting resource;
59
- * objects can now be pretty printed using 'pp object';
60
- * Restfully::Collection now include the Enumerable module;
61
- * Restfully::Collection inherits from Restfully::Resource;
62
- * 'object.uid' is no longer valid. Use 'object["uid"]' instead;