soar_sc-rack-router 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: ea1b4cfbce696717b0a1ba75823c3dc7eb1ce77b
4
- data.tar.gz: af2320579e449daa1b2716fbbbb4b7a7b6a15f1c
3
+ metadata.gz: e0d01611a439740ed9559a1a00c73a5641becc7b
4
+ data.tar.gz: 48a48a2e58137330af37778ee387b123e69e590b
5
5
  SHA512:
6
- metadata.gz: 9e412c1fbb014a7743f5950bf9a1aadd03f7b9aff5f827a1cedfd38ed66fa66582a2b67ad204f59991b89092c3e757b05a74b5e06731c92f29a6cafa8a9780f7
7
- data.tar.gz: edb1ecd42f5ec8a6a3699deeaf7516cc306b01a7212a5005289087bc8ab675daa787876e2b6ec5b72532208ae43ede486a328017789536bc9c783e5a8d41b967
6
+ metadata.gz: 9a762f1d8ae8e5a11647b4285ad6021ff280ad9b9b3c7bbaa5bc458951c5948df0e442190d6186640e5d195ffa726a100362f31080a0b55c51052e6a41569912
7
+ data.tar.gz: d10e6b1d19b54fd6fc55d8afb71f01314376986e0e2bc75e75189140f11ba9dea5b0cd48050c50a06b6e20ee46939de829a47740cf941744ea12c366a7ac5537
data/README.md CHANGED
@@ -34,7 +34,7 @@ Or install it yourself as:
34
34
 
35
35
  The following are not examples of sensible ways to structure your router actions. They just demonstrate the SoarSc::Rack::Router API.
36
36
 
37
- An example of a mult-router stack:
37
+ An example of a multi-router stack:
38
38
 
39
39
  ```ruby
40
40
  require 'soar_sc/rack/router'
@@ -51,7 +51,7 @@ stack = Rack::Builder.new do
51
51
  post "/business", ->(env) { ... }
52
52
  end
53
53
 
54
- run ->(env) [404, {'Content-Type' => 'text/plain'}, ['Object Not Found']]
54
+ run ->(env) { [404, {'Content-Type' => 'text/plain'}, ['Object Not Found']] }
55
55
  end
56
56
 
57
57
  run stack
@@ -75,7 +75,7 @@ stack = Rack::Builder.new do
75
75
  run ->(...)
76
76
  end
77
77
 
78
- run ->(env) [404, {'Content-Type' => 'text/plain'}, ['Object Not Found']]
78
+ run ->(env) { [404, {'Content-Type' => 'text/plain'}, ['Object Not Found']] }
79
79
  end
80
80
  end
81
81
  ```
@@ -94,7 +94,7 @@ stack = Rack::Builder.new do
94
94
  end
95
95
  end
96
96
 
97
- run ->(env) [404, {'Content-Type' => 'text/plain'}, ['Object Not Found']]
97
+ run ->(env) { [404, {'Content-Type' => 'text/plain'}, ['Object Not Found']] }
98
98
  end
99
99
 
100
100
  run stack
@@ -8,6 +8,8 @@ module SoarSc
8
8
  end
9
9
  end
10
10
 
11
+ class InvalidParameterError < RuntimeError; end
12
+
11
13
  end
12
14
  end
13
15
  end
@@ -6,6 +6,7 @@ module SoarSc
6
6
  attr_reader :method, :path, :action
7
7
 
8
8
  def initialize(method, path, action)
9
+ validate_path(path)
9
10
  @method, @path, @action = method, path, action
10
11
  end
11
12
 
@@ -43,6 +44,14 @@ module SoarSc
43
44
  path.split('/')
44
45
  end
45
46
 
47
+ def validate_path(path)
48
+ components(path).each do |c|
49
+ if c.start_with?(":") and c !~ /:[a-z_][a-z0-9_]*+/
50
+ raise InvalidParameterError, "Invalid parameter #{c} in path #{path}"
51
+ end
52
+ end
53
+ end
54
+
46
55
  end
47
56
 
48
57
  end
@@ -1,7 +1,7 @@
1
1
  module SoarSc
2
2
  module Rack
3
3
  class Router
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soar_sc-rack-router
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sheldon Hearn