wouter 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -5
- data/lib/wouter/route.rb +2 -2
- data/wouter.gemspec +4 -4
- metadata +4 -5
- data/examples/hello.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b29bb82a3cec6a4618458dc39b5efd372e27648b87c33893a4e91b23ab7b016e
|
4
|
+
data.tar.gz: 880aa04c4957d8e616c4ec31887656571283504fc52d8131eaea2285254b5035
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0943f0078e3088c8a2b73fffaeae8f9a367a15aab7f9aad3a67482704b7599b5fa61316bd425ce510ecb37565543661500e2390fb1c27c41717337535b6515a4'
|
7
|
+
data.tar.gz: 7e25c151a9458ec94c6dcfe0089ff4d6cf574d8568745c9e8e0368a82d746efd64124e4db8a08156f1a69d76a51d25f7c7d48c0936907d6d5658ed17674ffe0d
|
data/README.md
CHANGED
@@ -4,24 +4,56 @@ Wouter is a modular web framework built on top of Rack.
|
|
4
4
|
|
5
5
|
Wouter design goals: explicit, modular, readable.
|
6
6
|
|
7
|
-
##
|
7
|
+
## Quick Example
|
8
8
|
|
9
9
|
Wouter allows you to define routes that connect to endpoints.
|
10
10
|
|
11
|
-
Here is an example `rackup` compatible
|
11
|
+
Here is an example `rackup` compatible `config.ru`:
|
12
12
|
|
13
13
|
```ruby
|
14
|
-
require '
|
14
|
+
require 'wouter'
|
15
15
|
|
16
|
-
class HelloWorld <
|
16
|
+
class HelloWorld < Wouter::Endpoint
|
17
17
|
def respond
|
18
18
|
'Hello, world!'
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
class Routes <
|
22
|
+
class Routes < Wouter
|
23
23
|
get '/', HelloWorld
|
24
24
|
end
|
25
25
|
|
26
26
|
run Routes.build
|
27
27
|
```
|
28
|
+
|
29
|
+
Intances of `Wouter::Endpoint` are Rack applications. Instances of `Wouter` are Rack applications. `Wouter` builds routes to dispatch requests to `Wouter::Endpoint` instances.
|
30
|
+
|
31
|
+
An example application can be viewed [here](./test/test_app.rb).
|
32
|
+
|
33
|
+
## Instances of `Wouter`
|
34
|
+
|
35
|
+
When you create an instance of the `Wouter` class, you must call `.build` to create the Rack application.
|
36
|
+
|
37
|
+
### Wouter DSL
|
38
|
+
|
39
|
+
HTTP routes:
|
40
|
+
|
41
|
+
* `get`
|
42
|
+
* `put`
|
43
|
+
* `post`
|
44
|
+
* `delete`
|
45
|
+
|
46
|
+
Rack middleware:
|
47
|
+
|
48
|
+
* `middleware` - add Rack middleware
|
49
|
+
|
50
|
+
## Instaces of `Wouter::Endpoint`
|
51
|
+
|
52
|
+
Instances of `Wouter::Endpoint` have access to a few helper methods.
|
53
|
+
|
54
|
+
* `req` - an instance of `Rack::Request` for the current HTTP request
|
55
|
+
* `res` - an instance of `Rack::Response` for the current HTTP response
|
56
|
+
* `params` - convience method for access to `req.params` and any URL route parameters
|
57
|
+
* `headers` - convience method for getting and setting HTTP headers
|
58
|
+
* `status` - get or set HTTP status code
|
59
|
+
* `not_found` - generates a HTTP 404 Not Found `Rack::Response`
|
data/lib/wouter/route.rb
CHANGED
@@ -42,7 +42,7 @@ class Wouter::Route
|
|
42
42
|
path.scan(/(:\w+)/).flatten.each do |param|
|
43
43
|
string_regex = string_regex.gsub(param, '(?<' + param[1..-1] +'>' + REGEX + ')')
|
44
44
|
end
|
45
|
-
Regexp.new(string_regex)
|
45
|
+
Regexp.new('^' + string_regex + '$')
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -54,7 +54,7 @@ class Wouter::Route
|
|
54
54
|
path.scan(/(:\w+)/).flatten.each do |param|
|
55
55
|
string_regex = string_regex.gsub(param, REGEX)
|
56
56
|
end
|
57
|
-
Regexp.new(string_regex)
|
57
|
+
Regexp.new('^' + string_regex + '$')
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
data/wouter.gemspec
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'wouter'
|
5
5
|
s.platform = Gem::Platform::RUBY
|
6
|
-
s.version = '0.0.
|
7
|
-
s.summary = 'Rack web
|
8
|
-
s.description = 'Wouter is a modular web
|
6
|
+
s.version = '0.0.7'
|
7
|
+
s.summary = 'Rack web framework.'
|
8
|
+
s.description = 'Wouter is a modular web framework built on top of Rack.'
|
9
9
|
s.authors = ['Robert Peterson']
|
10
10
|
s.email = 'robertpeterson@gmail.com'
|
11
|
-
s.files = Dir['lib/**/*'
|
11
|
+
s.files = Dir['lib/**/*'] + ['README.md', 'Gemfile', 'Rakefile', 'wouter.gemspec']
|
12
12
|
s.test_files = s.files.select { |p| p =~ /^test\/.*_test.rb/ }
|
13
13
|
s.license = 'MIT'
|
14
14
|
s.homepage = 'https://github.com/rawburt/wouter'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wouter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Peterson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -150,7 +150,7 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 12.3.1
|
153
|
-
description: Wouter is a modular web
|
153
|
+
description: Wouter is a modular web framework built on top of Rack.
|
154
154
|
email: robertpeterson@gmail.com
|
155
155
|
executables: []
|
156
156
|
extensions: []
|
@@ -159,7 +159,6 @@ files:
|
|
159
159
|
- Gemfile
|
160
160
|
- README.md
|
161
161
|
- Rakefile
|
162
|
-
- examples/hello.rb
|
163
162
|
- lib/wouter.rb
|
164
163
|
- lib/wouter/endpoint.rb
|
165
164
|
- lib/wouter/route.rb
|
@@ -189,5 +188,5 @@ rubyforge_project:
|
|
189
188
|
rubygems_version: 2.7.3
|
190
189
|
signing_key:
|
191
190
|
specification_version: 4
|
192
|
-
summary: Rack web
|
191
|
+
summary: Rack web framework.
|
193
192
|
test_files: []
|