app-routes 0.1.16 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/app-routes.rb +29 -10
- metadata +22 -20
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 263ef4b0b1ec428769f8522b2d7d7ac47717a11a
|
4
|
+
data.tar.gz: be92747bc18486819eb734c0bbfdad5e5c3de7e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0ac549510f98d476e71ec029d1d2a1affa4839d033eb705124205a1d18d79c9b442c03c03f7c12c81d7ac00d68b012854f2454749fed788237686c74085fc1d
|
7
|
+
data.tar.gz: 42585afdab950e182eba995048f59a2292555ae4a3d8dfbaa85568ea055628680955aaeb0b54af1db24c9b5a59c69c81562497e3ced2e798a8580d70983291bf
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/app-routes.rb
CHANGED
@@ -2,24 +2,28 @@
|
|
2
2
|
|
3
3
|
# file: app-routes.rb
|
4
4
|
|
5
|
+
|
5
6
|
module AppRoutes
|
6
7
|
|
7
8
|
attr_accessor :routes
|
8
9
|
|
9
10
|
def initialize(logfile='/tmp/app-routes.log')
|
10
|
-
@
|
11
|
+
@get_routes, @post_routes = {}, {}
|
11
12
|
@params = {}
|
12
13
|
end
|
13
14
|
|
14
|
-
def run_route(request)
|
15
|
+
def run_route(request, request_method='GET')
|
15
16
|
|
16
17
|
result = nil
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
return unless routes
|
19
|
+
return unless @get_routes or @post_routes
|
21
20
|
|
22
|
-
route
|
21
|
+
route, routes = case request_method
|
22
|
+
when 'GET'
|
23
|
+
[@get_routes.detect {|key, block| request.match(key) }, @get_routes]
|
24
|
+
when 'POST'
|
25
|
+
[@post_routes.detect {|key, block| request.match(key) }, @post_routes]
|
26
|
+
end
|
23
27
|
|
24
28
|
if route then
|
25
29
|
key, block = route
|
@@ -54,19 +58,34 @@ module AppRoutes
|
|
54
58
|
send (methodx[arg.class.to_s.to_sym]), arg, &block
|
55
59
|
end
|
56
60
|
|
57
|
-
def
|
58
|
-
|
61
|
+
def post(arg,&block)
|
62
|
+
methodx = {String: :string_post, Regexp: :regex_post}
|
63
|
+
send (methodx[arg.class.to_s.to_sym]), arg, &block
|
64
|
+
end
|
65
|
+
|
66
|
+
def add_route(arg, request_method='GET')
|
67
|
+
name = request_method == 'GET' ? :get : :post
|
68
|
+
method(name).call(arg) {yield(@params)}
|
59
69
|
end
|
60
70
|
|
61
71
|
private
|
62
72
|
|
63
73
|
def string_get(raw_s, &block)
|
64
74
|
s = "^%s$" % raw_s.gsub(/\:[\w-]+/,'([\w-]+)').gsub(/\/\*/,'(.*)')
|
65
|
-
@
|
75
|
+
@get_routes[Regexp.new s] = {s: raw_s, block: block}
|
66
76
|
end
|
67
77
|
|
68
78
|
def regex_get(r, &block)
|
69
|
-
@
|
79
|
+
@get_routes[r] = {block: block}
|
80
|
+
end
|
81
|
+
|
82
|
+
def string_post(raw_s, &block)
|
83
|
+
s = "^%s$" % raw_s.gsub(/\:[\w-]+/,'([\w-]+)').gsub(/\/\*/,'(.*)')
|
84
|
+
@post_routes[Regexp.new s] = {s: raw_s, block: block}
|
85
|
+
end
|
86
|
+
|
87
|
+
def regex_post(r, &block)
|
88
|
+
@post_routes[r] = {block: block}
|
70
89
|
end
|
71
90
|
|
72
91
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: app-routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,26 +10,28 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
|
14
14
|
YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
|
15
|
-
|
15
|
+
8ixkARkWAmV1MB4XDTE0MDIxNTE4Mzg0NloXDTE1MDIxNTE4Mzg0NlowSDESMBAG
|
16
16
|
A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
|
17
17
|
EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
18
|
+
ggEBALrUXRATuMounNxJuY2KPEhkbaQh89V4UdWQsuMHj+oNF9Fsj9Lbf4FejLgE
|
19
|
+
eHh1A8jxgBr0nUaBTLLX9Y6iSHG0bo/COkxsMSxJIwfBeMw3+kLtvhp2UGtytc0w
|
20
|
+
cxLTEuzORekzhou1u9oXkCI+CPZrQrsS9nZmLI61/M0NlfwmrPIwpBy1a4MhV8U0
|
21
|
+
1ZSxANJz5lpXO40K2mV6FcsE4RhW+FkKVAf954H3kWMYoNUqsBXejdfEjgq62ysO
|
22
|
+
YEb1nH9Ft7iDEzPUyQYaZWRg63OreK6SDEk+54FQ7eezpND+or99NYPDwM2phL1/
|
23
|
+
CEAJPie1w9Tuq6R/P0fYIyNPtCMCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
|
24
|
+
DwQEAwIEsDAdBgNVHQ4EFgQUfNuNBhLNX8uqqhpiAUApvq1buS4wJgYDVR0RBB8w
|
25
|
+
HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
|
26
|
+
c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAihk9LVVY
|
27
|
+
2pJCTT00S36cY/anAcw8AskBP1GiSk+rfSv9M7RM+/GgDPvNcgqkpds8cfafLgIg
|
28
|
+
D8tWOQLxm+5LqfFUz0pbTfjtHOzR0JXnDCf+M0jWuRUbK7mRXX3cZvjIPEVRgVVp
|
29
|
+
fH5tfdWrh9D6a+6wfvvr929YD7F7Lo3nBOSj8/qVqE28VpyKokKjxFR8MxX7ehzE
|
30
|
+
a/xE/A22dA/MdKgU9SBqsS7NWy4DQg1Qq+gYikuR1O9lozYEDUvyNSgZvU9UK6PX
|
31
|
+
CZGra4Y0S+K0fINIK2l1MYyjxOsO6VCvVCdUf17d5L2tMEIeJfzPaqOldIR0lA40
|
32
|
+
kANeVHhqH+wo9g==
|
31
33
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
34
|
+
date: 2014-02-15 00:00:00.000000000 Z
|
33
35
|
dependencies: []
|
34
36
|
description:
|
35
37
|
email: james@r0bertson.co.uk
|
@@ -48,17 +50,17 @@ require_paths:
|
|
48
50
|
- lib
|
49
51
|
required_ruby_version: !ruby/object:Gem::Requirement
|
50
52
|
requirements:
|
51
|
-
- -
|
53
|
+
- - '>='
|
52
54
|
- !ruby/object:Gem::Version
|
53
55
|
version: '0'
|
54
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
57
|
requirements:
|
56
|
-
- -
|
58
|
+
- - '>='
|
57
59
|
- !ruby/object:Gem::Version
|
58
60
|
version: '0'
|
59
61
|
requirements: []
|
60
62
|
rubyforge_project:
|
61
|
-
rubygems_version: 2.0.
|
63
|
+
rubygems_version: 2.0.14
|
62
64
|
signing_key:
|
63
65
|
specification_version: 4
|
64
66
|
summary: app-routes
|
metadata.gz.sig
CHANGED
Binary file
|