patchbay 0.0.1.pre3 → 0.0.1.pre4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/patchbay.rb +26 -14
- metadata +27 -59
data/lib/patchbay.rb
CHANGED
@@ -1,9 +1,22 @@
|
|
1
1
|
require 'rack/mime'
|
2
2
|
require 'rack/handler'
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
module PatchbayHelpers
|
5
|
+
def incoming_json
|
6
|
+
unless params[:incoming_json]
|
7
|
+
inp = environment['rack.input']
|
8
|
+
inp.rewind
|
9
|
+
params[:incoming_json] = JSON.parse inp.read
|
10
|
+
end
|
11
|
+
|
12
|
+
params[:incoming_json]
|
6
13
|
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# The main Patchbay class, from which application classes derive.
|
17
|
+
class Patchbay
|
18
|
+
|
19
|
+
include PatchbayHelpers
|
7
20
|
|
8
21
|
NoRoute_Message = <<EOT
|
9
22
|
<html><body>
|
@@ -29,23 +42,20 @@ private
|
|
29
42
|
# Checks if the `path_to_test` falls within the `root_path`.
|
30
43
|
# This can be used to test for directory-traversal attacks.
|
31
44
|
#
|
32
|
-
#
|
33
|
-
# path_to_test
|
34
|
-
#
|
35
|
-
#
|
36
|
-
# root_path::
|
37
|
-
# A path that `path_to_test` will be checked against.
|
38
|
-
#
|
39
|
-
# == Returns:
|
40
|
-
# `true` if `path_to_test` resides within `root_path`.
|
41
|
-
# `false` otherwise.
|
42
|
-
#
|
45
|
+
# @param [String] path_to_test A path which is to be checked against the root path.
|
46
|
+
# @param [String] root_path A path that `path_to_test` will be checked against.
|
47
|
+
# @return [Boolean] True if the `path_to_test` is within the `root_path`, false otherwise.
|
43
48
|
def path_is_subdir_of(path_to_test, root_path)
|
44
49
|
File.fnmatch(File.join(root_path, '**'), File.realpath(path_to_test))
|
45
50
|
end
|
46
51
|
|
47
52
|
# Parses URLs and matches them to handlers.
|
53
|
+
#
|
48
54
|
class Router
|
55
|
+
# Wrap up data associated with a route.
|
56
|
+
class Route < Struct.new(:handler, :url_parts, :verb)
|
57
|
+
end
|
58
|
+
|
49
59
|
def initialize
|
50
60
|
@routes = []
|
51
61
|
end
|
@@ -219,7 +229,7 @@ public
|
|
219
229
|
self.class.files_dir
|
220
230
|
end
|
221
231
|
|
222
|
-
|
232
|
+
public
|
223
233
|
# Get the Rack environment corresponding to the current request.
|
224
234
|
#
|
225
235
|
# == Returns:
|
@@ -238,6 +248,7 @@ private
|
|
238
248
|
@params
|
239
249
|
end
|
240
250
|
|
251
|
+
private
|
241
252
|
# Handle requests that match no route, when we have a public files directory.
|
242
253
|
# Sets up the response appropriately for that case.
|
243
254
|
#
|
@@ -378,3 +389,4 @@ private
|
|
378
389
|
end
|
379
390
|
end
|
380
391
|
end
|
392
|
+
|
metadata
CHANGED
@@ -1,89 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: patchbay
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.pre4
|
5
5
|
prerelease: 6
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
- pre
|
11
|
-
- 3
|
12
|
-
version: 0.0.1.pre3
|
13
6
|
platform: ruby
|
14
|
-
authors:
|
7
|
+
authors:
|
15
8
|
- Andrew Armenia
|
16
9
|
autorequire:
|
17
10
|
bindir: bin
|
18
11
|
cert_chain: []
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
dependencies:
|
23
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-09-13 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
24
15
|
name: rack
|
25
|
-
|
26
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &79937490 !ruby/object:Gem::Requirement
|
27
17
|
none: false
|
28
|
-
requirements:
|
29
|
-
- -
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
hash: 27
|
32
|
-
segments:
|
33
|
-
- 1
|
34
|
-
- 3
|
35
|
-
- 0
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
36
21
|
version: 1.3.0
|
37
22
|
type: :runtime
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *79937490
|
25
|
+
description: ! "Patchbay is the web framework for non-web apps. \nIt's designed for
|
26
|
+
simplicity, minimalism, and easy integration.\n"
|
43
27
|
email: andrew@asquaredlabs.com
|
44
28
|
executables: []
|
45
|
-
|
46
29
|
extensions: []
|
47
|
-
|
48
30
|
extra_rdoc_files: []
|
49
|
-
|
50
|
-
files:
|
31
|
+
files:
|
51
32
|
- lib/patchbay.rb
|
52
|
-
has_rdoc: true
|
53
33
|
homepage: http://rubygems.org/gems/patchbay
|
54
34
|
licenses: []
|
55
|
-
|
56
35
|
post_install_message:
|
57
36
|
rdoc_options: []
|
58
|
-
|
59
|
-
require_paths:
|
37
|
+
require_paths:
|
60
38
|
- lib
|
61
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
40
|
none: false
|
63
|
-
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
|
67
|
-
|
68
|
-
- 0
|
69
|
-
version: "0"
|
70
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
46
|
none: false
|
72
|
-
requirements:
|
73
|
-
- -
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
hash: 25
|
76
|
-
segments:
|
77
|
-
- 1
|
78
|
-
- 3
|
79
|
-
- 1
|
47
|
+
requirements:
|
48
|
+
- - ! '>'
|
49
|
+
- !ruby/object:Gem::Version
|
80
50
|
version: 1.3.1
|
81
51
|
requirements: []
|
82
|
-
|
83
52
|
rubyforge_project:
|
84
|
-
rubygems_version: 1.
|
53
|
+
rubygems_version: 1.8.6
|
85
54
|
signing_key:
|
86
55
|
specification_version: 3
|
87
56
|
summary: Embed HTTP APIs in non-web apps easily
|
88
57
|
test_files: []
|
89
|
-
|