optionsful 0.4.1 → 0.4.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.
- data/README.textile +22 -17
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/optionsful.gemspec +5 -5
- data/spec/optionsful_server_spec.rb +30 -10
- metadata +7 -7
data/README.textile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
h1.
|
1
|
+
h1. [+*O p t i o n s f u l*+]
|
2
2
|
|
3
3
|
Provide HTTP OPTIONS support for the Ruby on Rails framework.
|
4
4
|
|
@@ -10,7 +10,7 @@ Provide HTTP OPTIONS support for the Ruby on Rails framework.
|
|
10
10
|
|
11
11
|
h1. "-No! No! No! *-Show me the code!*"
|
12
12
|
|
13
|
-
|
13
|
+
h2. Playing HTTP OPTIONS via telnet:
|
14
14
|
|
15
15
|
<pre>
|
16
16
|
$ telnet localhost 3000
|
@@ -42,7 +42,7 @@ Date: Thu, 22 Jul 2010 18:12:43 GMT
|
|
42
42
|
Link: "<http://localhost:3000/api/posts/1/comments>; type=text/html; rel=help"
|
43
43
|
|
44
44
|
</pre>
|
45
|
-
|
45
|
+
~*Note the empty line which is part of the HTTP protocol.*~
|
46
46
|
|
47
47
|
h3. I agree. Telnet is the geekest way.. ;-)
|
48
48
|
|
@@ -52,7 +52,7 @@ h3. I agree. Telnet is the geekest way.. ;-)
|
|
52
52
|
|
53
53
|
h1. INSTALLATION:
|
54
54
|
|
55
|
-
# Change directory to your Ruby on Rails web application
|
55
|
+
# Change directory to your Ruby on Rails web application
|
56
56
|
# Add gem dependency to @Gemfile@:
|
57
57
|
<pre>gem 'optionsful'</pre>
|
58
58
|
# Add it to the stack at @config/application.rb@:
|
@@ -63,6 +63,8 @@ h1. INSTALLATION:
|
|
63
63
|
<pre>$ gem install optionsful</pre>
|
64
64
|
# Enjoy! And give feedback! :)
|
65
65
|
|
66
|
+
h1. CONFIGURATION
|
67
|
+
|
66
68
|
h2. Setting up the @Link@ header
|
67
69
|
|
68
70
|
* To enable and setup the response's @Link@ header, install and edit the configuration file:
|
@@ -75,28 +77,32 @@ h2. Setting up the @Link@ header
|
|
75
77
|
base_path: /api
|
76
78
|
propagate: true</pre>
|
77
79
|
|
78
|
-
|
80
|
+
h2. Possible values and effects: (the underline values are the default ones)
|
79
81
|
|
80
82
|
* @link@
|
81
|
-
**
|
82
|
-
|
83
|
+
** [+false+]: Do not include the "Link" in the response headers.
|
84
|
+
*** some other settings are then ignored
|
85
|
+
** true: Do include it!
|
86
|
+
*** build the *URI* based on the *host*, *base_path*, and *propagate* values, explained below.
|
83
87
|
|
84
88
|
* @host@
|
85
|
-
**
|
86
|
-
**
|
87
|
-
|
89
|
+
** [+auto+]: Use the application's own address and port.
|
90
|
+
** custom URI: point it to another location
|
91
|
+
*** Example: www.baurets.net
|
92
|
+
*** *Note: do not include 'http://'*
|
88
93
|
|
89
94
|
* @base_path@
|
90
|
-
** the path to be appended to the host.
|
91
|
-
|
92
|
-
|
95
|
+
** the path to be appended to the host.
|
96
|
+
*** Default is [+*/api*+].
|
97
|
+
*** To disable it, use @/@
|
98
|
+
*** Example: /my_company_private_area/our_big_project/resources/api
|
93
99
|
|
94
100
|
* @propagate@
|
95
101
|
** false: Do not append the request's path info to the URI.
|
96
|
-
**
|
102
|
+
** [+true+]: Do append it, as it is.
|
97
103
|
|
98
104
|
* Generated Link example:
|
99
|
-
(*link: true*, *host: auto*)
|
105
|
+
(*link: true*, *host: auto*, *base_path: /api*, *propagate: true*)
|
100
106
|
<pre>Link: "<http://localhost:3000/api/posts/1/comments>; type=text/html; rel=help"</pre>
|
101
107
|
|
102
108
|
* *Note*: @Allow@ *and* @Link@ *are expected headers on a response to an HTTP OPTIONS request.*
|
@@ -110,7 +116,6 @@ h2. Development notes
|
|
110
116
|
* To bleed on the edge, at your Rails 3 application's @Gemfile@:
|
111
117
|
<pre>gem 'optionsful', :path => "~/your_workspace/optionsful/"</pre>
|
112
118
|
|
113
|
-
|
114
119
|
h2. Get involved
|
115
120
|
* Mailing list: http://groups.google.com/group/optionsful
|
116
121
|
* Bug tracker : http://kayaman.lighthouseapp.com/projects/56438-optionsful/overview
|
@@ -119,4 +124,4 @@ h2. CONTRIBUTORS
|
|
119
124
|
* Me, myself and I, so far.
|
120
125
|
* You are welcome, do it. ;-)
|
121
126
|
|
122
|
-
Copyright (c) 2010 Marco Antonio Gonzalez Junior, kayaman@baurets.net, released under the MIT license.
|
127
|
+
Copyright (c) 2010 Marco Antonio Gonzalez Junior, kayaman@baurets.net, released under the MIT license.
|
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ begin
|
|
14
14
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
15
15
|
gem.add_development_dependency "yard", ">= 0"
|
16
16
|
gem.add_development_dependency "cucumber", ">= 0"
|
17
|
-
gem.add_dependency "rails", "= 3.0.0.
|
17
|
+
gem.add_dependency "rails", "= 3.0.0.rc2"
|
18
18
|
end
|
19
19
|
Jeweler::GemcutterTasks.new
|
20
20
|
Jeweler::RubyforgeTasks.new do |rubyforge|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
data/optionsful.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{optionsful}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Marco Antonio Gonzalez Junior"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-26}
|
13
13
|
s.description = %q{Build RESTful web services supporting the HTTP OPTIONS verb on Ruby on Rails applications.}
|
14
14
|
s.email = %q{kayaman@baurets.net}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -67,18 +67,18 @@ Gem::Specification.new do |s|
|
|
67
67
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
68
68
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
69
69
|
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
70
|
-
s.add_runtime_dependency(%q<rails>, ["= 3.0.0.
|
70
|
+
s.add_runtime_dependency(%q<rails>, ["= 3.0.0.rc2"])
|
71
71
|
else
|
72
72
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
73
73
|
s.add_dependency(%q<yard>, [">= 0"])
|
74
74
|
s.add_dependency(%q<cucumber>, [">= 0"])
|
75
|
-
s.add_dependency(%q<rails>, ["= 3.0.0.
|
75
|
+
s.add_dependency(%q<rails>, ["= 3.0.0.rc2"])
|
76
76
|
end
|
77
77
|
else
|
78
78
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
79
79
|
s.add_dependency(%q<yard>, [">= 0"])
|
80
80
|
s.add_dependency(%q<cucumber>, [">= 0"])
|
81
|
-
s.add_dependency(%q<rails>, ["= 3.0.0.
|
81
|
+
s.add_dependency(%q<rails>, ["= 3.0.0.rc2"])
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -106,7 +106,6 @@ describe "Optionsful" do
|
|
106
106
|
response[0].should be 404
|
107
107
|
end
|
108
108
|
|
109
|
-
|
110
109
|
after(:all) do
|
111
110
|
Rails.application.reload_routes!
|
112
111
|
end
|
@@ -291,7 +290,7 @@ describe "Optionsful" do
|
|
291
290
|
end
|
292
291
|
end
|
293
292
|
|
294
|
-
it "
|
293
|
+
it "a full flavour should work" do
|
295
294
|
response = http_options_request("/products/123/sales/recent.xml")
|
296
295
|
validate_response(response)
|
297
296
|
response[0].should be 204
|
@@ -354,7 +353,7 @@ describe "Optionsful" do
|
|
354
353
|
end
|
355
354
|
end
|
356
355
|
|
357
|
-
it "
|
356
|
+
it "'/' should work" do
|
358
357
|
response = http_options_request("/")
|
359
358
|
validate_response(response)
|
360
359
|
response[0].should be 204
|
@@ -366,8 +365,29 @@ describe "Optionsful" do
|
|
366
365
|
end
|
367
366
|
|
368
367
|
end
|
368
|
+
|
369
|
+
describe "route globbing" do
|
370
|
+
|
371
|
+
before(:all) do
|
372
|
+
rails_app.routes.draw do
|
373
|
+
match 'photos/*other' => 'photos#unknown'
|
374
|
+
end
|
375
|
+
end
|
376
|
+
|
377
|
+
it "should work" do
|
378
|
+
response = http_options_request("/photos/chick/show/123.json")
|
379
|
+
validate_response(response)
|
380
|
+
response[0].should be 204
|
381
|
+
response[1]["Allow"].should include "GET"
|
382
|
+
end
|
383
|
+
|
384
|
+
after(:all) do
|
385
|
+
Rails.application.reload_routes!
|
386
|
+
end
|
387
|
+
|
388
|
+
end
|
369
389
|
|
370
|
-
describe "the legacy '
|
390
|
+
describe "the legacy 'wild' controller" do
|
371
391
|
|
372
392
|
before(:all) do
|
373
393
|
rails_app.routes.draw do
|
@@ -392,7 +412,7 @@ describe "Optionsful" do
|
|
392
412
|
|
393
413
|
context "the Link header" do
|
394
414
|
|
395
|
-
describe "should
|
415
|
+
describe "should NOT be present" do
|
396
416
|
|
397
417
|
before(:each) do
|
398
418
|
rails_app.routes.draw do
|
@@ -401,7 +421,7 @@ describe "Optionsful" do
|
|
401
421
|
delete_configuration_file
|
402
422
|
end
|
403
423
|
|
404
|
-
it "if
|
424
|
+
it "if NO directions were given" do
|
405
425
|
response = http_options_request("/posts")
|
406
426
|
validate_response(response)
|
407
427
|
response[0].should be 204
|
@@ -436,7 +456,7 @@ describe "Optionsful" do
|
|
436
456
|
link.should match /\A\".+\"\z/
|
437
457
|
end
|
438
458
|
|
439
|
-
it "the Link header
|
459
|
+
it "the Link header MAY use its very current host" do
|
440
460
|
copy_configuration_file('optionsful_true.yml')
|
441
461
|
response = http_options_request("/posts")
|
442
462
|
validate_response(response)
|
@@ -445,7 +465,7 @@ describe "Optionsful" do
|
|
445
465
|
link.should match /\A\"<http:\/\/localhost.+\"\z/
|
446
466
|
end
|
447
467
|
|
448
|
-
it "the Link header
|
468
|
+
it "the Link header MAY use a custom host value" do
|
449
469
|
copy_configuration_file('optionsful_true_custom.yml')
|
450
470
|
response = http_options_request("/posts")
|
451
471
|
validate_response(response)
|
@@ -454,7 +474,7 @@ describe "Optionsful" do
|
|
454
474
|
link.should match /\A\"<http:\/\/www.baurets.net.+\"\z/
|
455
475
|
end
|
456
476
|
|
457
|
-
it "the Link header
|
477
|
+
it "the Link header MAY use a custom base path value" do
|
458
478
|
copy_configuration_file('optionsful_true_custom_base_path.yml')
|
459
479
|
response = http_options_request("/posts")
|
460
480
|
validate_response(response)
|
@@ -463,7 +483,7 @@ describe "Optionsful" do
|
|
463
483
|
link.should match /\A\"<http:\/\/www.baurets.net\/private\/api.+\"\z/
|
464
484
|
end
|
465
485
|
|
466
|
-
it "the Link header
|
486
|
+
it "the Link header MAY propagate original path info" do
|
467
487
|
copy_configuration_file('optionsful_true_custom_propagate.yml')
|
468
488
|
response = http_options_request("/posts")
|
469
489
|
validate_response(response)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optionsful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 2
|
10
|
+
version: 0.4.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marco Antonio Gonzalez Junior
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-26 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -70,13 +70,13 @@ dependencies:
|
|
70
70
|
requirements:
|
71
71
|
- - "="
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
hash:
|
73
|
+
hash: 977940607
|
74
74
|
segments:
|
75
75
|
- 3
|
76
76
|
- 0
|
77
77
|
- 0
|
78
|
-
-
|
79
|
-
version: 3.0.0.
|
78
|
+
- rc2
|
79
|
+
version: 3.0.0.rc2
|
80
80
|
type: :runtime
|
81
81
|
version_requirements: *id004
|
82
82
|
description: Build RESTful web services supporting the HTTP OPTIONS verb on Ruby on Rails applications.
|