sinatra-verbs 0.0.6
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/.gitignore +3 -0
- data/Gemfile +5 -0
- data/LICENSE +14 -0
- data/README.markdown +67 -0
- data/Rakefile +2 -0
- data/lib/sinatra/verbs.rb +21 -0
- data/sinatra-verbs.gemspec +20 -0
- metadata +85 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Copyright (C) 2011 Rafael Fernández López <ereslibre@gmail.com>
|
|
2
|
+
|
|
3
|
+
This program is free software: you can redistribute it and/or modify
|
|
4
|
+
it under the terms of the GNU General Public License as published by
|
|
5
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
6
|
+
(at your option) any later version.
|
|
7
|
+
|
|
8
|
+
This program is distributed in the hope that it will be useful,
|
|
9
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11
|
+
GNU General Public License for more details.
|
|
12
|
+
|
|
13
|
+
You should have received a copy of the GNU General Public License
|
|
14
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
data/README.markdown
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Sinatra Verbs
|
|
2
|
+
|
|
3
|
+
## What is Sinatra Verbs ?
|
|
4
|
+
|
|
5
|
+
Sinatra Verbs is a Sinatra extension that allows you to extend regular supported HTTP verbs. It can be used just for fun, or to
|
|
6
|
+
implement a WebDAV server, for instance.
|
|
7
|
+
|
|
8
|
+
## Installing Sinatra Verbs
|
|
9
|
+
|
|
10
|
+
sudo gem install sinatra-verbs
|
|
11
|
+
|
|
12
|
+
## Using Sinatra Verbs
|
|
13
|
+
|
|
14
|
+
### Using Sinatra::Base
|
|
15
|
+
|
|
16
|
+
require 'sinatra/base'
|
|
17
|
+
require 'sinatra/verbs'
|
|
18
|
+
|
|
19
|
+
Sinatra::Verbs.custom :mkcol, :hello
|
|
20
|
+
|
|
21
|
+
class MyApp < Sinatra::Base
|
|
22
|
+
mkcol '/hi' do
|
|
23
|
+
"Hello, this is MKCOL verb"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
hello '/hi' do
|
|
27
|
+
"Hello, this is HELLO verb"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
run!
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
### Classic
|
|
34
|
+
|
|
35
|
+
require 'sinatra'
|
|
36
|
+
require 'sinatra/verbs'
|
|
37
|
+
|
|
38
|
+
Sinatra::Verbs.custom :mkcol, :hello
|
|
39
|
+
|
|
40
|
+
mkcol '/hi' do
|
|
41
|
+
"Hello, this is MKCOL verb"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
hello '/hi' do
|
|
45
|
+
"Hello, this is HELLO verb"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
## Lightning-fast testing
|
|
49
|
+
|
|
50
|
+
Write one of the previous examples to a file, say: test-sinatra-verbs.rb
|
|
51
|
+
|
|
52
|
+
ruby test-sinatra-verbs.rb
|
|
53
|
+
|
|
54
|
+
Now let's start a telnet session:
|
|
55
|
+
|
|
56
|
+
telnet localhost 4567
|
|
57
|
+
> HELLO /hi HTTP/1.1<ENTER>
|
|
58
|
+
> <ENTER>
|
|
59
|
+
|
|
60
|
+
< HTTP/1.1 200 OK
|
|
61
|
+
< Content-Type: text/html;charset=utf-8
|
|
62
|
+
< Content-Length: 25
|
|
63
|
+
< Server: WEBrick/1.3.1 (Ruby/1.9.2/2010-12-25)
|
|
64
|
+
< Date: Sat, 22 Jan 2011 01:39:58 GMT
|
|
65
|
+
< Connection: Keep-Alive
|
|
66
|
+
<
|
|
67
|
+
< Hello, this is HELLO verb
|
data/Rakefile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Sinatra
|
|
2
|
+
module Verbs
|
|
3
|
+
# Defines custom HTTP verbs.
|
|
4
|
+
#
|
|
5
|
+
# This method exposes enough API to use this custom verbs in both Sinatra styles: the classic one,
|
|
6
|
+
# and inheriting Sinatra::Base. You work with them as if they were regular HTTP verbs.
|
|
7
|
+
def self.custom(*verbs)
|
|
8
|
+
verbs.each do |verb_name|
|
|
9
|
+
::Sinatra::Delegator.module_eval <<-RUBY
|
|
10
|
+
def #{verb_name}(*args, &b)
|
|
11
|
+
::Sinatra::Application.send(#{verb_name.inspect}, *args, &b)
|
|
12
|
+
end
|
|
13
|
+
private #{verb_name.inspect}
|
|
14
|
+
RUBY
|
|
15
|
+
::Sinatra::Base.module_eval <<-RUBY
|
|
16
|
+
def self.#{verb_name}(path, opts={}, &bk); route '#{verb_name.to_s.upcase}', path, opts, &bk end
|
|
17
|
+
RUBY
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |s|
|
|
5
|
+
s.name = "sinatra-verbs"
|
|
6
|
+
s.version = "0.0.6"
|
|
7
|
+
s.platform = Gem::Platform::RUBY
|
|
8
|
+
s.authors = ["Rafael Fernández López"]
|
|
9
|
+
s.email = ["ereslibre@gmail.com"]
|
|
10
|
+
s.homepage = "http://www.ereslibre.es"
|
|
11
|
+
s.summary = %q{Sinatra extension that allows you to add your own HTTP verbs}
|
|
12
|
+
s.description = %q{Sinatra extension that allows you to add your own HTTP verbs}
|
|
13
|
+
s.rubyforge_project = "sinatra-verbs"
|
|
14
|
+
s.add_runtime_dependency 'sinatra', '>= 1.0.0'
|
|
15
|
+
s.files = `git ls-files`.split("\n")
|
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
18
|
+
s.has_rdoc = true
|
|
19
|
+
s.require_paths = ["lib"]
|
|
20
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: sinatra-verbs
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
prerelease: false
|
|
5
|
+
segments:
|
|
6
|
+
- 0
|
|
7
|
+
- 0
|
|
8
|
+
- 6
|
|
9
|
+
version: 0.0.6
|
|
10
|
+
platform: ruby
|
|
11
|
+
authors:
|
|
12
|
+
- "Rafael Fern\xC3\xA1ndez L\xC3\xB3pez"
|
|
13
|
+
autorequire:
|
|
14
|
+
bindir: bin
|
|
15
|
+
cert_chain: []
|
|
16
|
+
|
|
17
|
+
date: 2011-01-22 00:00:00 +01:00
|
|
18
|
+
default_executable:
|
|
19
|
+
dependencies:
|
|
20
|
+
- !ruby/object:Gem::Dependency
|
|
21
|
+
name: sinatra
|
|
22
|
+
prerelease: false
|
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
24
|
+
none: false
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
segments:
|
|
29
|
+
- 1
|
|
30
|
+
- 0
|
|
31
|
+
- 0
|
|
32
|
+
version: 1.0.0
|
|
33
|
+
type: :runtime
|
|
34
|
+
version_requirements: *id001
|
|
35
|
+
description: Sinatra extension that allows you to add your own HTTP verbs
|
|
36
|
+
email:
|
|
37
|
+
- ereslibre@gmail.com
|
|
38
|
+
executables: []
|
|
39
|
+
|
|
40
|
+
extensions: []
|
|
41
|
+
|
|
42
|
+
extra_rdoc_files: []
|
|
43
|
+
|
|
44
|
+
files:
|
|
45
|
+
- .gitignore
|
|
46
|
+
- Gemfile
|
|
47
|
+
- LICENSE
|
|
48
|
+
- README.markdown
|
|
49
|
+
- Rakefile
|
|
50
|
+
- lib/sinatra/verbs.rb
|
|
51
|
+
- sinatra-verbs.gemspec
|
|
52
|
+
has_rdoc: true
|
|
53
|
+
homepage: http://www.ereslibre.es
|
|
54
|
+
licenses: []
|
|
55
|
+
|
|
56
|
+
post_install_message:
|
|
57
|
+
rdoc_options: []
|
|
58
|
+
|
|
59
|
+
require_paths:
|
|
60
|
+
- lib
|
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
|
+
none: false
|
|
63
|
+
requirements:
|
|
64
|
+
- - ">="
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
segments:
|
|
67
|
+
- 0
|
|
68
|
+
version: "0"
|
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
|
+
none: false
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
segments:
|
|
75
|
+
- 0
|
|
76
|
+
version: "0"
|
|
77
|
+
requirements: []
|
|
78
|
+
|
|
79
|
+
rubyforge_project: sinatra-verbs
|
|
80
|
+
rubygems_version: 1.3.7
|
|
81
|
+
signing_key:
|
|
82
|
+
specification_version: 3
|
|
83
|
+
summary: Sinatra extension that allows you to add your own HTTP verbs
|
|
84
|
+
test_files: []
|
|
85
|
+
|