wouter 0.0.6 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 328983ffb5c818d8e95bfd645fa6a4390bc97efee9d3b195d28cd86421b69315
4
- data.tar.gz: '01191a528dab4215b98d03545b863c4cd8c3f0b5be7c0f9f91e97a0bbe300e72'
3
+ metadata.gz: b29bb82a3cec6a4618458dc39b5efd372e27648b87c33893a4e91b23ab7b016e
4
+ data.tar.gz: 880aa04c4957d8e616c4ec31887656571283504fc52d8131eaea2285254b5035
5
5
  SHA512:
6
- metadata.gz: 5e1b52bc209def3b17235c036102d145c1e43ed31deb318288437956307489636573c037342dd064d541c8f59d6343b9d42f363c4e3638e4d36d83e9d2c2c9ea
7
- data.tar.gz: a41ead4e722ebccfd50af05e13571cd880f3f580eec097d89cc992f09376bc6352ab96c1560d85589cb9cd20d1c08d4352c12d98f48146199d65ad14d8a11ae4
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
- ## Basic Usage
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 file:
11
+ Here is an example `rackup` compatible `config.ru`:
12
12
 
13
13
  ```ruby
14
- require 'wouty'
14
+ require 'wouter'
15
15
 
16
- class HelloWorld < Wouty::Endpoint
16
+ class HelloWorld < Wouter::Endpoint
17
17
  def respond
18
18
  'Hello, world!'
19
19
  end
20
20
  end
21
21
 
22
- class Routes < Wouty
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.6'
7
- s.summary = 'Rack web router.'
8
- s.description = 'Wouter is a modular web router built on Rack.'
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/**/*', 'examples/*'] + ['README.md', 'Gemfile', 'Rakefile', 'wouter.gemspec']
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.6
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-17 00:00:00.000000000 Z
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 router built on Rack.
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 router.
191
+ summary: Rack web framework.
193
192
  test_files: []
data/examples/hello.rb DELETED
@@ -1,15 +0,0 @@
1
- # Usage: rackup hello.rb
2
-
3
- require 'wouter'
4
-
5
- class HelloWorld < Wouty::Endpoint
6
- def respond
7
- 'Hello, world!'
8
- end
9
- end
10
-
11
- class Routes < Wouty
12
- get '/', HelloWorld
13
- end
14
-
15
- run Routes.build