diff --git a/.yardoc/checksums b/.yardoc/checksums index 5ce3526..59aa550 100644 --- a/.yardoc/checksums +++ b/.yardoc/checksums @@ -1,21 +1,28 @@ -lib/hyde.rb 775368f05e89c7396fdf9a9c1f55e3537f8fba98 +lib/hyde.rb 632d043ed6e7484bca963c37e1629e1d88c89b69 lib/hyde/node.rb 93d92492390abb2b55649c6d027fa3a2cb8f2014 -lib/hyde/path.rb 280170523467824ac6ce310500fc88439808d59e -lib/hyde/probe.rb 994a5527bb30c713c1c70e56195ea6967ae39241 -lib/hyde/server.rb 3286219acc8606b432d12545e9ba3a57dd227473 -lib/hyde/request.rb 9baea24ae9975e3a26571878ed7e9da99889584f +lib/hyde/path.rb 42c04e42ea879ad73f639f2086b3ab5ca40489dc +lib/hyde/probe.rb 673b55e9aa8c8286a770bd23ae00bff1ac2047fe +lib/hyde/server.rb 6f15f6c8e67783086bfe70ad03c7ca9b8269c69d +lib/hyde/request.rb 792427908273455eb694e13d3517cdae43af3454 lib/hyde/response.rb 0f0c107c7db883b308b81cbf5c0c4b7d5c90e7ba -lib/hyde/util/html.rb 3767a1632026ba555ae5517b59728b2e916b61de -lib/hyde/util/query.rb ffa6f9b6631277d7061f63dd36e4cb431a8169f5 +lib/hyde/template.rb f3ac5033c5cdb9218b1865b5c9662ba50b813a70 +lib/hyde/util/html.rb bb83ec3ad162b8702ae054428f33c7d8a041d816 +lib/hyde/util/query.rb 212e9bd776eac429c2b2a821586ccce97f996df9 +lib/hyde/util/header.rb ce82b5351a857860b105f25d68ca66c0193359ce lib/hyde/util/lookup.rb 5b8e28a8471bb786f4e0a0d616885d238c806661 -lib/hyde/probe/binding.rb 1a83cfea5e7b620d075798c920dd4af3335871c7 -lib/hyde/probe/handler.rb 4d45e895a3bfee8e5234be3862c7e201772731b1 -lib/hyde/dsl/path_methods.rb 0369e370c594f0bd5c987c67791175eeaa8f9c21 +lib/hyde/template/erb.rb 4d1c85dd55b55030bba1ba4f9c27ea39fd0c1e47 +lib/hyde/util/sorting.rb af30f01ce32880f7e3e2b0ad6c2324c2fded9431 +lib/hyde/probe/handler.rb 9b3eb4ce702c40920c04ed0cb3b93984683de447 +lib/hyde/util/multipart.rb 37abad9fbe044855d02d36185be645f07cb417c0 +lib/hyde/dsl/methods_path.rb 0369e370c594f0bd5c987c67791175eeaa8f9c21 lib/hyde/pattern_matching.rb fe86f6529a2d22c128d9d3a74217862e9fa59c15 -lib/hyde/dsl/probe_methods.rb a9dd3ddbdf89875d79d5ca3e56fd3a261546dd25 -lib/hyde/probe/http_method.rb f5f6874998e4a581cd3673a06f3536c8a14e67c8 -lib/hyde/probe/serve_handler.rb 1690e7dd3f0abe9180a61d474bb89c0a765fc381 -lib/hyde/dsl/path_constructors.rb 97895412fc27eeb7f3fa379a85972c97a24d97bf +lib/hyde/dsl/methods_probe.rb c18bb7f712f14e4d08416f77969eb0af07a4f3a7 +lib/hyde/probe/http_method.rb 26ba5c9dabff5508dbd6efcba1711d6417cf957b +lib/hyde/dsl/methods_common.rb ea06161f4324127fbbacd51918eadc4e059e4fcf +lib/hyde/probe/serve_handler.rb 6c1d2a7b949700468342ced4c23c7fe60df4d3f0 +lib/hyde/dsl/methods_template.rb c77827f2a4133142b7f9f9dfe0bb49efb3b23d44 +lib/hyde/dsl/constructors_path.rb d9fafcfae4d6aab9bd85a7de955eb74f8d4d5937 lib/hyde/pattern_matching/glob.rb 16595083bc8d6f7b98f4adda502a05bd411bc1ca lib/hyde/pattern_matching/util.rb 188dc7d5d9a9a6538a01943a83eb132c385dc092 +lib/hyde/dsl/constructors_probe.rb 6295d25bfa4e896b122590e79e57a03111ed2f09 lib/hyde/pattern_matching/rematch.rb 54a4f94791e68d85c38034d954e4c3174e01511b diff --git a/.yardoc/object_types b/.yardoc/object_types index e2ba358..43429da 100644 Binary files a/.yardoc/object_types and b/.yardoc/object_types differ diff --git a/.yardoc/objects/root.dat b/.yardoc/objects/root.dat index eb76e34..0fdf97b 100644 Binary files a/.yardoc/objects/root.dat and b/.yardoc/objects/root.dat differ diff --git a/.yardopts b/.yardopts new file mode 100644 index 0000000..191a6de --- /dev/null +++ b/.yardopts @@ -0,0 +1 @@ +--markup=markdown --markup-provider=redcarpet diff --git a/README.md b/README.md index 0a82c81..d17b1f5 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ app = Hyde::Server.new do end get "answer" do header "content-type", "application/json" - '{"answer":42, "desc":"something important!"}' + '\\{"answer":42, "desc":"something important!"\\}' end end end diff --git a/doc/Hyde.html b/doc/Hyde.html index 21d25e5..80854e5 100644 --- a/doc/Hyde.html +++ b/doc/Hyde.html @@ -79,7 +79,7 @@
Defined in:
lib/hyde.rb,
- lib/hyde/node.rb,
lib/hyde/path.rb,
lib/hyde/probe.rb,
lib/hyde/server.rb,
lib/hyde/request.rb,
lib/hyde/response.rb,
lib/hyde/util/html.rb,
lib/hyde/util/query.rb,
lib/hyde/util/lookup.rb,
lib/hyde/probe/binding.rb,
lib/hyde/probe/handler.rb,
lib/hyde/dsl/path_methods.rb,
lib/hyde/pattern_matching.rb,
lib/hyde/dsl/probe_methods.rb,
lib/hyde/probe/http_method.rb,
lib/hyde/probe/serve_handler.rb,
lib/hyde/dsl/path_constructors.rb,
lib/hyde/pattern_matching/glob.rb,
lib/hyde/pattern_matching/util.rb,
lib/hyde/pattern_matching/rematch.rb
+ lib/hyde/node.rb,
lib/hyde/path.rb,
lib/hyde/probe.rb,
lib/hyde/server.rb,
lib/hyde/request.rb,
lib/hyde/response.rb,
lib/hyde/template.rb,
lib/hyde/util/html.rb,
lib/hyde/util/query.rb,
lib/hyde/util/header.rb,
lib/hyde/util/lookup.rb,
lib/hyde/template/erb.rb,
lib/hyde/util/sorting.rb,
lib/hyde/probe/handler.rb,
lib/hyde/util/multipart.rb,
lib/hyde/dsl/methods_path.rb,
lib/hyde/pattern_matching.rb,
lib/hyde/dsl/methods_probe.rb,
lib/hyde/probe/http_method.rb,
lib/hyde/dsl/methods_common.rb,
lib/hyde/probe/serve_handler.rb,
lib/hyde/dsl/methods_template.rb,
lib/hyde/dsl/constructors_path.rb,
lib/hyde/pattern_matching/glob.rb,
lib/hyde/pattern_matching/util.rb,
lib/hyde/dsl/constructors_probe.rb,
lib/hyde/pattern_matching/rematch.rb
@@ -87,8 +87,7 @@

Overview

- -

Hyde is a hideously simple ruby web framework

+

Hyde is a hideously simple ruby web framework

@@ -100,11 +99,11 @@

- Modules: DSL, PatternMatching, Util + Modules: DSL, Handlers, PatternMatching, Templates, Util - Classes: CONNECTHandler, DELETEHandler, GETHandler, HEADHandler, Handler, Node, OPTIONSHandler, PATCHHandler, POSTHandler, PUTHandler, Path, PathBinding, Pattern, Probe, ProbeBinding, Request, Response, ServeHandler, Server, ServerBinding, TRACEHandler + Classes: Node, Path, PathContext, Pattern, Probe, ProbeContext, ProcessorContext, Request, Response, Server, ServerContext, Template, TemplateContext

@@ -120,8 +119,7 @@
VERSION =
- -

Hyde version

+

Hyde version

@@ -136,8 +134,7 @@
VLINE =
- -

Hyde branding and version

+

Hyde branding and version

@@ -152,8 +149,7 @@
diff --git a/doc/Hyde/DELETEHandler.html b/doc/Hyde/DELETEHandler.html index 98b97d2..3dc250b 100644 --- a/doc/Hyde/DELETEHandler.html +++ b/doc/Hyde/DELETEHandler.html @@ -211,7 +211,7 @@ diff --git a/doc/Hyde/DSL.html b/doc/Hyde/DSL.html index 1279e94..c54c1a2 100644 --- a/doc/Hyde/DSL.html +++ b/doc/Hyde/DSL.html @@ -78,8 +78,8 @@
Defined in:
-
lib/hyde/dsl/path_methods.rb,
- lib/hyde/dsl/probe_methods.rb,
lib/hyde/dsl/path_constructors.rb
+
lib/hyde/dsl/methods_path.rb,
+ lib/hyde/dsl/methods_probe.rb,
lib/hyde/dsl/methods_common.rb,
lib/hyde/dsl/methods_template.rb,
lib/hyde/dsl/constructors_path.rb,
lib/hyde/dsl/constructors_probe.rb
@@ -87,8 +87,7 @@

Overview

- -

Shared DSL methods

+

Shared DSL methods

@@ -100,7 +99,7 @@

- Modules: PathConstructors, PathMethods, ProbeMethods + Modules: CommonMethods, PathConstructors, PathMethods, ProbeConstructors, ProbeMethods, TemplateMethods @@ -118,7 +117,7 @@

diff --git a/doc/Hyde/DSL/CommonMethods.html b/doc/Hyde/DSL/CommonMethods.html new file mode 100644 index 0000000..cce4dc4 --- /dev/null +++ b/doc/Hyde/DSL/CommonMethods.html @@ -0,0 +1,337 @@ + + + + + + + Module: Hyde::DSL::CommonMethods + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Hyde::DSL::CommonMethods + + + +

+
+ + + + + + + + + +
+
Included in:
+
ProbeContext, ProcessorContext, TemplateContext
+
+ + + +
+
Defined in:
+
lib/hyde/dsl/methods_common.rb
+
+ +
+ +

Overview

+
+

Methods shared by probes, preprocessors and filters.

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #bounceObject + + + + + +

+
+

Bounce request to the next handler

+ + +
+
+
+ +

Raises:

+
    + +
  • + + + (UncaughtThrowError) + + + + — +

    throws :break to get out of the callback

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+23
+24
+25
+
+
# File 'lib/hyde/dsl/methods_common.rb', line 23
+
+def bounce
+  throw :break
+end
+
+
+ +
+

+ + #die(errorcode, backtrace: nil) ⇒ Object + + + + + +

+
+

Stop execution and generate a boilerplate response with the given code

+ + +
+
+
+

Parameters:

+
    + +
  • + + errorcode + + + (Integer) + + + +
  • + +
  • + + backtrace + + + (Array(String), nil) + + + (defaults to: nil) + + +
  • + +
+ +

Raises:

+
    + +
  • + + + (UncaughtThrowError) + + + + — +

    throws :finish to return back to Server

    +
    + +
  • + +
+ +
+ + + + +
+
+
+
+11
+12
+13
+14
+15
+16
+17
+18
+19
+
+
# File 'lib/hyde/dsl/methods_common.rb', line 11
+
+def die(errorcode, backtrace: nil)
+  throw :finish, [errorcode].append(
+    *(@origin.properties["handle.#{errorcode}"] or
+      @origin.properties["handle.default"]).call(
+        errorcode,
+        backtrace: backtrace
+      )
+  )
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/doc/Hyde/DSL/PathConstructors.html b/doc/Hyde/DSL/PathConstructors.html index 83472b8..8d8d9a0 100644 --- a/doc/Hyde/DSL/PathConstructors.html +++ b/doc/Hyde/DSL/PathConstructors.html @@ -76,22 +76,21 @@
Included in:
-
PathBinding
+
PathContext
Defined in:
-
lib/hyde/dsl/path_constructors.rb
+
lib/hyde/dsl/constructors_path.rb

Overview

- -

Path (and subclasses) DSL constructors

+

Path (and subclasses) DSL constructors

@@ -131,8 +130,7 @@ -
-

Create a new CONNECTHandler object.

+

Create a new Handlers::CONNECTHandler object.

@@ -155,8 +153,7 @@ -
-

Create a new Hyde::DELETEHandler object.

+

Create a new Handlers::DELETEHandler object.

@@ -179,8 +176,7 @@ -
-

Create a new GETHandler object.

+

Create a new Handlers::GETHandler object.

@@ -203,8 +199,7 @@ -
-

Create a new HEADHandler object.

+

Create a new Handlers::HEADHandler object.

@@ -227,8 +222,7 @@ -
-

Create a new OPTIONSHandler object.

+

Create a new Handlers::OPTIONSHandler object.

@@ -251,8 +245,7 @@ -
-

Create a new PATCHHandler object.

+

Create a new Handlers::PATCHHandler object.

@@ -275,8 +268,7 @@ -
-

Create a new Path object.

+

Create a new Path object.

@@ -299,8 +291,7 @@ -
-

create a new POSTHandler object.

+

create a new Handlers::POSTHandler object.

@@ -323,8 +314,7 @@ -
-

Create a new Probe object.

+

Create a new Handlers::Probe object.

@@ -347,8 +337,7 @@ -
-

Create a new PUTHandler object.

+

Create a new Handlers::PUTHandler object.

@@ -371,8 +360,7 @@ -
-

Append a Node child object to the list of children.

+

Append a Node child object to the list of children.

@@ -395,8 +383,7 @@ -
-

Create a new GETHandler that serves static files.

+

Create a new Handlers::GETHandler that serves static files.

@@ -419,8 +406,7 @@ -
-

Create a new TRACEHandler object.

+

Create a new Handlers::TRACEHandler object.

@@ -446,8 +432,7 @@
- -

Create a new CONNECTHandler object

+

Create a new Handlers::CONNECTHandler object

@@ -461,15 +446,15 @@
 
 
-55
-56
-57
+53 +54 +55 -
# File 'lib/hyde/dsl/path_constructors.rb', line 55
+      
# File 'lib/hyde/dsl/constructors_path.rb', line 53
 
 def connect(path, &setup)
-  register(Hyde::CONNECTHandler.new(path, parent: @origin, &setup))
+  register(Hyde::Handlers::CONNECT.new(path, parent: @origin, &setup))
 end
@@ -487,8 +472,7 @@
- -

Create a new Hyde::DELETEHandler object

+

Create a new Handlers::DELETEHandler object

@@ -502,15 +486,15 @@
 
 
-50
-51
-52
+48 +49 +50
-
# File 'lib/hyde/dsl/path_constructors.rb', line 50
+      
# File 'lib/hyde/dsl/constructors_path.rb', line 48
 
 def delete(path, &setup)
-  register(Hyde::DELETEHandler.new(path, parent: @origin, &setup))
+  register(Hyde::Handlers::DELETE.new(path, parent: @origin, &setup))
 end
@@ -528,8 +512,7 @@
- -

Create a new GETHandler object

+

Create a new Handlers::GETHandler object

@@ -543,15 +526,15 @@
 
 
-30
-31
-32
+28 +29 +30
-
# File 'lib/hyde/dsl/path_constructors.rb', line 30
+      
# File 'lib/hyde/dsl/constructors_path.rb', line 28
 
 def get(path, &setup)
-  register(Hyde::GETHandler.new(path, parent: @origin, &setup))
+  register(Hyde::Handlers::GET.new(path, parent: @origin, &setup))
 end
@@ -569,8 +552,7 @@
- -

Create a new HEADHandler object

+

Create a new Handlers::HEADHandler object

@@ -584,15 +566,15 @@
 
 
-45
-46
-47
+43 +44 +45
-
# File 'lib/hyde/dsl/path_constructors.rb', line 45
+      
# File 'lib/hyde/dsl/constructors_path.rb', line 43
 
 def head(path, &setup)
-  register(Hyde::HEADHandler.new(path, parent: @origin, &setup))
+  register(Hyde::Handlers::HEAD.new(path, parent: @origin, &setup))
 end
@@ -610,8 +592,7 @@
- -

Create a new OPTIONSHandler object

+

Create a new Handlers::OPTIONSHandler object

@@ -625,15 +606,15 @@
 
 
-70
-71
-72
+68 +69 +70
-
# File 'lib/hyde/dsl/path_constructors.rb', line 70
+      
# File 'lib/hyde/dsl/constructors_path.rb', line 68
 
 def options(path, &setup)
-  register(Hyde::OPTIONSHandler.new(path, parent: @origin, &setup))
+  register(Hyde::Handlers::OPTIONS.new(path, parent: @origin, &setup))
 end
@@ -651,8 +632,7 @@
- -

Create a new PATCHHandler object

+

Create a new Handlers::PATCHHandler object

@@ -666,15 +646,15 @@
 
 
-65
-66
-67
+63 +64 +65
-
# File 'lib/hyde/dsl/path_constructors.rb', line 65
+      
# File 'lib/hyde/dsl/constructors_path.rb', line 63
 
 def patch(path, &setup)
-  register(Hyde::PATCHHandler.new(path, parent: @origin, &setup))
+  register(Hyde::Handlers::PATCH.new(path, parent: @origin, &setup))
 end
@@ -692,8 +672,7 @@
- -

Create a new Path object

+

Create a new Path object

@@ -709,17 +688,13 @@ 18 19 -20 -21 -22
+20 -
# File 'lib/hyde/dsl/path_constructors.rb', line 18
+      
# File 'lib/hyde/dsl/constructors_path.rb', line 18
 
 def path(path, &setup)
-  # i don't know WHAT is wrong with this thing. it just is wrong.
-  # @sg-ignore
-  register(Hyde::Path.new(path, parent: @origin, &setup))
+  register(Hyde::Path.new(path, parent: @origin, &setup))
 end
@@ -737,8 +712,7 @@
- -

create a new POSTHandler object

+

create a new Handlers::POSTHandler object

@@ -752,15 +726,15 @@
 
 
-35
-36
-37
+33 +34 +35
-
# File 'lib/hyde/dsl/path_constructors.rb', line 35
+      
# File 'lib/hyde/dsl/constructors_path.rb', line 33
 
 def post(path, &setup)
-  register(Hyde::POSTHandler.new(path, parent: @origin, &setup))
+  register(Hyde::Handlers::POST.new(path, parent: @origin, &setup))
 end
@@ -778,8 +752,7 @@
- -

Create a new Probe object

+

Create a new Handlers::Probe object

@@ -793,15 +766,15 @@
 
 
-25
-26
-27
+23 +24 +25
-
# File 'lib/hyde/dsl/path_constructors.rb', line 25
+      
# File 'lib/hyde/dsl/constructors_path.rb', line 23
 
 def probe(path, &_setup)
-  register(Hyde::Probe.new(path, parent: @origin))
+  register(Hyde::Handlers::Probe.new(path, parent: @origin))
 end
@@ -819,8 +792,7 @@
- -

Create a new PUTHandler object

+

Create a new Handlers::PUTHandler object

@@ -834,15 +806,15 @@
 
 
-40
-41
-42
+38 +39 +40
-
# File 'lib/hyde/dsl/path_constructors.rb', line 40
+      
# File 'lib/hyde/dsl/constructors_path.rb', line 38
 
 def put(path, &setup)
-  register(Hyde::PUTHandler.new(path, parent: @origin, &setup))
+  register(Hyde::Handlers::PUT.new(path, parent: @origin, &setup))
 end
@@ -860,8 +832,7 @@
- -

Append a Node child object to the list of children

+

Append a Node child object to the list of children

@@ -884,7 +855,7 @@ 15
-
# File 'lib/hyde/dsl/path_constructors.rb', line 9
+      
# File 'lib/hyde/dsl/constructors_path.rb', line 9
 
 def register(obj)
   unless obj.is_a? Hyde::Node
@@ -909,8 +880,7 @@
   
 
- -

Create a new GETHandler that serves static files

+

Create a new Handlers::GETHandler that serves static files

@@ -924,15 +894,15 @@
 
 
-75
-76
-77
+73 +74 +75
-
# File 'lib/hyde/dsl/path_constructors.rb', line 75
+      
# File 'lib/hyde/dsl/constructors_path.rb', line 73
 
 def serve(path)
-  register(Hyde::ServeHandler.new(path, parent: @origin))
+  register(Hyde::Handlers::Serve.new(path, parent: @origin))
 end
@@ -950,8 +920,7 @@
- -

Create a new TRACEHandler object

+

Create a new Handlers::TRACEHandler object

@@ -965,15 +934,15 @@
 
 
-60
-61
-62
+58 +59 +60
-
# File 'lib/hyde/dsl/path_constructors.rb', line 60
+      
# File 'lib/hyde/dsl/constructors_path.rb', line 58
 
 def trace(path, &setup)
-  register(Hyde::TRACEHandler.new(path, parent: @origin, &setup))
+  register(Hyde::Handlers::TRACE.new(path, parent: @origin, &setup))
 end
@@ -985,7 +954,7 @@
diff --git a/doc/Hyde/DSL/PathMethods.html b/doc/Hyde/DSL/PathMethods.html index 2aba23c..f644575 100644 --- a/doc/Hyde/DSL/PathMethods.html +++ b/doc/Hyde/DSL/PathMethods.html @@ -76,22 +76,21 @@
Included in:
-
PathBinding
+
PathContext
Defined in:
-
lib/hyde/dsl/path_methods.rb
+
lib/hyde/dsl/methods_path.rb

Overview

- -

Common path methods

+

Common path methods

@@ -131,8 +130,7 @@ -
-

Add a filter to the path.

+

Add a filter to the path.

@@ -155,8 +153,7 @@ -
-

Set path index.

+

Set path index.

@@ -179,8 +176,7 @@ -
-

Add a postprocessor to the path.

+

Add a postprocessor to the path.

@@ -203,8 +199,7 @@ -
-

Add a preprocessor to the path.

+

Add a preprocessor to the path.

@@ -227,8 +222,7 @@ -
-

Set root path (without appending matched part).

+

Set root path (without appending matched part).

@@ -251,8 +245,7 @@ -
-

Set root path (appends matched part of the path).

+

Set root path (appends matched part of the path).

@@ -278,8 +271,8 @@
- -

Add a filter to the path. Blocks path access if a filter returns false.

+

Add a filter to the path. +Blocks path access if a filter returns false.

@@ -329,7 +322,7 @@ 58 -
# File 'lib/hyde/dsl/path_methods.rb', line 55
+      
# File 'lib/hyde/dsl/methods_path.rb', line 55
 
 def filter(&block)
   @origin.filter(&block)
@@ -351,8 +344,7 @@
   
 
- -

Set path index

+

Set path index

@@ -393,7 +385,7 @@ 19
-
# File 'lib/hyde/dsl/path_methods.rb', line 10
+      
# File 'lib/hyde/dsl/methods_path.rb', line 10
 
 def index(index)
   case index
@@ -421,8 +413,7 @@
   
 
- -

Add a postprocessor to the path.

+

Add a postprocessor to the path.

@@ -483,7 +474,7 @@ 49
-
# File 'lib/hyde/dsl/path_methods.rb', line 46
+      
# File 'lib/hyde/dsl/methods_path.rb', line 46
 
 def postprocess(&block)
   @origin.postprocess(&block)
@@ -505,8 +496,8 @@
   
 
- -

Add a preprocessor to the path. Does not modify path execution.

+

Add a preprocessor to the path. +Does not modify path execution.

@@ -556,7 +547,7 @@ 40
-
# File 'lib/hyde/dsl/path_methods.rb', line 37
+      
# File 'lib/hyde/dsl/methods_path.rb', line 37
 
 def preprocess(&block)
   @origin.preprocess(&block)
@@ -578,8 +569,7 @@
   
 
- -

Set root path (without appending matched part).

+

Set root path (without appending matched part).

@@ -598,8 +588,7 @@ — -
-

ath [String

+

ath [String

@@ -618,7 +607,7 @@ 31
-
# File 'lib/hyde/dsl/path_methods.rb', line 29
+      
# File 'lib/hyde/dsl/methods_path.rb', line 29
 
 def remap(path)
   @origin.remap = path
@@ -639,8 +628,7 @@
   
 
- -

Set root path (appends matched part of the path).

+

Set root path (appends matched part of the path).

@@ -659,8 +647,7 @@ — -
-

ath [String

+

ath [String

@@ -679,7 +666,7 @@ 25
-
# File 'lib/hyde/dsl/path_methods.rb', line 23
+      
# File 'lib/hyde/dsl/methods_path.rb', line 23
 
 def root(path)
   @origin.root = path
@@ -694,7 +681,7 @@
 
diff --git a/doc/Hyde/DSL/ProbeConstructors.html b/doc/Hyde/DSL/ProbeConstructors.html new file mode 100644 index 0000000..62bd930 --- /dev/null +++ b/doc/Hyde/DSL/ProbeConstructors.html @@ -0,0 +1,207 @@ + + + + + + + Module: Hyde::DSL::ProbeConstructors + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: Hyde::DSL::ProbeConstructors + + + +

+
+ + + + + + + + + +
+
Included in:
+
ProbeContext, TemplateContext
+
+ + + +
+
Defined in:
+
lib/hyde/dsl/constructors_probe.rb
+
+ +
+ +

Overview

+
+

Probe (and subclasses) DSL construct

+ + +
+
+
+ + +
+ + + + + + + +

+ Instance Method Summary + collapse +

+ + + + + + +
+

Instance Method Details

+ + +
+

+ + #erb(input, toplevel: nil, locals: nil) ⇒ Object + + + + + +

+
+

Create a new erb template

+ + +
+
+
+ + +

See Also:

+
    + +
  • Template#new
  • + +
+ +
+ + + + +
+
+
+
+9
+10
+11
+
+
# File 'lib/hyde/dsl/constructors_probe.rb', line 9
+
+def erb(input, toplevel: nil, locals: nil)
+  Hyde::Templates::ERB.new(input, toplevel: toplevel, locals: locals)
+end
+
+
+ +
+ +
+ + + +
+ + \ No newline at end of file diff --git a/doc/Hyde/DSL/ProbeMethods.html b/doc/Hyde/DSL/ProbeMethods.html index 7d90e6c..319f1c7 100644 --- a/doc/Hyde/DSL/ProbeMethods.html +++ b/doc/Hyde/DSL/ProbeMethods.html @@ -76,22 +76,21 @@
Included in:
-
ProbeBinding
+
ProbeContext, TemplateContext
Defined in:
-
lib/hyde/dsl/probe_methods.rb
+
lib/hyde/dsl/methods_probe.rb

Overview

- -

Common methods for Probe objects

+

Common methods for Probe objects

@@ -117,7 +116,7 @@
  • - #bounce ⇒ Object + #file(path, mode = "r", *all, &block) ⇒ Object @@ -131,8 +130,7 @@ -
    -

    Bounce request to the next handler.

    +

    Open a file relative to current filepath.

  • @@ -141,7 +139,7 @@
  • - #die(errorcode, backtrace: nil) ⇒ Object + #form ⇒ Hash{String=>(String,Hyde::Util::FormPart)} @@ -155,8 +153,30 @@ -
    -

    Stop execution and generate a boilerplate response with the given code.

    +

    Returns formdata.

    +
    + +
  • + + +
  • + + + #form? ⇒ Boolean + + + + + + + + + + + + + +

    Checks if current request has multipart/form-data associated with it.

  • @@ -179,8 +199,7 @@ -
    -

    Set response header (generate response if one doesn’t exist yet).

    +

    Set response header (generate response if one doesn't exist yet).

    @@ -203,8 +222,7 @@ -
    -

    Delete a header value from the headers hash If no value is provided, deletes all key entries.

    +

    Delete a header value from the headers hash If no value is provided, deletes all key entries.

    @@ -227,8 +245,7 @@ -
    -

    Get the current request.

    +

    Get the current request.

    @@ -253,8 +270,7 @@ -
    -

    Set response status (generate response if one doesn’t exist yet).

    +

    Set response status (generate response if one doesn't exist yet).

    @@ -270,9 +286,9 @@
    -

    +

    - #bounceObject + #file(path, mode = "r", *all, &block) ⇒ Object @@ -280,32 +296,20 @@

    - -

    Bounce request to the next handler

    +

    Open a file relative to current filepath

    -

    Raises:

    -
      - -
    • - - - (UncaughtThrowError) - - - - — -
      -

      throws :break to get out of the callback

      -
      - -
    • - -
    + +

    See Also:

    +
      + +
    • File#open
    • + +
    @@ -313,15 +317,15 @@
     
     
    -31
    -32
    -33
    +88 +89 +90 @@ -329,9 +333,9 @@
    -

    +

    - #die(errorcode, backtrace: nil) ⇒ Object + #formHash{String=>(String,Hyde::Util::FormPart)} @@ -339,57 +343,23 @@

    - -

    Stop execution and generate a boilerplate response with the given code

    +

    Returns formdata

    -

    Parameters:

    -
      -
    • - - errorcode - - - (Integer) - - - -
    • - -
    • - - backtrace - - - (Array(String), nil) - - - (defaults to: nil) - - -
    • - -
    - -

    Raises:

    -
      +

      Returns:

      +
      • - (UncaughtThrowError) + (Hash{String=>(String,Hyde::Util::FormPart)}) - — -
        -

        throws :finish to return back to Server

        -
        -
      @@ -400,27 +370,86 @@
       
       
      -19
      -20
      -21
      -22
      -23
      -24
      -25
      -26
      -27
      +79 +80 +81 +82 +83 +84
    + +
    -
    # File 'lib/hyde/dsl/probe_methods.rb', line 31
    +      
    # File 'lib/hyde/dsl/methods_probe.rb', line 88
     
    -def bounce
    -  throw :break
    +def file(path, mode = "r", *all, &block)
    +  File.open("#{request.filepath}/#{path}", mode, *all, &block)
     end
    -
    # File 'lib/hyde/dsl/probe_methods.rb', line 19
    +      
    # File 'lib/hyde/dsl/methods_probe.rb', line 79
     
    -def die(errorcode, backtrace: nil)
    -  throw :finish, [errorcode].append(
    -    *(@origin.properties["handle.#{errorcode}"] or
    -      @origin.properties["handle.default"]).call(
    -        errorcode,
    -        backtrace: backtrace
    -      )
    -  )
    +def form
    +  _, opts = Hyde::Util.parse_value(request.headers["content-type"])
    +  Hyde::Util::MultipartParser.new(
    +    request.input, opts["boundary"]
    +  ).to_h
    +end
    +
    +
    + +
    +

    + + #form?Boolean + + + + + +

    +
    +

    Checks if current request has multipart/form-data associated with it

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +
    + + + @@ -438,8 +467,7 @@
    - -

    Set response header (generate response if one doesn’t exist yet)

    +

    Set response header (generate response if one doesn't exist yet)

    @@ -458,8 +486,7 @@ — -
    -

    header name

    +

    header name

    @@ -474,8 +501,7 @@ — -
    -

    header value

    +

    header value

    @@ -489,24 +515,24 @@
     
     
    -47
    -48
    -49
    -50
    -51
    -52
    -53
    -54
    -55
    -56
    -57
    -58
    -59
    -60
    -61
    +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43
    @@ -757,7 +778,7 @@ diff --git a/doc/Hyde/DSL/TemplateMethods.html b/doc/Hyde/DSL/TemplateMethods.html new file mode 100644 index 0000000..fef857f --- /dev/null +++ b/doc/Hyde/DSL/TemplateMethods.html @@ -0,0 +1,105 @@ + + + + + + + Module: Hyde::DSL::TemplateMethods + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: Hyde::DSL::TemplateMethods + + + +

    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/dsl/methods_template.rb
    +
    + +
    + + + + + + + + + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/GETHandler.html b/doc/Hyde/GETHandler.html index 96dca45..9f60e36 100644 --- a/doc/Hyde/GETHandler.html +++ b/doc/Hyde/GETHandler.html @@ -328,16 +328,16 @@
     
     
    +24
    +25
     26
     27
     28
     29
    -30
    -31
    -32
    +30 @@ -394,12 +394,12 @@
     
     
    +19
     20
    -21
    -22
    +21 @@ -483,8 +478,7 @@
    - -

    Returns the value of attribute children.

    +

    Returns the value of attribute children.

    @@ -498,12 +492,12 @@
     
     
    -86
    -87
    -88
    +98 +99 +100
    + +
    +
    +
    +
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +
    +
    # File 'lib/hyde/dsl/methods_probe.rb', line 67
    +
    +def form?
    +  value, opts = Hyde::Util.parse_value(request.headers["content-type"])
    +  if value == "multipart/form-data" and
    +     opts["boundary"]
    +    true
    +  else
    +    false
    +  end
     end
    -
    # File 'lib/hyde/dsl/probe_methods.rb', line 47
    +      
    # File 'lib/hyde/dsl/methods_probe.rb', line 29
     
     def header(key, value)
       return status(value) if key.downcase == "status"
    @@ -539,8 +565,8 @@
       
     
    - -

    Delete a header value from the headers hash If no value is provided, deletes all key entries

    +

    Delete a header value from the headers hash +If no value is provided, deletes all key entries

    @@ -559,8 +585,7 @@ — -
    -

    header name

    +

    header name

    @@ -577,8 +602,7 @@ — -
    -

    header value

    +

    header value

    @@ -592,24 +616,24 @@
     
     
    -67
    -68
    -69
    -70
    -71
    -72
    -73
    -74
    -75
    -76
    -77
    -78
    -79
    -80
    -81
    +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63
    -
    # File 'lib/hyde/dsl/probe_methods.rb', line 67
    +      
    # File 'lib/hyde/dsl/methods_probe.rb', line 49
     
     def remove_header(key, value = nil)
       return unless @origin.response
    @@ -642,8 +666,7 @@
       
     
    - -

    Get the current request

    +

    Get the current request

    @@ -670,12 +693,12 @@
     
     
    -11
    -12
    -13
    +13 +14 +15
    -
    # File 'lib/hyde/dsl/probe_methods.rb', line 11
    +      
    # File 'lib/hyde/dsl/methods_probe.rb', line 13
     
     def request
       @origin.request
    @@ -700,8 +723,7 @@
       
     
    - -

    Set response status (generate response if one doesn’t exist yet)

    +

    Set response status (generate response if one doesn't exist yet)

    @@ -720,8 +742,7 @@ — -
    -

    http status code

    +

    http status code

    @@ -735,17 +756,17 @@
     
     
    -37
    -38
    -39
    -40
    +19 +20 +21 +22
    -
    # File 'lib/hyde/dsl/probe_methods.rb', line 37
    +      
    # File 'lib/hyde/dsl/methods_probe.rb', line 19
     
     def status(status)
    -  @response = (@response or Hyde::Response.new)
    -  @response.status = status
    +  @origin.response = (@origin.response or Hyde::Response.new)
    +  @origin.response.status = status
     end
    -
    # File 'lib/hyde/probe/http_method.rb', line 26
    +      
    # File 'lib/hyde/probe/http_method.rb', line 24
     
     def process(request)
       unless request.request_method.casecmp(self.class::METHOD).zero?
    @@ -356,7 +356,7 @@
     
     
           
    diff --git a/doc/Hyde/HEADHandler.html b/doc/Hyde/HEADHandler.html
    index 23d6000..555ed79 100644
    --- a/doc/Hyde/HEADHandler.html
    +++ b/doc/Hyde/HEADHandler.html
    @@ -211,7 +211,7 @@
     
     
           
    diff --git a/doc/Hyde/Handler.html b/doc/Hyde/Handler.html
    index 97826db..2cc8daf 100644
    --- a/doc/Hyde/Handler.html
    +++ b/doc/Hyde/Handler.html
    @@ -340,20 +340,20 @@
           
     
     
    +11
     12
     13
     14
     15
    -16
    -17
    +16
    -
    # File 'lib/hyde/probe/handler.rb', line 12
    +      
    # File 'lib/hyde/probe/handler.rb', line 11
     
     def initialize(path, parent:, &exec)
       super(path, parent: parent)
       @callback = exec
    -  @binding = Hyde::ProbeBinding.new(self)
    +  @context = Hyde::ProbeContext.new(self)
       @response = nil
     end
    -
    # File 'lib/hyde/probe/handler.rb', line 20
    +      
    # File 'lib/hyde/probe/handler.rb', line 19
     
     def request
       @request
    @@ -437,12 +437,12 @@
           
     
     
    +18
     19
    -20
    -21
    +20
    -
    # File 'lib/hyde/probe/handler.rb', line 19
    +      
    # File 'lib/hyde/probe/handler.rb', line 18
     
     def response
       @response
    @@ -549,6 +549,7 @@
           
     
     
    +35
     36
     37
     38
    @@ -565,11 +566,10 @@
     49
     50
     51
    -52
    -53
    +52
    -
    # File 'lib/hyde/probe/handler.rb', line 36
    +      
    # File 'lib/hyde/probe/handler.rb', line 35
     
     def process(request)
       @response = nil
    @@ -577,7 +577,7 @@
     
       @request = request
       response = catch(:break) do
    -    @binding.instance_exec(*request.splat,
    +    @context.instance_exec(*request.splat,
                                **request.param,
                                &@callback)
       end
    @@ -599,7 +599,7 @@
     
     
           
    diff --git a/doc/Hyde/Handlers.html b/doc/Hyde/Handlers.html
    new file mode 100644
    index 0000000..f89abca
    --- /dev/null
    +++ b/doc/Hyde/Handlers.html
    @@ -0,0 +1,127 @@
    +
    +
    +  
    +    
    +
    +
    +  Module: Hyde::Handlers
    +  
    +    — Documentation by YARD 0.9.34
    +  
    +
    +
    +  
    +
    +  
    +
    +
    +
    +
    +  
    +
    +  
    +
    +
    +  
    +  
    +    
    +
    +    
    + + +

    Module: Hyde::Handlers + + + +

    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/probe.rb,
    + lib/hyde/probe/handler.rb,
    lib/hyde/probe/http_method.rb,
    lib/hyde/probe/serve_handler.rb
    +
    +
    + +
    + +

    Overview

    +
    +

    All subclasses of Hyde::Probe that respond to requests

    + + +
    +
    +
    + + +

    Defined Under Namespace

    +

    + + + + + Classes: CONNECT, DELETE, GET, HEAD, Handler, OPTIONS, PATCH, POST, PUT, Serve, TRACE + + +

    + + + + + + + + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Handlers/CONNECT.html b/doc/Hyde/Handlers/CONNECT.html new file mode 100644 index 0000000..c18fe90 --- /dev/null +++ b/doc/Hyde/Handlers/CONNECT.html @@ -0,0 +1,220 @@ + + + + + + + Class: Hyde::Handlers::CONNECT + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Hyde::Handlers::CONNECT + + + +

    +
    + +
    +
    Inherits:
    +
    + GET + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/probe/http_method.rb
    +
    + +
    + +

    Overview

    +
    +

    Probe that executes callback on a CONNECT

    + + +
    +
    +
    + + +
    + +

    + Constant Summary + collapse +

    + +
    + +
    METHOD = + +
    +
    "CONNECT"
    + +
    + + + + + + + +

    Instance Attribute Summary

    + +

    Attributes inherited from Handler

    +

    #request, #response

    + + + +

    Attributes inherited from Probe

    +

    #properties

    + + + +

    Attributes inherited from Node

    +

    #remap, #root

    + + + + + + + + + +

    Method Summary

    + +

    Methods inherited from GET

    +

    #process

    + + + + + + + + + +

    Methods inherited from Handler

    +

    #initialize, #process

    + + + + + + + + + +

    Methods inherited from Probe

    +

    #initialize, #process

    + + + + + + + + + +

    Methods inherited from Node

    +

    #go, #initialize, #process, #reject

    +
    +

    Constructor Details

    + +

    This class inherits a constructor from Hyde::Handlers::Handler

    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Handlers/DELETE.html b/doc/Hyde/Handlers/DELETE.html new file mode 100644 index 0000000..244f96b --- /dev/null +++ b/doc/Hyde/Handlers/DELETE.html @@ -0,0 +1,220 @@ + + + + + + + Class: Hyde::Handlers::DELETE + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Hyde::Handlers::DELETE + + + +

    +
    + +
    +
    Inherits:
    +
    + GET + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/probe/http_method.rb
    +
    + +
    + +

    Overview

    +
    +

    Probe that executes callback on a DELETE

    + + +
    +
    +
    + + +
    + +

    + Constant Summary + collapse +

    + +
    + +
    METHOD = + +
    +
    "DELETE"
    + +
    + + + + + + + +

    Instance Attribute Summary

    + +

    Attributes inherited from Handler

    +

    #request, #response

    + + + +

    Attributes inherited from Probe

    +

    #properties

    + + + +

    Attributes inherited from Node

    +

    #remap, #root

    + + + + + + + + + +

    Method Summary

    + +

    Methods inherited from GET

    +

    #process

    + + + + + + + + + +

    Methods inherited from Handler

    +

    #initialize, #process

    + + + + + + + + + +

    Methods inherited from Probe

    +

    #initialize, #process

    + + + + + + + + + +

    Methods inherited from Node

    +

    #go, #initialize, #process, #reject

    +
    +

    Constructor Details

    + +

    This class inherits a constructor from Hyde::Handlers::Handler

    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Handlers/GET.html b/doc/Hyde/Handlers/GET.html new file mode 100644 index 0000000..2ee0d1e --- /dev/null +++ b/doc/Hyde/Handlers/GET.html @@ -0,0 +1,360 @@ + + + + + + + Class: Hyde::Handlers::GET + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Hyde::Handlers::GET + + + +

    +
    + +
    +
    Inherits:
    +
    + Handler + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/probe/http_method.rb
    +
    + +
    + +

    Overview

    +
    +

    Probe that executes callback on a GET

    + + +
    +
    +
    + + +
    +

    Direct Known Subclasses

    +

    CONNECT, DELETE, HEAD, OPTIONS, PATCH, POST, PUT, TRACE

    +
    + + +

    + Constant Summary + collapse +

    + +
    + +
    METHOD = + +
    +
    "GET"
    + +
    + + + + + + + +

    Instance Attribute Summary

    + +

    Attributes inherited from Handler

    +

    #request, #response

    + + + +

    Attributes inherited from Probe

    +

    #properties

    + + + +

    Attributes inherited from Node

    +

    #remap, #root

    + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + + + + +

    Methods inherited from Handler

    +

    #initialize

    + + + + + + + + + +

    Methods inherited from Probe

    +

    #initialize

    + + + + + + + + + +

    Methods inherited from Node

    +

    #go, #initialize, #reject

    +
    +

    Constructor Details

    + +

    This class inherits a constructor from Hyde::Handlers::Handler

    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #process(request) ⇒ Boolean + + + + + +

    +
    +

    Method callback on successful request navigation. +Runs block supplied with object initialization. +Request's #splat and #param are passed to block.

    + +

    Callback's returned should be one of viable responses:

    + +
      +
    • Response object
    • +
    • An array that matches Rack return form
    • +
    • An array that matches old (Rack 2.x) return form
    • +
    • A string (returned as HTML with code 200)
    • +
    • false (bounces the request to next handler)
    • +
    + + +
    +
    +
    +

    Parameters:

    + + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +

      true if further navigation is possible

      +
      + +
    • + +
    +

    Raises:

    +
      + +
    • + + + (UncaughtThrowError) + + + + — +

      may raise if die() is called.

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +25
    +26
    +27
    +28
    +29
    +30
    +31
    +
    +
    # File 'lib/hyde/probe/http_method.rb', line 25
    +
    +def process(request)
    +  unless request.request_method.casecmp(self.class::METHOD).zero?
    +    return false
    +  end
    +
    +  super(request)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Handlers/HEAD.html b/doc/Hyde/Handlers/HEAD.html new file mode 100644 index 0000000..4f5bd68 --- /dev/null +++ b/doc/Hyde/Handlers/HEAD.html @@ -0,0 +1,220 @@ + + + + + + + Class: Hyde::Handlers::HEAD + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Hyde::Handlers::HEAD + + + +

    +
    + +
    +
    Inherits:
    +
    + GET + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/probe/http_method.rb
    +
    + +
    + +

    Overview

    +
    +

    Probe that executes callback on a HEAD

    + + +
    +
    +
    + + +
    + +

    + Constant Summary + collapse +

    + +
    + +
    METHOD = + +
    +
    "HEAD"
    + +
    + + + + + + + +

    Instance Attribute Summary

    + +

    Attributes inherited from Handler

    +

    #request, #response

    + + + +

    Attributes inherited from Probe

    +

    #properties

    + + + +

    Attributes inherited from Node

    +

    #remap, #root

    + + + + + + + + + +

    Method Summary

    + +

    Methods inherited from GET

    +

    #process

    + + + + + + + + + +

    Methods inherited from Handler

    +

    #initialize, #process

    + + + + + + + + + +

    Methods inherited from Probe

    +

    #initialize, #process

    + + + + + + + + + +

    Methods inherited from Node

    +

    #go, #initialize, #process, #reject

    +
    +

    Constructor Details

    + +

    This class inherits a constructor from Hyde::Handlers::Handler

    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Handlers/Handler.html b/doc/Hyde/Handlers/Handler.html new file mode 100644 index 0000000..2273f8b --- /dev/null +++ b/doc/Hyde/Handlers/Handler.html @@ -0,0 +1,597 @@ + + + + + + + Class: Hyde::Handlers::Handler + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Hyde::Handlers::Handler + + + +

    +
    + +
    +
    Inherits:
    +
    + Probe + +
      +
    • Object
    • + + + + + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/probe/handler.rb
    +
    + +
    + +

    Overview

    +
    +

    Probe that executes a callback on request

    + + +
    +
    +
    + + +
    +

    Direct Known Subclasses

    +

    GET

    +
    + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #request ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      Returns the value of attribute request.

      +
      + +
    • + + +
    • + + + #response ⇒ Object + + + + + + + + + + + + + + + + +

      Returns the value of attribute response.

      +
      + +
    • + + +
    + + + + + +

    Attributes inherited from Probe

    +

    #properties

    + + + +

    Attributes inherited from Node

    +

    #remap, #root

    + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + + + + + + + + + + +

    Methods inherited from Node

    +

    #go, #reject

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(path, parent:, &exec) ⇒ Handler + + + + + +

    +
    +

    Returns a new instance of Handler.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + path + + + (Object) + + + +
    • + +
    • + + parent + + + (Hyde::Node) + + + +
    • + +
    • + + exec + + + (#call) + + + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +12
    +13
    +14
    +15
    +16
    +17
    +
    +
    # File 'lib/hyde/probe/handler.rb', line 12
    +
    +def initialize(path, parent:, &exec)
    +  super(path, parent: parent)
    +  @callback = exec
    +  @context = Hyde::ProbeContext.new(self)
    +  @response = nil
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #requestObject (readonly) + + + + + +

    +
    +

    Returns the value of attribute request.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +20
    +21
    +22
    +
    +
    # File 'lib/hyde/probe/handler.rb', line 20
    +
    +def request
    +  @request
    +end
    +
    +
    + + + +
    +

    + + #responseObject + + + + + +

    +
    +

    Returns the value of attribute response.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +19
    +20
    +21
    +
    +
    # File 'lib/hyde/probe/handler.rb', line 19
    +
    +def response
    +  @response
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #process(request) ⇒ Boolean + + + + + +

    +
    +

    Method callback on successful request navigation. +Runs block supplied with object initialization. +Request's #splat and #param are passed to block.

    + +

    Callback's returned should be one of viable responses:

    + +
      +
    • Response object
    • +
    • An array that matches Rack return form
    • +
    • An array that matches old (Rack 2.x) return form
    • +
    • A string (returned as HTML with code 200)
    • +
    • false (bounces the request to next handler)
    • +
    + + +
    +
    +
    +

    Parameters:

    + + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +

      true if further navigation is possible

      +
      + +
    • + +
    +

    Raises:

    +
      + +
    • + + + (UncaughtThrowError) + + + + — +

      may raise if die() is called.

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +36
    +37
    +38
    +39
    +40
    +41
    +42
    +43
    +44
    +45
    +46
    +47
    +48
    +49
    +50
    +51
    +52
    +53
    +
    +
    # File 'lib/hyde/probe/handler.rb', line 36
    +
    +def process(request)
    +  @response = nil
    +  return reject(request) unless request.path.match?(/^\/?$/)
    + 
    +  @request = request
    +  response = catch(:break) do
    +    @context.instance_exec(*request.splat,
    +                           **request.param,
    +                           &@callback)
    +  end
    +  return false unless response
    + 
    +  if @response and [String, File, IO].include? response.class
    +    @response.body = response
    +    throw :finish, @response
    +  end
    +  throw :finish, response
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Handlers/OPTIONS.html b/doc/Hyde/Handlers/OPTIONS.html new file mode 100644 index 0000000..1557b39 --- /dev/null +++ b/doc/Hyde/Handlers/OPTIONS.html @@ -0,0 +1,220 @@ + + + + + + + Class: Hyde::Handlers::OPTIONS + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Hyde::Handlers::OPTIONS + + + +

    +
    + +
    +
    Inherits:
    +
    + GET + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/probe/http_method.rb
    +
    + +
    + +

    Overview

    +
    +

    Probe that executes callback on a OPTIONS

    + + +
    +
    +
    + + +
    + +

    + Constant Summary + collapse +

    + +
    + +
    METHOD = + +
    +
    "OPTIONS"
    + +
    + + + + + + + +

    Instance Attribute Summary

    + +

    Attributes inherited from Handler

    +

    #request, #response

    + + + +

    Attributes inherited from Probe

    +

    #properties

    + + + +

    Attributes inherited from Node

    +

    #remap, #root

    + + + + + + + + + +

    Method Summary

    + +

    Methods inherited from GET

    +

    #process

    + + + + + + + + + +

    Methods inherited from Handler

    +

    #initialize, #process

    + + + + + + + + + +

    Methods inherited from Probe

    +

    #initialize, #process

    + + + + + + + + + +

    Methods inherited from Node

    +

    #go, #initialize, #process, #reject

    +
    +

    Constructor Details

    + +

    This class inherits a constructor from Hyde::Handlers::Handler

    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Handlers/PATCH.html b/doc/Hyde/Handlers/PATCH.html new file mode 100644 index 0000000..12c153f --- /dev/null +++ b/doc/Hyde/Handlers/PATCH.html @@ -0,0 +1,220 @@ + + + + + + + Class: Hyde::Handlers::PATCH + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Hyde::Handlers::PATCH + + + +

    +
    + +
    +
    Inherits:
    +
    + GET + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/probe/http_method.rb
    +
    + +
    + +

    Overview

    +
    +

    Probe that executes callback on a PATCH

    + + +
    +
    +
    + + +
    + +

    + Constant Summary + collapse +

    + +
    + +
    METHOD = + +
    +
    "PATCH"
    + +
    + + + + + + + +

    Instance Attribute Summary

    + +

    Attributes inherited from Handler

    +

    #request, #response

    + + + +

    Attributes inherited from Probe

    +

    #properties

    + + + +

    Attributes inherited from Node

    +

    #remap, #root

    + + + + + + + + + +

    Method Summary

    + +

    Methods inherited from GET

    +

    #process

    + + + + + + + + + +

    Methods inherited from Handler

    +

    #initialize, #process

    + + + + + + + + + +

    Methods inherited from Probe

    +

    #initialize, #process

    + + + + + + + + + +

    Methods inherited from Node

    +

    #go, #initialize, #process, #reject

    +
    +

    Constructor Details

    + +

    This class inherits a constructor from Hyde::Handlers::Handler

    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Handlers/POST.html b/doc/Hyde/Handlers/POST.html new file mode 100644 index 0000000..8c23108 --- /dev/null +++ b/doc/Hyde/Handlers/POST.html @@ -0,0 +1,220 @@ + + + + + + + Class: Hyde::Handlers::POST + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Hyde::Handlers::POST + + + +

    +
    + +
    +
    Inherits:
    +
    + GET + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/probe/http_method.rb
    +
    + +
    + +

    Overview

    +
    +

    Probe that executes callback on a POST

    + + +
    +
    +
    + + +
    + +

    + Constant Summary + collapse +

    + +
    + +
    METHOD = + +
    +
    "POST"
    + +
    + + + + + + + +

    Instance Attribute Summary

    + +

    Attributes inherited from Handler

    +

    #request, #response

    + + + +

    Attributes inherited from Probe

    +

    #properties

    + + + +

    Attributes inherited from Node

    +

    #remap, #root

    + + + + + + + + + +

    Method Summary

    + +

    Methods inherited from GET

    +

    #process

    + + + + + + + + + +

    Methods inherited from Handler

    +

    #initialize, #process

    + + + + + + + + + +

    Methods inherited from Probe

    +

    #initialize, #process

    + + + + + + + + + +

    Methods inherited from Node

    +

    #go, #initialize, #process, #reject

    +
    +

    Constructor Details

    + +

    This class inherits a constructor from Hyde::Handlers::Handler

    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Handlers/PUT.html b/doc/Hyde/Handlers/PUT.html new file mode 100644 index 0000000..ef40433 --- /dev/null +++ b/doc/Hyde/Handlers/PUT.html @@ -0,0 +1,220 @@ + + + + + + + Class: Hyde::Handlers::PUT + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Hyde::Handlers::PUT + + + +

    +
    + +
    +
    Inherits:
    +
    + GET + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/probe/http_method.rb
    +
    + +
    + +

    Overview

    +
    +

    Probe that executes callback on a PUT

    + + +
    +
    +
    + + +
    + +

    + Constant Summary + collapse +

    + +
    + +
    METHOD = + +
    +
    "PUT"
    + +
    + + + + + + + +

    Instance Attribute Summary

    + +

    Attributes inherited from Handler

    +

    #request, #response

    + + + +

    Attributes inherited from Probe

    +

    #properties

    + + + +

    Attributes inherited from Node

    +

    #remap, #root

    + + + + + + + + + +

    Method Summary

    + +

    Methods inherited from GET

    +

    #process

    + + + + + + + + + +

    Methods inherited from Handler

    +

    #initialize, #process

    + + + + + + + + + +

    Methods inherited from Probe

    +

    #initialize, #process

    + + + + + + + + + +

    Methods inherited from Node

    +

    #go, #initialize, #process, #reject

    +
    +

    Constructor Details

    + +

    This class inherits a constructor from Hyde::Handlers::Handler

    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Handlers/Serve.html b/doc/Hyde/Handlers/Serve.html new file mode 100644 index 0000000..799e46e --- /dev/null +++ b/doc/Hyde/Handlers/Serve.html @@ -0,0 +1,469 @@ + + + + + + + Class: Hyde::Handlers::Serve + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Hyde::Handlers::Serve + + + +

    +
    + +
    +
    Inherits:
    +
    + Probe + +
      +
    • Object
    • + + + + + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/probe/serve_handler.rb
    +
    + +
    + +

    Overview

    +
    +

    Probe that sends files from a location

    + + +
    +
    +
    + + +
    + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #response ⇒ Object + + + + + + + + + + + + + + + + +

      Returns the value of attribute response.

      +
      + +
    • + + +
    + + + + + +

    Attributes inherited from Probe

    +

    #properties

    + + + +

    Attributes inherited from Node

    +

    #remap, #root

    + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + + + + + + + + + + +

    Methods inherited from Node

    +

    #go, #reject

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(path, parent:) ⇒ Serve + + + + + +

    +
    +

    Returns a new instance of Serve.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + path + + + (Object) + + + +
    • + +
    • + + parent + + + (Hyde::Node) + + + +
    • + +
    • + + exec + + + (#call) + + + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +12
    +13
    +14
    +
    +
    # File 'lib/hyde/probe/serve_handler.rb', line 12
    +
    +def initialize(path, parent:)
    +  super(path, parent: parent)
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #responseObject + + + + + +

    +
    +

    Returns the value of attribute response.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +16
    +17
    +18
    +
    +
    # File 'lib/hyde/probe/serve_handler.rb', line 16
    +
    +def response
    +  @response
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #process(request) ⇒ Boolean + + + + + +

    +
    +

    Method callback on successful request navigation. +Tries to serve files matched by handler

    + + +
    +
    +
    +

    Parameters:

    + + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + + — +

      true if file was found

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +22
    +23
    +24
    +25
    +26
    +27
    +28
    +29
    +
    +
    # File 'lib/hyde/probe/serve_handler.rb', line 22
    +
    +def process(request)
    +  path = File.expand_path(request.filepath)
    +  return unless path.start_with? @properties["path"]
    +
    +  File.open(path.delete_suffix("/"))
    +rescue StandardError
    +  false
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Handlers/TRACE.html b/doc/Hyde/Handlers/TRACE.html new file mode 100644 index 0000000..c8ac125 --- /dev/null +++ b/doc/Hyde/Handlers/TRACE.html @@ -0,0 +1,220 @@ + + + + + + + Class: Hyde::Handlers::TRACE + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Hyde::Handlers::TRACE + + + +

    +
    + +
    +
    Inherits:
    +
    + GET + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/probe/http_method.rb
    +
    + +
    + +

    Overview

    +
    +

    Probe that executes callback on a TRACE

    + + +
    +
    +
    + + +
    + +

    + Constant Summary + collapse +

    + +
    + +
    METHOD = + +
    +
    "TRACE"
    + +
    + + + + + + + +

    Instance Attribute Summary

    + +

    Attributes inherited from Handler

    +

    #request, #response

    + + + +

    Attributes inherited from Probe

    +

    #properties

    + + + +

    Attributes inherited from Node

    +

    #remap, #root

    + + + + + + + + + +

    Method Summary

    + +

    Methods inherited from GET

    +

    #process

    + + + + + + + + + +

    Methods inherited from Handler

    +

    #initialize, #process

    + + + + + + + + + +

    Methods inherited from Probe

    +

    #initialize, #process

    + + + + + + + + + +

    Methods inherited from Node

    +

    #go, #initialize, #process, #reject

    +
    +

    Constructor Details

    + +

    This class inherits a constructor from Hyde::Handlers::Handler

    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Node.html b/doc/Hyde/Node.html index 80a0c21..72f1392 100644 --- a/doc/Hyde/Node.html +++ b/doc/Hyde/Node.html @@ -105,8 +105,10 @@ This class is abstract.
    +

    Abstract class that reacts to request navigation. +Does nothing by default, behaviour should be overriden through

    -

    Abstract class that reacts to request navigation. Does nothing by default, behaviour should be overriden through #reject and #process

    +

    reject and #process

    @@ -145,8 +147,7 @@ -
    -

    Returns the value of attribute remap.

    +

    Returns the value of attribute remap.

    @@ -172,8 +173,7 @@ -
    -

    Returns the value of attribute root.

    +

    Returns the value of attribute root.

    @@ -209,8 +209,7 @@ -
    -

    Try to navigate the path.

    +

    Try to navigate the path.

    @@ -235,8 +234,7 @@ -
    -

    A new instance of Node.

    +

    A new instance of Node.

    @@ -259,8 +257,7 @@ -
    -

    Method callback on successful request navigation.

    +

    Method callback on successful request navigation.

    @@ -283,8 +280,7 @@ -
    -

    Method callback on failed request navigation.

    +

    Method callback on failed request navigation.

    @@ -307,8 +303,7 @@
    - -

    Returns a new instance of Node.

    +

    Returns a new instance of Node.

    @@ -376,8 +371,7 @@
    - -

    Returns the value of attribute remap.

    +

    Returns the value of attribute remap.

    @@ -419,8 +413,7 @@
    - -

    Returns the value of attribute root.

    +

    Returns the value of attribute root.

    @@ -467,8 +460,7 @@
    - -

    Try to navigate the path. Run method callback in response.

    +

    Try to navigate the path. Run method callback in response.

    @@ -562,8 +554,7 @@
    - -

    Method callback on successful request navigation

    +

    Method callback on successful request navigation

    @@ -596,8 +587,7 @@ -
    -

    true

    +

    true

    @@ -636,8 +626,7 @@
    - -

    Method callback on failed request navigation

    +

    Method callback on failed request navigation

    @@ -670,8 +659,7 @@ -
    -

    false

    +

    false

    @@ -704,7 +692,7 @@
    diff --git a/doc/Hyde/OPTIONSHandler.html b/doc/Hyde/OPTIONSHandler.html index 22312de..481dcee 100644 --- a/doc/Hyde/OPTIONSHandler.html +++ b/doc/Hyde/OPTIONSHandler.html @@ -211,7 +211,7 @@
    diff --git a/doc/Hyde/PATCHHandler.html b/doc/Hyde/PATCHHandler.html index 0b44079..9ade95d 100644 --- a/doc/Hyde/PATCHHandler.html +++ b/doc/Hyde/PATCHHandler.html @@ -211,7 +211,7 @@
    diff --git a/doc/Hyde/POSTHandler.html b/doc/Hyde/POSTHandler.html index debc523..4954867 100644 --- a/doc/Hyde/POSTHandler.html +++ b/doc/Hyde/POSTHandler.html @@ -211,7 +211,7 @@
    diff --git a/doc/Hyde/PUTHandler.html b/doc/Hyde/PUTHandler.html index 3989021..3d3f53c 100644 --- a/doc/Hyde/PUTHandler.html +++ b/doc/Hyde/PUTHandler.html @@ -211,7 +211,7 @@
    diff --git a/doc/Hyde/Path.html b/doc/Hyde/Path.html index b2340da..0557357 100644 --- a/doc/Hyde/Path.html +++ b/doc/Hyde/Path.html @@ -103,8 +103,7 @@

    Overview

    - -

    Primary building block of request navigation.

    +

    Primary building block of request navigation.

    @@ -125,10 +124,15 @@
    -
    Binding = +
    ProcContext =
    -
    Hyde::PathBinding
    +
    Hyde::ProcessorContext
    + +
    Context = + +
    +
    Hyde::PathContext
    @@ -161,8 +165,7 @@ -
    -

    Returns the value of attribute children.

    +

    Returns the value of attribute children.

    @@ -190,8 +193,7 @@ -
    -

    Returns the value of attribute properties.

    +

    Returns the value of attribute properties.

    @@ -232,8 +234,7 @@ -
    -

    Add a filter to the path.

    +

    Add a filter to the path.

    @@ -258,8 +259,7 @@ -
    -

    A new instance of Path.

    +

    A new instance of Path.

    @@ -282,8 +282,7 @@ -
    -

    Add a postprocessor to the path.

    +

    Add a postprocessor to the path.

    @@ -306,8 +305,7 @@ -
    -

    Add a preprocessor to the path.

    +

    Add a preprocessor to the path.

    @@ -330,8 +328,7 @@ -
    -

    Method callback on successful request navigation.

    +

    Method callback on successful request navigation.

    @@ -365,8 +362,7 @@
    - -

    Returns a new instance of Path.

    +

    Returns a new instance of Path.

    @@ -385,8 +381,7 @@ — -
    -

    Object to generate Hyde::Pattern from

    +

    Object to generate Hyde::Pattern from

    @@ -401,8 +396,7 @@ — -
    -

    Parent object to inherit properties to

    +

    Parent object to inherit properties to

    @@ -417,8 +411,7 @@ — -
    -

    Setup block

    +

    Setup block

    @@ -432,21 +425,22 @@
     
     
    -27
    -28
    -29
    -30
    -31
    -32
    -33
    -34
    -35
    -36
    -37
    -38
    +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50
    -
    # File 'lib/hyde/path.rb', line 27
    +      
    # File 'lib/hyde/path.rb', line 38
     
     def initialize(path, parent:, &setup)
       super(path, parent: parent)
    @@ -456,9 +450,10 @@
       @preprocessors = []
       @postprocessors = []
       @filters = []
    -
    -  binding = Binding.new(self)
    -  binding.instance_exec(&setup)
    +  # Contexts setup
    +  context = self.class::Context.new(self)
    +  context.instance_exec(&setup)
    +  @proccontext = self.class::ProcContext.new(self)
     end
    -
    # File 'lib/hyde/path.rb', line 86
    +      
    # File 'lib/hyde/path.rb', line 98
     
     def children
       @children
    @@ -526,8 +520,7 @@
       
     
    - -

    Returns the value of attribute properties.

    +

    Returns the value of attribute properties.

    @@ -541,12 +534,12 @@
     
     
    -86
    -87
    -88
    +98 +99 +100
    -
    # File 'lib/hyde/path.rb', line 86
    +      
    # File 'lib/hyde/path.rb', line 98
     
     def properties
       @properties
    @@ -574,8 +567,8 @@
       
     
    - -

    Add a filter to the path. Blocks path access if a filter returns false.

    +

    Add a filter to the path. +Blocks path access if a filter returns false.

    @@ -619,12 +612,12 @@
     
     
    -82
    -83
    -84
    +94 +95 +96
    -
    # File 'lib/hyde/path.rb', line 82
    +      
    # File 'lib/hyde/path.rb', line 94
     
     def filter(&block)
       @filters.append(block)
    @@ -645,8 +638,7 @@
       
     
    - -

    Add a postprocessor to the path.

    +

    Add a postprocessor to the path.

    @@ -701,12 +693,12 @@
     
     
    -74
    -75
    -76
    +86 +87 +88
    -
    # File 'lib/hyde/path.rb', line 74
    +      
    # File 'lib/hyde/path.rb', line 86
     
     def postprocess(&block)
       @postprocessors.append(block)
    @@ -727,8 +719,8 @@
       
     
    - -

    Add a preprocessor to the path. Does not modify path execution.

    +

    Add a preprocessor to the path. +Does not modify path execution.

    @@ -772,12 +764,12 @@
     
     
    -66
    -67
    -68
    +78 +79 +80
    -
    # File 'lib/hyde/path.rb', line 66
    +      
    # File 'lib/hyde/path.rb', line 78
     
     def preprocess(&block)
       @preprocessors.append(block)
    @@ -798,8 +790,8 @@
       
     
    - -

    Method callback on successful request navigation. Finds the next appropriate path to go to.

    +

    Method callback on successful request navigation. +Finds the next appropriate path to go to.

    @@ -817,8 +809,7 @@ — -
    -

    true if further navigation will be done

    +

    true if further navigation will be done

    @@ -835,8 +826,7 @@ — -
    -

    by default throws :response if no matches found.

    +

    by default throws :response if no matches found.

    @@ -849,26 +839,26 @@
     
     
    -44
    -45
    -46
    -47
    -48
    -49
    -50
    -51
    -52
    -53
    -54
    -55
     56
     57
     58
     59
    -60
    +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72
    -
    # File 'lib/hyde/path.rb', line 44
    +      
    # File 'lib/hyde/path.rb', line 56
     
     def process(request)
       return false unless run_filters(request)
    @@ -897,7 +887,7 @@
     
     
           
    diff --git a/doc/Hyde/PathContext.html b/doc/Hyde/PathContext.html
    new file mode 100644
    index 0000000..f10c891
    --- /dev/null
    +++ b/doc/Hyde/PathContext.html
    @@ -0,0 +1,242 @@
    +
    +
    +  
    +    
    +
    +
    +  Class: Hyde::PathContext
    +  
    +    — Documentation by YARD 0.9.34
    +  
    +
    +
    +  
    +
    +  
    +
    +
    +
    +
    +  
    +
    +  
    +
    +
    +  
    +  
    +    
    +
    +    
    + + +

    Class: Hyde::PathContext + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + +
    +
    Includes:
    +
    DSL::PathConstructors, DSL::PathMethods
    +
    + + + + + + +
    +
    Defined in:
    +
    lib/hyde/path.rb
    +
    + +
    + +

    Overview

    +
    +

    Execution context for path setup block.

    + + +
    +
    +
    + + +
    +

    Direct Known Subclasses

    +

    ServerContext

    +
    + + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + + + + +

    Methods included from DSL::PathMethods

    +

    #filter, #index, #postprocess, #preprocess, #remap, #root

    + + + + + + + + + +

    Methods included from DSL::PathConstructors

    +

    #connect, #delete, #get, #head, #options, #patch, #path, #post, #probe, #put, #register, #serve, #trace

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(path) ⇒ PathContext + + + + + +

    +
    +

    Returns a new instance of PathContext.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +25
    +26
    +27
    +
    +
    # File 'lib/hyde/path.rb', line 25
    +
    +def initialize(path)
    +  @origin = path
    +end
    +
    +
    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Pattern.html b/doc/Hyde/Pattern.html index af2693e..fe2827b 100644 --- a/doc/Hyde/Pattern.html +++ b/doc/Hyde/Pattern.html @@ -101,8 +101,8 @@

    Overview

    - -

    Delegate class for all available patterns. Picks appropriate pattern based on contents.

    +

    Delegate class for all available patterns. +Picks appropriate pattern based on contents.

    @@ -144,8 +144,7 @@ -
    -

    A new instance of Pattern.

    +

    A new instance of Pattern.

    @@ -168,8 +167,7 @@ -
    -

    Match the string and assign matches to parameters.

    +

    Match the string and assign matches to parameters.

    @@ -192,8 +190,7 @@ -
    -

    Test if a string can be matched.

    +

    Test if a string can be matched.

    @@ -216,8 +213,7 @@ -
    -

    Checks if pattern object is static (is a simple String pattern).

    +

    Checks if pattern object is static (is a simple String pattern).

    @@ -240,8 +236,7 @@
    - -

    Returns a new instance of Pattern.

    +

    Returns a new instance of Pattern.

    @@ -260,8 +255,7 @@ — -
    -

    object to generate pattern from

    +

    object to generate pattern from

    @@ -310,15 +304,14 @@
    - -

    Match the string and assign matches to parameters. Returns:

    -
    • -

      Unmatched part of a string

      -
    • -

      Unnamed parameters

      -
    • -

      Named parameters

      -
    +

    Match the string and assign matches to parameters. +Returns:

    + +
      +
    • Unmatched part of a string
    • +
    • Unnamed parameters
    • +
    • Named parameters
    • +
    @@ -337,8 +330,7 @@ — -
    -

    String to match

    +

    String to match

    @@ -365,8 +357,7 @@ — -
    -

    if input doesn’t match pattern

    +

    if input doesn't match pattern

    @@ -423,8 +414,8 @@
    - -

    Test if a string can be matched. Lighter version of match that doesn’t assign any variables.

    +

    Test if a string can be matched. +Lighter version of match that doesn't assign any variables.

    @@ -443,8 +434,7 @@ — -
    -

    String to match

    +

    String to match

    @@ -505,8 +495,7 @@
    - -

    Checks if pattern object is static (is a simple String pattern).

    +

    Checks if pattern object is static (is a simple String pattern).

    @@ -553,7 +542,7 @@
    diff --git a/doc/Hyde/PatternMatching.html b/doc/Hyde/PatternMatching.html index b994167..2c2623c 100644 --- a/doc/Hyde/PatternMatching.html +++ b/doc/Hyde/PatternMatching.html @@ -87,8 +87,8 @@

    Overview

    - -

    Utility functions and pattern-generator classes. Used primarily to create patterns for path definitions.

    +

    Utility functions and pattern-generator classes. +Used primarily to create patterns for path definitions.

    @@ -138,8 +138,7 @@ -
    -

    Strips extra slashes from a string.

    +

    Strips extra slashes from a string.

    @@ -165,8 +164,8 @@
    - -

    Strips extra slashes from a string. (including slashes at the start and end of the string)

    +

    Strips extra slashes from a string. +(including slashes at the start and end of the string)

    @@ -232,7 +231,7 @@
    diff --git a/doc/Hyde/PatternMatching/Glob.html b/doc/Hyde/PatternMatching/Glob.html index 6b028a6..246bc63 100644 --- a/doc/Hyde/PatternMatching/Glob.html +++ b/doc/Hyde/PatternMatching/Glob.html @@ -101,63 +101,72 @@

    Overview

    - -

    Implements glob-like pattern matching. Exact specifications for globbing rules:

    +

    Implements glob-like pattern matching. +Exact specifications for globbing rules:

    -

    “/”

    +

    "/"

    -
    - act as directory separators
    -- multiple slashes (i.e. "///") are the same as one slash ("/")
    -- slashes are stripped at start and end of an expression or path
    -- slashes are not matched by anything but the globstar ("**")
    -
    +
      +
    • act as directory separators
    • +
    • multiple slashes (i.e. "///") are the same as one slash ("/")
    • +
    • slashes are stripped at start and end of an expression or path
    • +
    • slashes are not matched by anything but the globstar ("**")
    • +
    -

    “*” ( regexp: /([^/]*)/ )

    +

    "" ( regexp: /([^/])/ )

    -
    - matches from 0 to any number of characters
    -- does not match nothing if placed between two slashes (i.e "/*/")
    -- result is captured in an array
    -- stops at slashes
    -- greedy (matches as much as possible)
    -
    +
      +
    • matches from 0 to any number of characters
    • +
    • does not match nothing if placed between two slashes (i.e "/*/")
    • +
    • result is captured in an array
    • +
    • stops at slashes
    • +
    • greedy (matches as much as possible)
    • +
    -

    “**” ( regexp: /(.*)/ )

    +

    "*" ( regexp: /(.)/ )

    -
    - matches any number of characters
    -- matches slashes ("/")
    -- result is captured in an array
    -- does not stop at slashes
    -- greedy (matches as much as possible)
    -
    +
      +
    • matches any number of characters
    • +
    • matches slashes ("/")
    • +
    • result is captured in an array
    • +
    • does not stop at slashes
    • +
    • greedy (matches as much as possible)
    • +
    -

    “[…]+” ( regexp: itself, ! and ^ at the start are interchangeable )

    +

    "[...]+" ( regexp: itself, ! and ^ at the start are interchangeable )

    -
    - acts like a regexp range
    -- matches any characters, including slashes if specified
    -- matches any number of characters
    -- valid ways to specify a range: [A-z], [a-z], [9-z] (ascii order)
    -- ! or ^ at the start invert meaning (any character not in range)
    -- result is captured in an array
    -
    +
      +
    • acts like a regexp range
    • +
    • matches any characters, including slashes if specified
    • +
    • matches any number of characters
    • +
    • valid ways to specify a range: [A-z], [a-z], 9-z
    • +
    • ! or ^ at the start invert meaning (any character not in range)
    • +
    • result is captured in an array
    • +
    -

    “:name” ( regexp: acts like a named group for /[^/]*/ )

    +

    ":name" ( regexp: acts like a named group for /[^/]*/ )

    -
    - acts like * as defined above
    -- result is captured in a hash with "name" as key
    -- name allows alphanumeric characters and underscores
    -- ignored unless placed between two slashes
    -
    +
      +
    • acts like * as defined above
    • +
    • result is captured in a hash with "name" as key
    • +
    • name allows alphanumeric characters and underscores
    • +
    • ignored unless placed between two slashes
    • +
    -

    “(name|name2|…)” ( regexp: itself )

    +

    "(name|name2|...)" ( regexp: itself )

    -
    - matches any of (full keywords) name, name2, ...
    -- result is captured in an array
    -- each name may include only these groups of characters:
    -  - alphanumeric
    -  - slashes
    -  - underscores
    -  - dashes
    -
    +
      +
    • matches any of (full keywords) name, name2, ...
    • +
    • result is captured in an array
    • +
    • each name may include only these groups of characters: + +
        +
      • alphanumeric
      • +
      • slashes
      • +
      • underscores
      • +
      • dashes
      • +
    • +
    @@ -197,8 +206,7 @@ -
    -

    Test if input is convertible to a Glob and if it should be converted.

    +

    Test if input is convertible to a Glob and if it should be converted.

    @@ -232,8 +240,7 @@ -
    -

    A new instance of Glob.

    +

    A new instance of Glob.

    @@ -256,8 +263,7 @@ -
    -

    Match the string and assign matches to parameters.

    +

    Match the string and assign matches to parameters.

    @@ -280,8 +286,7 @@ -
    -

    Test if a string can be matched.

    +

    Test if a string can be matched.

    @@ -304,8 +309,7 @@
    - -

    Returns a new instance of Glob.

    +

    Returns a new instance of Glob.

    @@ -324,8 +328,7 @@ — -
    -

    Glob pattern

    +

    Glob pattern

    @@ -382,8 +385,7 @@
    - -

    Test if input is convertible to a Glob and if it should be converted

    +

    Test if input is convertible to a Glob and if it should be converted

    @@ -416,8 +418,7 @@ — -
    -

    Input can be safely converted to Glob

    +

    Input can be safely converted to Glob

    @@ -464,15 +465,14 @@
    - -

    Match the string and assign matches to parameters. Returns:

    -
    • -

      Unmatched part of a string

      -
    • -

      Unnamed parameters

      -
    • -

      Named parameters

      -
    +

    Match the string and assign matches to parameters. +Returns:

    + +
      +
    • Unmatched part of a string
    • +
    • Unnamed parameters
    • +
    • Named parameters
    • +
    @@ -491,8 +491,7 @@ — -
    -

    String to match

    +

    String to match

    @@ -519,8 +518,7 @@ — -
    -

    if input doesn’t match glob

    +

    if input doesn't match glob

    @@ -571,8 +569,8 @@
    - -

    Test if a string can be matched. Lighter version of match that doesn’t assign any variables.

    +

    Test if a string can be matched. +Lighter version of match that doesn't assign any variables.

    @@ -591,8 +589,7 @@ — -
    -

    String to match

    +

    String to match

    @@ -641,7 +638,7 @@
    diff --git a/doc/Hyde/PatternMatching/ReMatch.html b/doc/Hyde/PatternMatching/ReMatch.html index 843c1ce..8a055e7 100644 --- a/doc/Hyde/PatternMatching/ReMatch.html +++ b/doc/Hyde/PatternMatching/ReMatch.html @@ -104,18 +104,17 @@
    Note: -
    -

    If you are planning to write your own pattern, this is the easiest one to read.

    +

    If you are planning to write your own pattern, this is the easiest one to read.

    +

    Regexp pattern matching wrapper. +Following principles apply to the wrapper:

    -

    Regexp pattern matching wrapper. Following principles apply to the wrapper:

    -
    • -

      Regexp input is canonicalized using Hyde::PatternMatching.canonicalize

      -
    • -

      Matched content and anything before it is consumed in #match output

      -
    +
      +
    • Regexp input is canonicalized using Hyde::PatternMatching.canonicalize
    • +
    • Matched content and anything before it is consumed in #match output
    • +
    @@ -155,8 +154,7 @@ -
    -

    Test if input is convertible and if it should be converted.

    +

    Test if input is convertible and if it should be converted.

    @@ -190,8 +188,7 @@ -
    -

    A new instance of ReMatch.

    +

    A new instance of ReMatch.

    @@ -214,8 +211,7 @@ -
    -

    Match the string and assign matches to parameters.

    +

    Match the string and assign matches to parameters.

    @@ -238,8 +234,7 @@ -
    -

    Test if a string can be matched.

    +

    Test if a string can be matched.

    @@ -262,8 +257,7 @@
    - -

    Returns a new instance of ReMatch.

    +

    Returns a new instance of ReMatch.

    @@ -310,8 +304,7 @@
    - -

    Test if input is convertible and if it should be converted.

    +

    Test if input is convertible and if it should be converted.

    @@ -344,8 +337,7 @@ — -
    -

    Input can be safely converted to Glob

    +

    Input can be safely converted to Glob

    @@ -390,15 +382,14 @@
    - -

    Match the string and assign matches to parameters. Returns:

    -
    • -

      Unmatched part of a string

      -
    • -

      Unnamed parameters

      -
    • -

      Named parameters

      -
    +

    Match the string and assign matches to parameters. +Returns:

    + +
      +
    • Unmatched part of a string
    • +
    • Unnamed parameters
    • +
    • Named parameters
    • +
    @@ -417,8 +408,7 @@ — -
    -

    String to match

    +

    String to match

    @@ -445,8 +435,7 @@ — -
    -

    if input doesn’t match regexp

    +

    if input doesn't match regexp

    @@ -491,8 +480,8 @@
    - -

    Test if a string can be matched. Lighter version of match that doesn’t assign any variables.

    +

    Test if a string can be matched. +Lighter version of match that doesn't assign any variables.

    @@ -511,8 +500,7 @@ — -
    -

    String to match

    +

    String to match

    @@ -559,7 +547,7 @@
    diff --git a/doc/Hyde/Probe.html b/doc/Hyde/Probe.html index 2282d75..7a43863 100644 --- a/doc/Hyde/Probe.html +++ b/doc/Hyde/Probe.html @@ -103,8 +103,7 @@

    Overview

    - -

    Test probe. Also base for all “reactive” nodes.

    +

    Test probe. Also base for all "reactive" nodes.

    @@ -114,7 +113,7 @@

    Direct Known Subclasses

    -

    Handler, ServeHandler

    +

    Handlers::Handler, Handlers::Serve

    @@ -145,8 +144,7 @@ -
    -

    Returns the value of attribute properties.

    +

    Returns the value of attribute properties.

    @@ -189,8 +187,7 @@ -
    -

    A new instance of Probe.

    +

    A new instance of Probe.

    @@ -213,8 +210,7 @@ -
    -

    Method callback on successful request navigation.

    +

    Method callback on successful request navigation.

    @@ -248,8 +244,7 @@
    - -

    Returns a new instance of Probe.

    +

    Returns a new instance of Probe.

    @@ -289,12 +284,12 @@
     
     
    -23
    -24
    -25
    +41 +42 +43
    -
    # File 'lib/hyde/probe.rb', line 23
    +      
    # File 'lib/hyde/probe.rb', line 41
     
     def initialize(path, parent:)
       super(path, parent: parent)
    @@ -322,8 +317,7 @@
       
     
    - -

    Returns the value of attribute properties.

    +

    Returns the value of attribute properties.

    @@ -337,12 +331,12 @@
     
     
    -27
    -28
    -29
    +45 +46 +47
    -
    # File 'lib/hyde/probe.rb', line 27
    +      
    # File 'lib/hyde/probe.rb', line 45
     
     def properties
       @properties
    @@ -370,8 +364,9 @@
       
     
    - -

    Method callback on successful request navigation. Throws an error upon reaching the path. This behaviour should only be used internally.

    +

    Method callback on successful request navigation. +Throws an error upon reaching the path. +This behaviour should only be used internally.

    @@ -404,8 +399,7 @@ — -
    -

    true if further navigation is possible

    +

    true if further navigation is possible

    @@ -431,17 +425,17 @@
     
     
    -35
    -36
    -37
    -38
    -39
    -40
    -41
    -42
    +53 +54 +55 +56 +57 +58 +59 +60
    -
    # File 'lib/hyde/probe.rb', line 35
    +      
    # File 'lib/hyde/probe.rb', line 53
     
     def process(request)
       return reject(request) unless request.path.match?(/^\/?$/)
    @@ -461,7 +455,7 @@
     
     
           
    diff --git a/doc/Hyde/ProbeContext.html b/doc/Hyde/ProbeContext.html
    new file mode 100644
    index 0000000..7447eb1
    --- /dev/null
    +++ b/doc/Hyde/ProbeContext.html
    @@ -0,0 +1,249 @@
    +
    +
    +  
    +    
    +
    +
    +  Class: Hyde::ProbeContext
    +  
    +    — Documentation by YARD 0.9.34
    +  
    +
    +
    +  
    +
    +  
    +
    +
    +
    +
    +  
    +
    +  
    +
    +
    +  
    +  
    +    
    +
    +    
    + + +

    Class: Hyde::ProbeContext + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + +
    +
    Includes:
    +
    DSL::CommonMethods, DSL::ProbeConstructors, DSL::ProbeMethods
    +
    + + + + + + +
    +
    Defined in:
    +
    lib/hyde/probe.rb
    +
    + +
    + +

    Overview

    +
    +

    Context that provides execution context for Probes.

    + + +
    +
    +
    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + + + + +

    Methods included from DSL::CommonMethods

    +

    #bounce, #die

    + + + + + + + + + +

    Methods included from DSL::ProbeMethods

    +

    #file, #form, #form?, #header, #remove_header, #request, #status

    + + + + + + + + + +

    Methods included from DSL::ProbeConstructors

    +

    #erb

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(origin) ⇒ ProbeContext + + + + + +

    +
    +

    Returns a new instance of ProbeContext.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +32
    +33
    +34
    +
    +
    # File 'lib/hyde/probe.rb', line 32
    +
    +def initialize(origin)
    +  @origin = origin
    +end
    +
    +
    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/ProcessorContext.html b/doc/Hyde/ProcessorContext.html new file mode 100644 index 0000000..b902533 --- /dev/null +++ b/doc/Hyde/ProcessorContext.html @@ -0,0 +1,227 @@ + + + + + + + Class: Hyde::ProcessorContext + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Hyde::ProcessorContext + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + +
    +
    Includes:
    +
    DSL::CommonMethods
    +
    + + + + + + +
    +
    Defined in:
    +
    lib/hyde/path.rb
    +
    + +
    + +

    Overview

    +
    +

    Execution context for filters and preprocessors.

    + + +
    +
    +
    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + + + + +

    Methods included from DSL::CommonMethods

    +

    #bounce, #die

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(path) ⇒ ProcessorContext + + + + + +

    +
    +

    Returns a new instance of ProcessorContext.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +15
    +16
    +17
    +
    +
    # File 'lib/hyde/path.rb', line 15
    +
    +def initialize(path)
    +  @origin = path
    +end
    +
    +
    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Request.html b/doc/Hyde/Request.html index 9efd6fe..1ad005f 100644 --- a/doc/Hyde/Request.html +++ b/doc/Hyde/Request.html @@ -101,8 +101,7 @@

    Overview

    - -

    Request wrapper for Rack protocol

    +

    Request wrapper for Rack protocol

    @@ -137,8 +136,7 @@ -
    -

    Returns the value of attribute filepath.

    +

    Returns the value of attribute filepath.

    @@ -166,8 +164,7 @@ -
    -

    Returns the value of attribute headers.

    +

    Returns the value of attribute headers.

    @@ -195,8 +192,7 @@ -
    -

    Returns the value of attribute param.

    +

    Returns the value of attribute param.

    @@ -222,8 +218,7 @@ -
    -

    Returns the value of attribute path.

    +

    Returns the value of attribute path.

    @@ -251,8 +246,7 @@ -
    -

    Returns the value of attribute path_info.

    +

    Returns the value of attribute path_info.

    @@ -280,8 +274,7 @@ -
    -

    Returns the value of attribute postprocessors.

    +

    Returns the value of attribute postprocessors.

    @@ -309,8 +302,7 @@ -
    -

    Returns the value of attribute query.

    +

    Returns the value of attribute query.

    @@ -338,8 +330,7 @@ -
    -

    Returns the value of attribute request_method.

    +

    Returns the value of attribute request_method.

    @@ -367,8 +358,7 @@ -
    -

    Returns the value of attribute script_name.

    +

    Returns the value of attribute script_name.

    @@ -396,8 +386,7 @@ -
    -

    Returns the value of attribute server_name.

    +

    Returns the value of attribute server_name.

    @@ -425,8 +414,7 @@ -
    -

    Returns the value of attribute server_port.

    +

    Returns the value of attribute server_port.

    @@ -454,8 +442,7 @@ -
    -

    Returns the value of attribute server_protocol.

    +

    Returns the value of attribute server_protocol.

    @@ -483,8 +470,7 @@ -
    -

    Returns the value of attribute splat.

    +

    Returns the value of attribute splat.

    @@ -520,8 +506,7 @@ -
    -

    Returns request body (if POST data exists).

    +

    Returns request body (if POST data exists).

    @@ -546,8 +531,30 @@ -
    -

    A new instance of Request.

    +

    A new instance of Request.

    +
    + + + + +
  • + + + #input ⇒ IO + + + + + + + + + + + + + +

    Returns raw Rack input object.

  • @@ -570,8 +577,7 @@ -
    -

    Load last navigation state (path, splat, param) from state stack.

    +

    Load last navigation state (path, splat, param) from state stack.

    @@ -594,8 +600,7 @@ -
    -

    Push current navigation state (path, splat, param) onto state stack.

    +

    Push current navigation state (path, splat, param) onto state stack.

    @@ -618,8 +623,7 @@ -
    -

    Run postprocessors.

    +

    Run postprocessors.

    @@ -642,8 +646,7 @@
    - -

    Returns a new instance of Request.

    +

    Returns a new instance of Request.

    @@ -703,7 +706,7 @@ # Rack environment variable bindings. Should be public and frozen. init_request_params(env) # Query parsing - @query = Query.new(@query_string) + @query = Hyde::Util::Query.new(@query_string) # Pattern matching parameters. Public, readable, unfrozen. @param = {} @splat = [] @@ -741,8 +744,7 @@
    - -

    Returns the value of attribute filepath.

    +

    Returns the value of attribute filepath.

    @@ -756,12 +758,12 @@
     
     
    -59
    -60
    -61
    +65 +66 +67
    -
    # File 'lib/hyde/request.rb', line 59
    +      
    # File 'lib/hyde/request.rb', line 65
     
     def filepath
       @filepath
    @@ -784,8 +786,7 @@
       
     
    - -

    Returns the value of attribute headers.

    +

    Returns the value of attribute headers.

    @@ -799,12 +800,12 @@
     
     
    -56
    -57
    -58
    +62 +63 +64
    -
    # File 'lib/hyde/request.rb', line 56
    +      
    # File 'lib/hyde/request.rb', line 62
     
     def headers
       @headers
    @@ -827,8 +828,7 @@
       
     
    - -

    Returns the value of attribute param.

    +

    Returns the value of attribute param.

    @@ -842,12 +842,12 @@
     
     
    -56
    -57
    -58
    +62 +63 +64
    -
    # File 'lib/hyde/request.rb', line 56
    +      
    # File 'lib/hyde/request.rb', line 62
     
     def param
       @param
    @@ -870,8 +870,7 @@
       
     
    - -

    Returns the value of attribute path.

    +

    Returns the value of attribute path.

    @@ -885,12 +884,12 @@
     
     
    -59
    -60
    -61
    +65 +66 +67
    -
    # File 'lib/hyde/request.rb', line 59
    +      
    # File 'lib/hyde/request.rb', line 65
     
     def path
       @path
    @@ -913,8 +912,7 @@
       
     
    - -

    Returns the value of attribute path_info.

    +

    Returns the value of attribute path_info.

    @@ -928,12 +926,12 @@
     
     
    -56
    -57
    -58
    +62 +63 +64
    -
    # File 'lib/hyde/request.rb', line 56
    +      
    # File 'lib/hyde/request.rb', line 62
     
     def path_info
       @path_info
    @@ -956,8 +954,7 @@
       
     
    - -

    Returns the value of attribute postprocessors.

    +

    Returns the value of attribute postprocessors.

    @@ -971,12 +968,12 @@
     
     
    -56
    -57
    -58
    +62 +63 +64
    -
    # File 'lib/hyde/request.rb', line 56
    +      
    # File 'lib/hyde/request.rb', line 62
     
     def postprocessors
       @postprocessors
    @@ -999,8 +996,7 @@
       
     
    - -

    Returns the value of attribute query.

    +

    Returns the value of attribute query.

    @@ -1014,12 +1010,12 @@
     
     
    -56
    -57
    -58
    +62 +63 +64
    -
    # File 'lib/hyde/request.rb', line 56
    +      
    # File 'lib/hyde/request.rb', line 62
     
     def query
       @query
    @@ -1042,8 +1038,7 @@
       
     
    - -

    Returns the value of attribute request_method.

    +

    Returns the value of attribute request_method.

    @@ -1057,12 +1052,12 @@
     
     
    -56
    -57
    -58
    +62 +63 +64
    -
    # File 'lib/hyde/request.rb', line 56
    +      
    # File 'lib/hyde/request.rb', line 62
     
     def request_method
       @request_method
    @@ -1085,8 +1080,7 @@
       
     
    - -

    Returns the value of attribute script_name.

    +

    Returns the value of attribute script_name.

    @@ -1100,12 +1094,12 @@
     
     
    -56
    -57
    -58
    +62 +63 +64
    -
    # File 'lib/hyde/request.rb', line 56
    +      
    # File 'lib/hyde/request.rb', line 62
     
     def script_name
       @script_name
    @@ -1128,8 +1122,7 @@
       
     
    - -

    Returns the value of attribute server_name.

    +

    Returns the value of attribute server_name.

    @@ -1143,12 +1136,12 @@
     
     
    -56
    -57
    -58
    +62 +63 +64
    -
    # File 'lib/hyde/request.rb', line 56
    +      
    # File 'lib/hyde/request.rb', line 62
     
     def server_name
       @server_name
    @@ -1171,8 +1164,7 @@
       
     
    - -

    Returns the value of attribute server_port.

    +

    Returns the value of attribute server_port.

    @@ -1186,12 +1178,12 @@
     
     
    -56
    -57
    -58
    +62 +63 +64
    -
    # File 'lib/hyde/request.rb', line 56
    +      
    # File 'lib/hyde/request.rb', line 62
     
     def server_port
       @server_port
    @@ -1214,8 +1206,7 @@
       
     
    - -

    Returns the value of attribute server_protocol.

    +

    Returns the value of attribute server_protocol.

    @@ -1229,12 +1220,12 @@
     
     
    -56
    -57
    -58
    +62 +63 +64
    -
    # File 'lib/hyde/request.rb', line 56
    +      
    # File 'lib/hyde/request.rb', line 62
     
     def server_protocol
       @server_protocol
    @@ -1257,8 +1248,7 @@
       
     
    - -

    Returns the value of attribute splat.

    +

    Returns the value of attribute splat.

    @@ -1272,12 +1262,12 @@
     
     
    -56
    -57
    -58
    +62 +63 +64
    -
    # File 'lib/hyde/request.rb', line 56
    +      
    # File 'lib/hyde/request.rb', line 62
     
     def splat
       @splat
    @@ -1305,8 +1295,7 @@
       
     
    - -

    Returns request body (if POST data exists)

    +

    Returns request body (if POST data exists)

    @@ -1341,7 +1330,64 @@
    # File 'lib/hyde/request.rb', line 42
     
     def body
    -  @body ||= @rack.input&.gets
    +  @body ||= @rack.input&.read
    +end
    +
    +
    + +
    +

    + + #inputIO + + + + + +

    +
    +

    Returns raw Rack input object

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (IO) + + + + — +

      (May not entirely be compatible with IO, see Rack/SPEC.rdoc)

      +
      + +
    • + +
    + +
    + + + @@ -1359,8 +1405,7 @@
    - -

    Load last navigation state (path, splat, param) from state stack

    +

    Load last navigation state (path, splat, param) from state stack

    @@ -1374,12 +1419,12 @@
     
     
    -52
    -53
    -54
    +58 +59 +60
    + +
    +
    +
    +
    +48
    +49
    +50
    +
    +
    # File 'lib/hyde/request.rb', line 48
    +
    +def input
    +  @rack.input
     end
    -
    # File 'lib/hyde/request.rb', line 52
    +      
    # File 'lib/hyde/request.rb', line 58
     
     def pop_state
       @path, @param, @splat, @filepath = @states.pop
    @@ -1400,8 +1445,7 @@
       
     
    - -

    Push current navigation state (path, splat, param) onto state stack

    +

    Push current navigation state (path, splat, param) onto state stack

    @@ -1415,12 +1459,12 @@
     
     
    -47
    -48
    -49
    +53 +54 +55
    -
    # File 'lib/hyde/request.rb', line 47
    +      
    # File 'lib/hyde/request.rb', line 53
     
     def push_state
       @states.push([@path, @param.dup, @splat.dup, @filepath.dup])
    @@ -1441,8 +1485,7 @@
       
     
    - -

    Run postprocessors

    +

    Run postprocessors

    @@ -1495,7 +1538,7 @@
    diff --git a/doc/Hyde/Response.html b/doc/Hyde/Response.html index e5fa4ba..7900382 100644 --- a/doc/Hyde/Response.html +++ b/doc/Hyde/Response.html @@ -101,8 +101,7 @@

    Overview

    - -

    Rack protocol response wrapper.

    +

    Rack protocol response wrapper.

    @@ -137,8 +136,7 @@ -
    -

    Returns the value of attribute body.

    +

    Returns the value of attribute body.

    @@ -164,8 +162,7 @@ -
    -

    Returns the value of attribute chunk_size.

    +

    Returns the value of attribute chunk_size.

    @@ -191,8 +188,7 @@ -
    -

    Returns the value of attribute headers.

    +

    Returns the value of attribute headers.

    @@ -218,8 +214,7 @@ -
    -

    Returns the value of attribute status.

    +

    Returns the value of attribute status.

    @@ -255,8 +250,7 @@ -
    -

    Turn body into array of chunks.

    +

    Turn body into array of chunks.

    @@ -279,8 +273,7 @@ -
    -

    Ensure response correctness.

    +

    Ensure response correctness.

    @@ -312,8 +305,7 @@ -
    -

    Add a header to the headers hash.

    +

    Add a header to the headers hash.

    @@ -336,8 +328,7 @@ -
    -

    Delete a header value from the headers hash If no value is provided, deletes all key entries.

    +

    Delete a header value from the headers hash If no value is provided, deletes all key entries.

    @@ -360,8 +351,7 @@ -
    -

    Return internal representation of Rack response.

    +

    Return internal representation of Rack response.

    @@ -386,8 +376,7 @@ -
    -

    A new instance of Response.

    +

    A new instance of Response.

    @@ -410,8 +399,7 @@ -
    -

    Make internal representation conformant.

    +

    Make internal representation conformant.

    @@ -434,8 +422,7 @@
    - -

    Returns a new instance of Response.

    +

    Returns a new instance of Response.

    @@ -515,8 +502,7 @@
    - -

    Returns the value of attribute body.

    +

    Returns the value of attribute body.

    @@ -558,8 +544,7 @@
    - -

    Returns the value of attribute chunk_size.

    +

    Returns the value of attribute chunk_size.

    @@ -601,8 +586,7 @@
    - -

    Returns the value of attribute headers.

    +

    Returns the value of attribute headers.

    @@ -644,8 +628,7 @@
    - -

    Returns the value of attribute status.

    +

    Returns the value of attribute status.

    @@ -692,8 +675,7 @@
    - -

    Turn body into array of chunks

    +

    Turn body into array of chunks

    @@ -761,8 +743,7 @@
    - -

    Ensure response correctness

    +

    Ensure response correctness

    @@ -795,8 +776,7 @@ -
    -

    Response

    +

    Response

    @@ -867,8 +847,7 @@
    - -

    Add a header to the headers hash

    +

    Add a header to the headers hash

    @@ -887,8 +866,7 @@ — -
    -

    header name

    +

    header name

    @@ -903,8 +881,7 @@ — -
    -

    header value

    +

    header value

    @@ -956,8 +933,8 @@
    - -

    Delete a header value from the headers hash If no value is provided, deletes all key entries

    +

    Delete a header value from the headers hash +If no value is provided, deletes all key entries

    @@ -976,8 +953,7 @@ — -
    -

    header name

    +

    header name

    @@ -994,8 +970,7 @@ — -
    -

    header value

    +

    header value

    @@ -1043,8 +1018,7 @@
    - -

    Return internal representation of Rack response

    +

    Return internal representation of Rack response

    @@ -1097,8 +1071,7 @@
    - -

    Make internal representation conformant

    +

    Make internal representation conformant

    @@ -1167,7 +1140,7 @@
    diff --git a/doc/Hyde/ServeHandler.html b/doc/Hyde/ServeHandler.html index eb34b2e..1d0b2d9 100644 --- a/doc/Hyde/ServeHandler.html +++ b/doc/Hyde/ServeHandler.html @@ -307,12 +307,12 @@
     
     
    +11
     12
    -13
    -14
    +13
    -
    # File 'lib/hyde/probe/serve_handler.rb', line 12
    +      
    # File 'lib/hyde/probe/serve_handler.rb', line 11
     
     def initialize(path, parent:)
       super(path, parent: parent)
    @@ -355,12 +355,12 @@
           
     
     
    +15
     16
    -17
    -18
    +17
    -
    # File 'lib/hyde/probe/serve_handler.rb', line 16
    +      
    # File 'lib/hyde/probe/serve_handler.rb', line 15
     
     def response
       @response
    @@ -436,17 +436,17 @@
           
     
     
    +21
     22
     23
     24
     25
     26
     27
    -28
    -29
    +28
    -
    # File 'lib/hyde/probe/serve_handler.rb', line 22
    +      
    # File 'lib/hyde/probe/serve_handler.rb', line 21
     
     def process(request)
       path = File.expand_path(request.filepath)
    @@ -466,7 +466,7 @@
     
     
           
    diff --git a/doc/Hyde/Server.html b/doc/Hyde/Server.html
    index 0166536..99c4cac 100644
    --- a/doc/Hyde/Server.html
    +++ b/doc/Hyde/Server.html
    @@ -105,8 +105,7 @@
     
     

    Overview

    - -

    A specialized path that can be used directly as a Rack application.

    +

    A specialized path that can be used directly as a Rack application.

    @@ -123,16 +122,22 @@
    -
    Binding = +
    Context =
    -
    ServerBinding
    +
    ServerContext
    + + +

    Constants inherited + from Path

    +

    Path::ProcContext

    + @@ -172,8 +177,7 @@ -
    -

    Rack ingress point.

    +

    Rack ingress point.

    @@ -198,8 +202,7 @@ -
    -

    A new instance of Server.

    +

    A new instance of Server.

    @@ -244,8 +247,7 @@
    - -

    Returns a new instance of Server.

    +

    Returns a new instance of Server.

    @@ -266,8 +268,7 @@ — -
    -

    Parent object to inherit properties to

    +

    Parent object to inherit properties to

    @@ -282,8 +283,7 @@ — -
    -

    Setup block

    +

    Setup block

    @@ -297,6 +297,7 @@
     
     
    +17
     18
     19
     20
    @@ -312,11 +313,10 @@
     30
     31
     32
    -33
    -34
    +33
    -
    # File 'lib/hyde/server.rb', line 18
    +      
    # File 'lib/hyde/server.rb', line 17
     
     def initialize(parent: nil, &setup)
       super("", parent: parent, &setup)
    @@ -358,8 +358,9 @@
       
     
    - -

    Rack ingress point. This should not be called under any circumstances twice in the same application, although server nesting for the purpose of creating virtual hosts is allowed.

    +

    Rack ingress point. +This should not be called under any circumstances twice in the same application, +although server nesting for the purpose of creating virtual hosts is allowed.

    @@ -401,17 +402,17 @@
     
     
    +40
     41
     42
     43
     44
     45
     46
    -47
    -48
    +47
    -
    # File 'lib/hyde/server.rb', line 41
    +      
    # File 'lib/hyde/server.rb', line 40
     
     def call(env)
       request = Hyde::Request.new(env)
    @@ -431,7 +432,7 @@
     
     
           
    diff --git a/doc/Hyde/ServerContext.html b/doc/Hyde/ServerContext.html
    new file mode 100644
    index 0000000..76d4d19
    --- /dev/null
    +++ b/doc/Hyde/ServerContext.html
    @@ -0,0 +1,162 @@
    +
    +
    +  
    +    
    +
    +
    +  Class: Hyde::ServerContext
    +  
    +    — Documentation by YARD 0.9.34
    +  
    +
    +
    +  
    +
    +  
    +
    +
    +
    +
    +  
    +
    +  
    +
    +
    +  
    +  
    +    
    +
    +    
    + + +

    Class: Hyde::ServerContext + + + +

    +
    + +
    +
    Inherits:
    +
    + PathContext + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/server.rb
    +
    + +
    + + + + + + + + + + + + + + + +

    Method Summary

    + +

    Methods inherited from PathContext

    +

    #initialize

    + + + + + + + + + +

    Methods included from DSL::PathMethods

    +

    #filter, #index, #postprocess, #preprocess, #remap, #root

    + + + + + + + + + +

    Methods included from DSL::PathConstructors

    +

    #connect, #delete, #get, #head, #options, #patch, #path, #post, #probe, #put, #register, #serve, #trace

    +
    +

    Constructor Details

    + +

    This class inherits a constructor from Hyde::PathContext

    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/TRACEHandler.html b/doc/Hyde/TRACEHandler.html index 30a8e7e..169d3a8 100644 --- a/doc/Hyde/TRACEHandler.html +++ b/doc/Hyde/TRACEHandler.html @@ -211,7 +211,7 @@ diff --git a/doc/Hyde/Template.html b/doc/Hyde/Template.html new file mode 100644 index 0000000..3e7cfea --- /dev/null +++ b/doc/Hyde/Template.html @@ -0,0 +1,763 @@ + + + + + + + Class: Hyde::Template + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Hyde::Template + Abstract + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/template.rb
    +
    + +
    + +

    Overview

    +
    +
    + This class is abstract. +

    does not represent any actual template engine.

    +
    +
    +

    Interface for Template engines

    + + +
    +
    +
    + + +
    +

    Direct Known Subclasses

    +

    Hyde::Templates::ERB

    +
    + + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #binding ⇒ Object + + + + + + + + + + + + + + + + +

      Returns the value of attribute binding.

      +
      + +
    • + + +
    + + + + + +

    + Instance Method Summary + collapse +

    + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(input, toplevel: nil, locals: nil) ⇒ Template + + + + + +

    +
    +

    Returns a new instance of Template.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + input + + + (String, File) + + + +
    • + +
    • + + context + + + (Binding, nil) + + + +
    • + +
    • + + locals + + + (Hash, nil) + + + (defaults to: nil) + + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +30
    +31
    +32
    +33
    +34
    +35
    +36
    +37
    +38
    +
    +
    # File 'lib/hyde/template.rb', line 30
    +
    +def initialize(input, toplevel: nil, locals: nil)
    +  @template = input.is_a?(File) ? input.read : input
    +  input.close if input.is_a? File
    +  @binding = toplevel or binding
    +  locals&.each do |k, v|
    +    @binding.local_variable_set(k,v)
    +  end
    +  @context = TemplateContext.new(self)
    +end
    +
    +
    + +
    + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #bindingObject + + + + + +

    +
    +

    Returns the value of attribute binding.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +74
    +75
    +76
    +
    +
    # File 'lib/hyde/template.rb', line 74
    +
    +def binding
    +  @binding
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #local_variable_get(key) ⇒ Object + + + + + +

    +
    +

    Get local variable

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + key + + + (Symbol) + + + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Object) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +50
    +51
    +52
    +
    +
    # File 'lib/hyde/template.rb', line 50
    +
    +def local_variable_get(key)
    +  @binding.local_variable_get(key)
    +end
    +
    +
    + +
    +

    + + #local_variable_set(key, value) ⇒ Object + + + + + +

    +
    +

    Set local variable

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + key + + + (Symbol) + + + +
    • + +
    • + + value + + + (Object) + + + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +43
    +44
    +45
    +
    +
    # File 'lib/hyde/template.rb', line 43
    +
    +def local_variable_set(key, value)
    +  @binding.local_variable_set(key, value)
    +end
    +
    +
    + +
    +

    + + #local_variablesArray(Symbol) + + + + + +

    +
    +

    Get an array of defined local variables

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Array(Symbol)) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +56
    +57
    +58
    +
    +
    # File 'lib/hyde/template.rb', line 56
    +
    +def local_variables
    +  @binding.local_variables
    +end
    +
    +
    + +
    +

    + + #override_locals(vars) ⇒ Object + + + + + +

    +
    +

    Override binding variables.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + vars + + + (Hash{Symbol => Object}) + + + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +62
    +63
    +64
    +65
    +66
    +
    +
    # File 'lib/hyde/template.rb', line 62
    +
    +def override_locals(vars)
    +  vars.each do |k, v|
    +    @binding.local_variable_set(k, v)
    +  end
    +end
    +
    +
    + +
    +

    + + #runObject + + + + + +

    +
    + +
    + Note: +

    This method is a stub.

    +
    +
    + +

    Run the template

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +70
    +71
    +72
    +
    +
    # File 'lib/hyde/template.rb', line 70
    +
    +def run
    +  # ... (stub)
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/TemplateContext.html b/doc/Hyde/TemplateContext.html new file mode 100644 index 0000000..76d099d --- /dev/null +++ b/doc/Hyde/TemplateContext.html @@ -0,0 +1,249 @@ + + + + + + + Class: Hyde::TemplateContext + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Hyde::TemplateContext + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + +
    +
    Includes:
    +
    DSL::CommonMethods, DSL::ProbeConstructors, DSL::ProbeMethods
    +
    + + + + + + +
    +
    Defined in:
    +
    lib/hyde/template.rb
    +
    + +
    + +

    Overview

    +
    +

    Context for template engines

    + + +
    +
    +
    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + + + + +

    Methods included from DSL::ProbeConstructors

    +

    #erb

    + + + + + + + + + +

    Methods included from DSL::ProbeMethods

    +

    #file, #form, #form?, #header, #remove_header, #request, #status

    + + + + + + + + + +

    Methods included from DSL::CommonMethods

    +

    #bounce, #die

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(parent) ⇒ TemplateContext + + + + + +

    +
    +

    Returns a new instance of TemplateContext.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +19
    +20
    +21
    +
    +
    # File 'lib/hyde/template.rb', line 19
    +
    +def initialize(parent)
    +  @origin = parent
    +end
    +
    +
    + +
    + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Templates.html b/doc/Hyde/Templates.html new file mode 100644 index 0000000..5a658e6 --- /dev/null +++ b/doc/Hyde/Templates.html @@ -0,0 +1,127 @@ + + + + + + + Module: Hyde::Templates + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: Hyde::Templates + + + +

    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/template.rb,
    + lib/hyde/template/erb.rb
    +
    +
    + +
    + +

    Overview

    +
    +

    All template engine adapters subclassed from Template

    + + +
    +
    +
    + + +

    Defined Under Namespace

    +

    + + + + + Classes: ERB + + +

    + + + + + + + + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Templates/ERB.html b/doc/Hyde/Templates/ERB.html new file mode 100644 index 0000000..4faaf33 --- /dev/null +++ b/doc/Hyde/Templates/ERB.html @@ -0,0 +1,311 @@ + + + + + + + Class: Hyde::Templates::ERB + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Hyde::Templates::ERB + + + +

    +
    + +
    +
    Inherits:
    +
    + Hyde::Template + + + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/template/erb.rb
    +
    + +
    + +

    Overview

    +
    +

    ERB Template language adapter

    + + +
    +
    +
    + + +
    + + + + + +

    Instance Attribute Summary

    + +

    Attributes inherited from Hyde::Template

    +

    #binding

    + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + + + + +

    Methods inherited from Hyde::Template

    +

    #local_variable_get, #local_variable_set, #local_variables, #override_locals

    +
    +

    Constructor Details

    + +
    +

    + + #initialize(input, toplevel: nil, locals: nil) ⇒ ERB + + + + + +

    +
    +

    Returns a new instance of ERB.

    + + +
    +
    +
    + + +

    See Also:

    +
      + +
    • Hyde::Template#new
    • + +
    + +
    + + + + +
    +
    +
    +
    +11
    +12
    +13
    +14
    +
    +
    # File 'lib/hyde/template/erb.rb', line 11
    +
    +def initialize(input, toplevel: nil, locals: nil)
    +  super
    +  @template = ::ERB.new(@template)
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #runObject + + + + + +

    +
    +

    Run the template.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +17
    +18
    +19
    +20
    +21
    +
    +
    # File 'lib/hyde/template/erb.rb', line 17
    +
    +def run
    +  @context.instance_exec(@template) do |template|
    +    template.result @binding
    +  end
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Util.html b/doc/Hyde/Util.html index c44f07c..887da0a 100644 --- a/doc/Hyde/Util.html +++ b/doc/Hyde/Util.html @@ -79,7 +79,7 @@
    Defined in:
    lib/hyde/util/lookup.rb,
    - lib/hyde/util/html.rb,
    lib/hyde/util/query.rb
    + lib/hyde/util/html.rb,
    lib/hyde/util/query.rb,
    lib/hyde/util/header.rb,
    lib/hyde/util/sorting.rb,
    lib/hyde/util/multipart.rb
    @@ -87,8 +87,7 @@

    Overview

    - -

    Various things that exists for purely logical reasons

    +

    Various things that exists for purely logical reasons

    @@ -100,9 +99,11 @@

    + Modules: ParserCommon + - Classes: Lookup, Query + Classes: FormPart, Lookup, MultipartParser, Query

    @@ -118,8 +119,8 @@
    HTTP_STATUS =
    - -

    HTTP status codes and descriptions Taken from WEBrick https://github.com/ruby/webrick/blob/master/lib/webrick/httpstatus.rb

    +

    HTTP status codes and descriptions +Taken from WEBrick https://github.com/ruby/webrick/blob/master/lib/webrick/httpstatus.rb

    @@ -165,6 +166,7 @@ 415 => 'Unsupported Media Type', 416 => 'Request Range Not Satisfiable', 417 => 'Expectation Failed', + 418 => "I'm a teapot", 422 => 'Unprocessable Entity', 423 => 'Locked', 424 => 'Failed Dependency', @@ -217,8 +219,7 @@ -
    -

    Default error page for Hyde.

    +

    Default error page for Hyde.

    @@ -241,8 +242,76 @@ -
    -

    Return string with escaped HTML entities.

    +

    Return string with escaped HTML entities.

    +
    + + + + +
  • + + + .make_value(input, opts, sep = ";") ⇒ String + + + + + + + + + + + + + +

    Construct a parametrized header value.

    +
    + +
  • + + +
  • + + + .parse_value(input, sep = ";") ⇒ Array(String, Hash) + + + + + + + + + + + + + +

    Parse parametrized header values.

    +
    + +
  • + + +
  • + + + .unescape_html(str) ⇒ String + + + + + + + + + + + + + +

    Return string with unescaped HTML entities.

  • @@ -268,8 +337,7 @@
    - -

    Default error page for Hyde

    +

    Default error page for Hyde

    @@ -288,8 +356,7 @@ — -
    -

    HTTP Status code

    +

    HTTP Status code

    @@ -304,8 +371,7 @@ — -
    -

    Message to show in backtrace window

    +

    Message to show in backtrace window

    @@ -332,15 +398,6 @@
     
     
    -78
    -79
    -80
    -81
    -82
    -83
    -84
    -85
    -86
     87
     88
     89
    @@ -358,10 +415,19 @@
     101
     102
     103
    -104
    +104 +105 +106 +107 +108 +109 +110 +111 +112 +113
    -
    # File 'lib/hyde/util/html.rb', line 78
    +      
    # File 'lib/hyde/util/html.rb', line 87
     
     def self.default_error_page(code, backtrace)
       backtrace ||= []
    @@ -407,7 +473,15 @@
     
    -

    Return string with escaped HTML entities

    +
    + Note: +

    Do not use this to inject untrusted input into JavaScript code

    +
    +
    + +

    Return string with escaped HTML entities. +or CSS style of the page. +This function is not adequate to prevent string interpolation.

    @@ -449,23 +523,279 @@
     
     
    -64
    -65
    -66
    -67
    -68
    -69
    -70
    +70 +71 +72
    -
    # File 'lib/hyde/util/html.rb', line 64
    +      
    # File 'lib/hyde/util/html.rb', line 70
     
     def self.escape_html(str)
    -  str.gsub("&", "&")
    -     .gsub("<", "&lt;")
    -     .gsub(">", "&gt;")
    -     .gsub("\"", "&quot;")
    -     .gsub("'", "&#39;")
    +  CGI.escapeHTML(str)
    +end
    +
    +
    + +
    +

    + + .make_value(input, opts, sep = ";") ⇒ String + + + + + +

    +
    +

    Construct a parametrized header value

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + input + + + (String) + + + +
    • + +
    • + + opts + + + (Hash) + + + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +25
    +26
    +27
    +28
    +29
    +30
    +31
    +32
    +33
    +34
    +35
    +36
    +37
    +38
    +39
    +
    +
    # File 'lib/hyde/util/header.rb', line 25
    +
    +def self.make_value(input, opts, sep = ";")
    +  unless input.match?(/^[\w!#$%&'*+-.^_`|~]*=?[^[:cntrl:]\\",;]+$/)
    +    raise StandardError, "input contains invalid characters"
    +  end
    +
    +  output = input
    +  opts.each do |key, value|
    +    output += if value.is_a? String
    +                "#{sep} #{key}=#{value}"
    +              else
    +                "#{sep} #{key}"
    +              end
    +  end
    +  output
    +end
    +
    +
    + +
    +

    + + .parse_value(input, sep = ";") ⇒ Array(String, Hash) + + + + + +

    +
    +

    Parse parametrized header values

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + input + + + (String) + + + +
    • + +
    • + + sep + + + (String, Regexp) + + + (defaults to: ";") + + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (Array(String, Hash)) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +11
    +12
    +13
    +14
    +15
    +16
    +17
    +18
    +19
    +
    +
    # File 'lib/hyde/util/header.rb', line 11
    +
    +def self.parse_value(input, sep = ";")
    +  parts = input.split(sep).map { |x| URI.decode_uri_component(x).strip }
    +  base = parts.shift
    +  opts = parts.map do |raw|
    +    key, value = raw.match(/^([^=]*)(?:=(.*)|)\Z/).to_a[1..]
    +    [key, ((value&.match?(/^".*"$/) ? value[1..-2] : value) or true)]
    +  end.to_h
    +  [base, opts]
    +end
    +
    +
    + +
    +

    + + .unescape_html(str) ⇒ String + + + + + +

    +
    +

    Return string with unescaped HTML entities.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + str + + + (String) + + + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + +
    • + +
    + +
    + + + @@ -477,7 +807,7 @@ diff --git a/doc/Hyde/Util/FormPart.html b/doc/Hyde/Util/FormPart.html new file mode 100644 index 0000000..c70987c --- /dev/null +++ b/doc/Hyde/Util/FormPart.html @@ -0,0 +1,857 @@ + + + + + + + Class: Hyde::Util::FormPart + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Hyde::Util::FormPart + + + +

    +
    + +
    +
    Inherits:
    +
    + Struct + +
      +
    • Object
    • + + + + + +
    + show all + +
    +
    + + + + + + + + + + + +
    +
    Defined in:
    +
    lib/hyde/util/multipart.rb
    +
    + +
    + +

    Overview

    +
    +

    Valid element of form data with headers

    + + +
    +
    +
    + + +
    + + + +

    Instance Attribute Summary collapse

    +
      + +
    • + + + #data ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      Data received in the field through form data.

      +
      + +
    • + + +
    • + + + #filename ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      Original name of the sent file.

      +
      + +
    • + + +
    • + + + #filetype ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      MIME-type of the file.

      +
      + +
    • + + +
    • + + + #name ⇒ Object + + + + + + + + + readonly + + + + + + + + + +

      name of the form part.

      +
      + +
    • + + +
    + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + +
    +

    Instance Attribute Details

    + + + +
    +

    + + #dataObject (readonly) + + + + + +

    +
    +

    Data received in the field through form data

    + + +
    +
    +
    + + +
    +
    +
    +
    +77
    +78
    +79
    +
    +
    # File 'lib/hyde/util/html.rb', line 77
    +
    +def self.unescape_html(str)
    +  CGI.unescapeHTML(str)
     end
    + + + + +
    +
    +
    +
    +17
    +18
    +19
    +20
    +21
    +22
    +23
    +24
    +25
    +26
    +27
    +28
    +29
    +30
    +
    +
    # File 'lib/hyde/util/multipart.rb', line 17
    +
    +FormPart = Struct.new(:data, :name, :filename,
    +                      :filetype, :tempfile, :headers) do
    +  # Is this form part a file or plain data?
    +  # @return [Boolean]
    +  def file?
    +    !tempfile.nil?
    +  end
    +
    +  # If FormPart is not a file, simplify to string.
    +  # @return [FormPart, String]
    +  def simplify
    +    file? ? self : self.data
    +  end
    +end
    +
    +
    + + + +
    +

    + + #filenameObject (readonly) + + + + + +

    +
    +

    Original name of the sent file

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +17
    +18
    +19
    +20
    +21
    +22
    +23
    +24
    +25
    +26
    +27
    +28
    +29
    +30
    +
    +
    # File 'lib/hyde/util/multipart.rb', line 17
    +
    +FormPart = Struct.new(:data, :name, :filename,
    +                      :filetype, :tempfile, :headers) do
    +  # Is this form part a file or plain data?
    +  # @return [Boolean]
    +  def file?
    +    !tempfile.nil?
    +  end
    +
    +  # If FormPart is not a file, simplify to string.
    +  # @return [FormPart, String]
    +  def simplify
    +    file? ? self : self.data
    +  end
    +end
    +
    +
    + + + +
    +

    + + #filetypeObject (readonly) + + + + + +

    +
    +

    MIME-type of the file

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +17
    +18
    +19
    +20
    +21
    +22
    +23
    +24
    +25
    +26
    +27
    +28
    +29
    +30
    +
    +
    # File 'lib/hyde/util/multipart.rb', line 17
    +
    +FormPart = Struct.new(:data, :name, :filename,
    +                      :filetype, :tempfile, :headers) do
    +  # Is this form part a file or plain data?
    +  # @return [Boolean]
    +  def file?
    +    !tempfile.nil?
    +  end
    +
    +  # If FormPart is not a file, simplify to string.
    +  # @return [FormPart, String]
    +  def simplify
    +    file? ? self : self.data
    +  end
    +end
    +
    +
    + + + +
    +

    + + #nameObject (readonly) + + + + + +

    +
    +

    name of the form part

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +17
    +18
    +19
    +20
    +21
    +22
    +23
    +24
    +25
    +26
    +27
    +28
    +29
    +30
    +
    +
    # File 'lib/hyde/util/multipart.rb', line 17
    +
    +FormPart = Struct.new(:data, :name, :filename,
    +                      :filetype, :tempfile, :headers) do
    +  # Is this form part a file or plain data?
    +  # @return [Boolean]
    +  def file?
    +    !tempfile.nil?
    +  end
    +
    +  # If FormPart is not a file, simplify to string.
    +  # @return [FormPart, String]
    +  def simplify
    +    file? ? self : self.data
    +  end
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #file?Boolean + + + + + +

    +
    +

    Is this form part a file or plain data?

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Boolean) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +21
    +22
    +23
    +
    +
    # File 'lib/hyde/util/multipart.rb', line 21
    +
    +def file?
    +  !tempfile.nil?
    +end
    +
    +
    + +
    +

    + + #headers=(value) ⇒ Object + + + + + +

    +
    +

    headers recevied from form data

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +17
    +18
    +19
    +20
    +21
    +22
    +23
    +24
    +25
    +26
    +27
    +28
    +29
    +30
    +
    +
    # File 'lib/hyde/util/multipart.rb', line 17
    +
    +FormPart = Struct.new(:data, :name, :filename,
    +                      :filetype, :tempfile, :headers) do
    +  # Is this form part a file or plain data?
    +  # @return [Boolean]
    +  def file?
    +    !tempfile.nil?
    +  end
    +
    +  # If FormPart is not a file, simplify to string.
    +  # @return [FormPart, String]
    +  def simplify
    +    file? ? self : self.data
    +  end
    +end
    +
    +
    + +
    +

    + + #simplifyFormPart, String + + + + + +

    +
    +

    If FormPart is not a file, simplify to string.

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (FormPart, String) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +27
    +28
    +29
    +
    +
    # File 'lib/hyde/util/multipart.rb', line 27
    +
    +def simplify
    +  file? ? self : self.data
    +end
    +
    +
    + +
    +

    + + #tempfile=(value) ⇒ Object + + + + + +

    +
    +

    Temporary file for storing sent file data.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +17
    +18
    +19
    +20
    +21
    +22
    +23
    +24
    +25
    +26
    +27
    +28
    +29
    +30
    +
    +
    # File 'lib/hyde/util/multipart.rb', line 17
    +
    +FormPart = Struct.new(:data, :name, :filename,
    +                      :filetype, :tempfile, :headers) do
    +  # Is this form part a file or plain data?
    +  # @return [Boolean]
    +  def file?
    +    !tempfile.nil?
    +  end
    +
    +  # If FormPart is not a file, simplify to string.
    +  # @return [FormPart, String]
    +  def simplify
    +    file? ? self : self.data
    +  end
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Util/Lookup.html b/doc/Hyde/Util/Lookup.html index 6af3b6f..a1fb651 100644 --- a/doc/Hyde/Util/Lookup.html +++ b/doc/Hyde/Util/Lookup.html @@ -101,8 +101,7 @@

    Overview

    - -

    Value container with recursive lookup

    +

    Value container with recursive lookup

    @@ -137,8 +136,7 @@ -
    -

    Returns the value of attribute parent.

    +

    Returns the value of attribute parent.

    @@ -174,8 +172,7 @@ -
    -

    Initialize a Lookup from Hash.

    +

    Initialize a Lookup from Hash.

    @@ -207,8 +204,7 @@ -
    -

    Get a value by key.

    +

    Get a value by key.

    @@ -231,8 +227,7 @@ -
    -

    Set a value by key.

    +

    Set a value by key.

    @@ -257,8 +252,7 @@ -
    -

    A new instance of Lookup.

    +

    A new instance of Lookup.

    @@ -281,8 +275,7 @@
    - -

    Returns a new instance of Lookup.

    +

    Returns a new instance of Lookup.

    @@ -348,8 +341,7 @@
    - -

    Returns the value of attribute parent.

    +

    Returns the value of attribute parent.

    @@ -396,8 +388,7 @@
    - -

    Initialize a Lookup from Hash

    +

    Initialize a Lookup from Hash

    @@ -458,8 +449,7 @@
    - -

    Get a value by key

    +

    Get a value by key

    @@ -478,8 +468,7 @@ — -
    -

    key for value

    +

    key for value

    @@ -532,8 +521,7 @@
    - -

    Set a value by key

    +

    Set a value by key

    @@ -552,8 +540,7 @@ — -
    -

    key for value

    +

    key for value

    @@ -568,8 +555,7 @@ — -
    -

    value value

    +

    value value

    @@ -603,7 +589,7 @@
    diff --git a/doc/Hyde/Util/MultipartParser.html b/doc/Hyde/Util/MultipartParser.html new file mode 100644 index 0000000..86ef9d3 --- /dev/null +++ b/doc/Hyde/Util/MultipartParser.html @@ -0,0 +1,487 @@ + + + + + + + Class: Hyde::Util::MultipartParser + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Class: Hyde::Util::MultipartParser + + + +

    +
    + +
    +
    Inherits:
    +
    + Object + +
      +
    • Object
    • + + + +
    + show all + +
    +
    + + + + + + +
    +
    Includes:
    +
    ParserCommon
    +
    + + + + + + +
    +
    Defined in:
    +
    lib/hyde/util/multipart.rb
    +
    + +
    + +

    Overview

    +
    +

    A very naive implementation of a Multipart form parser.

    + + +
    +
    +
    + + +
    + + + + + + + +

    + Instance Method Summary + collapse +

    + + + + + + + + + + +
    +

    Constructor Details

    + +
    +

    + + #initialize(io, boundary) ⇒ MultipartParser + + + + + +

    +
    +

    Returns a new instance of MultipartParser.

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +35
    +36
    +37
    +38
    +39
    +40
    +
    +
    # File 'lib/hyde/util/multipart.rb', line 35
    +
    +def initialize(io, boundary)
    +  @input = io.is_a?(String) ? StringIO.new(io) : io
    +  @boundary = boundary
    +  @state = :idle
    +  @data = []
    +end
    +
    +
    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + #parseArray<FormPart, FormFile> + + + + + +

    +
    +

    Parse multipart formdata

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Array<FormPart, FormFile>) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +48
    +49
    +50
    +51
    +52
    +53
    +54
    +55
    +56
    +57
    +58
    +59
    +60
    +61
    +62
    +63
    +64
    +65
    +66
    +67
    +68
    +69
    +70
    +71
    +72
    +73
    +74
    +75
    +76
    +77
    +78
    +79
    +80
    +81
    +82
    +83
    +84
    +85
    +86
    +87
    +88
    +89
    +90
    +91
    +92
    +93
    +94
    +95
    +96
    +97
    +98
    +99
    +100
    +
    +
    # File 'lib/hyde/util/multipart.rb', line 48
    +
    +def parse
    +  return @data unless @data.empty?
    +
    +  while (line = @input.gets)
    +    case @state
    +    when :idle # waiting for valid boundary
    +      if line == "--#{@boundary}\r\n"
    +        # transition to :headers on valid boundary
    +        @state = :headers
    +        @data.append(FormPart.new(*([nil] * 5), {}))
    +      end
    +    when :headers # after valid boundary - checking for headers
    +      if line == "\r\n"
    +        # prepare form field and transition to :data or :file
    +        @state = file?(@data[-1].headers) ? :file : :data
    +        if @state == :data
    +          setup_data_meta(@data[-1])
    +        else
    +          setup_file_meta(@data[-1])
    +        end
    +        next
    +      end
    +      push_header(line, @data[-1].headers)
    +    when :data, :file # after headers - processing form data
    +      if @data[-1].headers.empty?
    +        # transition to :idle on empty headers
    +        @state = :idle
    +        next
    +      end
    +      if ["--#{@boundary}\r\n", "--#{@boundary}--\r\n"].include? line
    +        # finalize and transition to either :headers or :idle
    +        if @state == :file
    +          @data[-1].tempfile.truncate(@data[-1].tempfile.size - 2)
    +          @data[-1].tempfile.close
    +        else
    +          @data[-1].data.delete_suffix! "\r\n"
    +        end
    +        @state = line == "--#{@boundary}\r\n" ? :headers : :idle
    +        @data.append(FormPart.new(*([nil] * 5), {}))
    +        next
    +      end
    +      if @state == :data
    +        @data[-1].data ||= ""
    +        @data[-1].data << line
    +      else
    +        @data[-1].tempfile << line
    +      end
    +    end
    +  end
    +  @state = :idle
    +  @data.pop
    +  @data.freeze
    +end
    +
    +
    + +
    +

    + + #to_hHash + + + + + +

    +
    +

    Return a hash of current form. +(equivalent to Query.parse but for multipart/form-data)

    + + +
    +
    +
    + +

    Returns:

    +
      + +
    • + + + (Hash) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +106
    +107
    +108
    +
    +
    # File 'lib/hyde/util/multipart.rb', line 106
    +
    +def to_h
    +  flatten(sort(gen_hash(parse)))
    +end
    +
    +
    + +
    + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Util/ParserCommon.html b/doc/Hyde/Util/ParserCommon.html new file mode 100644 index 0000000..aecc37c --- /dev/null +++ b/doc/Hyde/Util/ParserCommon.html @@ -0,0 +1,120 @@ + + + + + + + Module: Hyde::Util::ParserCommon + + — Documentation by YARD 0.9.34 + + + + + + + + + + + + + + + + + + + +
    + + +

    Module: Hyde::Util::ParserCommon + + + +

    +
    + + + + + + + + + +
    +
    Included in:
    +
    MultipartParser, Query
    +
    + + + +
    +
    Defined in:
    +
    lib/hyde/util/sorting.rb
    +
    + +
    + +

    Overview

    +
    +

    Internal library for generating form hashes

    + + +
    +
    +
    + + +
    + + + + + + + + +
    + + + +
    + + \ No newline at end of file diff --git a/doc/Hyde/Util/Query.html b/doc/Hyde/Util/Query.html index 120361b..e43d504 100644 --- a/doc/Hyde/Util/Query.html +++ b/doc/Hyde/Util/Query.html @@ -87,6 +87,11 @@ +
    +
    Includes:
    +
    ParserCommon
    +
    + @@ -101,8 +106,8 @@

    Overview

    - -

    Query string parser

    +

    TODO: encoding support???? +Query string parser

    @@ -128,6 +133,29 @@
  • + #[](key) ⇒ String, Array + + + + + + + + + + + + + +

    Get key from query.

    +
    + +
  • + + +
  • + + #initialize(query) ⇒ Query @@ -144,8 +172,7 @@ -
    -

    A new instance of Query.

    +

    A new instance of Query.

  • @@ -168,8 +195,7 @@ -
    -

    Better(tm) query parser with Returns a hash with arrays Key semantics:.

    +

    Better(tm) query parser.

    @@ -192,8 +218,7 @@ -
    -

    Shallow query parser (does not do PHP-like array keys).

    +

    Shallow query parser (does not do PHP-like array keys).

    @@ -202,7 +227,13 @@ -
    + + + + + + +

    Constructor Details

    @@ -216,8 +247,7 @@
    - -

    Returns a new instance of Query.

    +

    Returns a new instance of Query.

    @@ -246,12 +276,12 @@
     
     
    -10
    -11
    -12
    +13 +14 +15 -
    # File 'lib/hyde/util/query.rb', line 10
    +      
    # File 'lib/hyde/util/query.rb', line 13
     
     def initialize(query)
       @query = query
    @@ -269,7 +299,75 @@
     
         
           
    -

    +

    + + #[](key) ⇒ String, Array + + + + + +

    +
    +

    Get key from query.

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + key + + + (String) + + + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (String, Array) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +40
    +41
    +42
    +
    +
    # File 'lib/hyde/util/query.rb', line 40
    +
    +def [](key)
    +  (@cache ||= parse)[key]
    +end
    +
    +
    + +
    +

    #parseHash @@ -279,15 +377,15 @@

    - -

    Better(tm) query parser with Returns a hash with arrays Key semantics:

    -
    • -

      ‘key=value` creates a key value pair

      -
    • -

      ‘key[]=value` appends `value` to an array named `key`

      -
    • -

      key=value` sets `value` at `index` of array named `key`

      -
    +

    Better(tm) query parser. +Returns a hash with arrays. +Key semantics:

    + +
      +
    • key=value creates a key value pair
    • +
    • key[]=value appends value to an array named key
    • +
    • key[index]=value sets value at index of array named key
    • +
    @@ -314,15 +412,15 @@
     
     
    -30
    -31
    -32
    +33 +34 +35
    -
    # File 'lib/hyde/util/query.rb', line 30
    +      
    # File 'lib/hyde/util/query.rb', line 33
     
     def parse
    -  construct_deep_hash(URI.decode_www_form(@query, Encoding::UTF_8))
    +  construct_deep_hash(URI.decode_www_form(@query))
     end
    @@ -340,8 +438,7 @@
    - -

    Shallow query parser (does not do PHP-like array keys)

    +

    Shallow query parser (does not do PHP-like array keys)

    @@ -368,17 +465,17 @@
     
     
    -16
    -17
    -18
     19
    -20
    +20 +21 +22 +23
    -
    # File 'lib/hyde/util/query.rb', line 16
    +      
    # File 'lib/hyde/util/query.rb', line 19
     
     def parse_shallow
    -  URI.decode_www_form(@query, Encoding::UTF_8)
    +  URI.decode_www_form(@query)
          .sort_by { |array| array[0] }
          .to_h
     end
    @@ -392,7 +489,7 @@
    diff --git a/doc/_index.html b/doc/_index.html index fe474d2..0d849c2 100644 --- a/doc/_index.html +++ b/doc/_index.html @@ -81,9 +81,16 @@
    diff --git a/doc/class_list.html b/doc/class_list.html index 5f73cb9..142398b 100644 --- a/doc/class_list.html +++ b/doc/class_list.html @@ -43,7 +43,7 @@
    diff --git a/doc/file.README.html b/doc/file.README.html index 0af2f42..9acf03c 100644 --- a/doc/file.README.html +++ b/doc/file.README.html @@ -151,11 +151,11 @@ path "important" do preprocess do |req| # Implement logging logic here - puts "Client at #{req.headers['REMOTE_ADDR']} wanted to access something /important!" + puts "Client at #{req.headers['remote-addr']} wanted to access something /important!" end get "answer" do header "content-type", "application/json" - '{"answer":42, "desc":"something important!"}' + '\\{"answer":42, "desc":"something important!"\\}' end end end @@ -190,7 +190,7 @@
    diff --git a/doc/index.html b/doc/index.html index 9ae2507..00183c3 100644 --- a/doc/index.html +++ b/doc/index.html @@ -151,11 +151,11 @@ path "important" do preprocess do |req| # Implement logging logic here - puts "Client at #{req.headers['REMOTE_ADDR']} wanted to access something /important!" +
    puts "Client at #{req.headers['remote-addr']} wanted to access something /important!" end get "answer" do header "content-type", "application/json" - '{"answer":42, "desc":"something important!"}' + '\\{"answer":42, "desc":"something important!"\\}' end end end @@ -190,7 +190,7 @@
    diff --git a/doc/method_list.html b/doc/method_list.html index 43b0bf2..477c905 100644 --- a/doc/method_list.html +++ b/doc/method_list.html @@ -46,15 +46,15 @@
  • - [] - Hyde::Util::Lookup + #[] + Hyde::Util::Query
  • - #[] + [] Hyde::Util::Lookup
  • @@ -62,13 +62,21 @@
  • - #[]= + #[] Hyde::Util::Lookup
  • +
    + #[]= + Hyde::Util::Lookup +
    +
  • + + +
  • #add_header Hyde::Response @@ -76,6 +84,14 @@
  • +
  • +
    + #binding + Hyde::Template +
    +
  • + +
  • #body @@ -94,8 +110,8 @@
  • - #bounce - Hyde::DSL::ProbeMethods + #bounce + Hyde::DSL::CommonMethods
  • @@ -173,6 +189,14 @@
  • +
    + #data + Hyde::Util::FormPart +
    +
  • + + +
  • default_error_page Hyde::Util @@ -180,7 +204,7 @@
  • -
  • +
  • #delete Hyde::DSL::PathConstructors @@ -188,7 +212,7 @@
  • -
  • +
  • #delete_header Hyde::Response @@ -196,10 +220,18 @@
  • +
  • +
    + #die + Hyde::DSL::CommonMethods +
    +
  • + +
  • - #die - Hyde::DSL::ProbeMethods + #erb + Hyde::DSL::ProbeConstructors
  • @@ -213,6 +245,30 @@
  • +
    + #file + Hyde::DSL::ProbeMethods +
    +
  • + + +
  • +
    + #file? + Hyde::Util::FormPart +
    +
  • + + +
  • +
    + #filename + Hyde::Util::FormPart +
    +
  • + + +
  • #filepath Hyde::Request @@ -220,6 +276,14 @@
  • +
  • +
    + #filetype + Hyde::Util::FormPart +
    +
  • + +
  • #filter @@ -244,6 +308,22 @@
  • +
  • +
    + #form + Hyde::DSL::ProbeMethods +
    +
  • + + +
  • +
    + #form? + Hyde::DSL::ProbeMethods +
    +
  • + +
  • #get @@ -293,6 +373,14 @@
  • +
    + #headers= + Hyde::Util::FormPart +
    +
  • + + +
  • #index Hyde::DSL::PathMethods @@ -300,7 +388,7 @@
  • -
  • +
  • #initialize Hyde::Node @@ -308,10 +396,18 @@
  • +
  • +
    + #initialize + Hyde::ProcessorContext +
    +
  • + +
  • - #initialize - Hyde::PathBinding + #initialize + Hyde::PathContext
  • @@ -325,6 +421,14 @@
  • +
    + #initialize + Hyde::ProbeContext +
    +
  • + + +
  • #initialize Hyde::Probe @@ -332,7 +436,7 @@
  • -
  • +
  • #initialize Hyde::Server @@ -340,7 +444,7 @@
  • -
  • +
  • #initialize Hyde::Request @@ -348,7 +452,7 @@
  • -
  • +
  • #initialize Hyde::Response @@ -356,7 +460,23 @@
  • +
  • +
    + #initialize + Hyde::TemplateContext +
    +
  • + +
  • +
    + #initialize + Hyde::Template +
    +
  • + + +
  • #initialize Hyde::Util::Query @@ -364,7 +484,7 @@
  • -
  • +
  • #initialize Hyde::Util::Lookup @@ -372,18 +492,26 @@
  • +
  • +
    + #initialize + Hyde::Templates::ERB +
    +
  • + +
  • - #initialize - Hyde::ProbeBinding + #initialize + Hyde::Handlers::Handler
  • - #initialize - Hyde::Handler + #initialize + Hyde::Util::MultipartParser
  • @@ -398,8 +526,8 @@
  • - #initialize - Hyde::ServeHandler + #initialize + Hyde::Handlers::Serve
  • @@ -421,6 +549,46 @@
  • +
    + #input + Hyde::Request +
    +
  • + + +
  • +
    + #local_variable_get + Hyde::Template +
    +
  • + + +
  • +
    + #local_variable_set + Hyde::Template +
    +
  • + + +
  • +
    + #local_variables + Hyde::Template +
    +
  • + + +
  • +
    + make_value + Hyde::Util +
    +
  • + + +
  • #match Hyde::Pattern @@ -428,7 +596,7 @@
  • -
  • +
  • #match Hyde::PatternMatching::Glob @@ -436,7 +604,7 @@
  • -
  • +
  • #match Hyde::PatternMatching::ReMatch @@ -444,7 +612,7 @@
  • -
  • +
  • #match? Hyde::Pattern @@ -452,7 +620,7 @@
  • -
  • +
  • #match? Hyde::PatternMatching::Glob @@ -460,7 +628,7 @@
  • -
  • +
  • #match? Hyde::PatternMatching::ReMatch @@ -468,6 +636,14 @@
  • +
  • +
    + #name + Hyde::Util::FormPart +
    +
  • + +
  • #options @@ -477,6 +653,14 @@
  • +
    + #override_locals + Hyde::Template +
    +
  • + + +
  • #param Hyde::Request @@ -484,7 +668,7 @@
  • -
  • +
  • #parent Hyde::Util::Lookup @@ -492,7 +676,7 @@
  • -
  • +
  • #parse Hyde::Util::Query @@ -500,6 +684,14 @@
  • +
  • +
    + #parse + Hyde::Util::MultipartParser +
    +
  • + +
  • #parse_shallow @@ -509,6 +701,14 @@
  • +
    + parse_value + Hyde::Util +
    +
  • + + +
  • #patch Hyde::DSL::PathConstructors @@ -516,7 +716,7 @@
  • -
  • +
  • #path Hyde::Request @@ -524,7 +724,7 @@
  • -
  • +
  • #path Hyde::DSL::PathConstructors @@ -532,7 +732,7 @@
  • -
  • +
  • #path_info Hyde::Request @@ -540,7 +740,7 @@
  • -
  • +
  • #pop_state Hyde::Request @@ -548,7 +748,7 @@
  • -
  • +
  • #post Hyde::DSL::PathConstructors @@ -556,7 +756,7 @@
  • -
  • +
  • #postprocess Hyde::Path @@ -564,7 +764,7 @@
  • -
  • +
  • #postprocess Hyde::DSL::PathMethods @@ -572,7 +772,7 @@
  • -
  • +
  • #postprocessors Hyde::Request @@ -580,7 +780,7 @@
  • -
  • +
  • #preprocess Hyde::Path @@ -588,7 +788,7 @@
  • -
  • +
  • #preprocess Hyde::DSL::PathMethods @@ -596,7 +796,7 @@
  • -
  • +
  • #probe Hyde::DSL::PathConstructors @@ -604,7 +804,7 @@
  • -
  • +
  • #process Hyde::Node @@ -612,7 +812,7 @@
  • -
  • +
  • #process Hyde::Path @@ -620,7 +820,7 @@
  • -
  • +
  • #process Hyde::Probe @@ -628,31 +828,31 @@
  • -
  • -
    - #process - Hyde::Handler -
    -
  • - -
  • - #process - Hyde::GETHandler + #process + Hyde::Handlers::Handler
  • - #process - Hyde::ServeHandler + #process + Hyde::Handlers::GET
  • +
    + #process + Hyde::Handlers::Serve +
    +
  • + + +
  • #properties Hyde::Path @@ -660,7 +860,7 @@
  • -
  • +
  • #properties Hyde::Probe @@ -668,7 +868,7 @@
  • -
  • +
  • #push_state Hyde::Request @@ -676,7 +876,7 @@
  • -
  • +
  • #put Hyde::DSL::PathConstructors @@ -684,7 +884,7 @@
  • -
  • +
  • #query Hyde::Request @@ -692,7 +892,7 @@
  • -
  • +
  • #register Hyde::DSL::PathConstructors @@ -700,7 +900,7 @@
  • -
  • +
  • #reject Hyde::Node @@ -708,7 +908,7 @@
  • -
  • +
  • #remap Hyde::Node @@ -716,7 +916,7 @@
  • -
  • +
  • #remap Hyde::DSL::PathMethods @@ -724,7 +924,7 @@
  • -
  • +
  • #remove_header Hyde::DSL::ProbeMethods @@ -732,15 +932,15 @@
  • -
  • +
  • - #request - Hyde::Handler + #request + Hyde::Handlers::Handler
  • -
  • +
  • #request Hyde::DSL::ProbeMethods @@ -748,7 +948,7 @@
  • -
  • +
  • #request_method Hyde::Request @@ -756,23 +956,23 @@
  • +
  • +
    + #response + Hyde::Handlers::Handler +
    +
  • + +
  • - #response - Hyde::Handler + #response + Hyde::Handlers::Serve
  • -
    - #response - Hyde::ServeHandler -
    -
  • - - -
  • #root Hyde::Node @@ -780,7 +980,7 @@
  • -
  • +
  • #root Hyde::DSL::PathMethods @@ -788,7 +988,23 @@
  • +
  • +
    + #run + Hyde::Template +
    +
  • + +
  • +
    + #run + Hyde::Templates::ERB +
    +
  • + + +
  • #run_postprocessors Hyde::Request @@ -796,7 +1012,7 @@
  • -
  • +
  • #script_name Hyde::Request @@ -804,7 +1020,7 @@
  • -
  • +
  • #serve Hyde::DSL::PathConstructors @@ -812,7 +1028,7 @@
  • -
  • +
  • #server_name Hyde::Request @@ -820,7 +1036,7 @@
  • -
  • +
  • #server_port Hyde::Request @@ -828,7 +1044,7 @@
  • -
  • +
  • #server_protocol Hyde::Request @@ -836,6 +1052,14 @@
  • +
  • +
    + #simplify + Hyde::Util::FormPart +
    +
  • + +
  • #splat @@ -868,6 +1092,22 @@
  • +
  • +
    + #tempfile= + Hyde::Util::FormPart +
    +
  • + + +
  • +
    + #to_h + Hyde::Util::MultipartParser +
    +
  • + +
  • #trace @@ -877,6 +1117,14 @@
  • +
    + unescape_html + Hyde::Util +
    +
  • + + +
  • #validate Hyde::Response diff --git a/doc/top-level-namespace.html b/doc/top-level-namespace.html index 6ebc842..bae6e7d 100644 --- a/doc/top-level-namespace.html +++ b/doc/top-level-namespace.html @@ -100,7 +100,7 @@
    diff --git a/examples/extension_testing/extension.ru b/examples/extension_testing/extension.ru new file mode 100644 index 0000000..d1fe5b8 --- /dev/null +++ b/examples/extension_testing/extension.ru @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/lib") +require 'hyde' +require_relative 'external_methods' + +app = Hyde::Server.new do + get "/hello" do + header "content-type", "text/plain" + do_hello() + end +end + +run app diff --git a/examples/extension_testing/external_methods.rb b/examples/extension_testing/external_methods.rb new file mode 100644 index 0000000..93109f7 --- /dev/null +++ b/examples/extension_testing/external_methods.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Hyde + module DSL + # Methods shared by probes, preprocessors and filters. + module CommonMethods + def do_hello() + "Hello world!" + end + end + end +end diff --git a/examples/extension_testing/lib b/examples/extension_testing/lib new file mode 120000 index 0000000..58677dd --- /dev/null +++ b/examples/extension_testing/lib @@ -0,0 +1 @@ +../../lib \ No newline at end of file diff --git a/examples/extension_testing/readme.txt b/examples/extension_testing/readme.txt new file mode 100644 index 0000000..ed8bfad --- /dev/null +++ b/examples/extension_testing/readme.txt @@ -0,0 +1 @@ +Example of extending base Hyde functionality with additional DSL methods. diff --git a/examples/form/readme.txt b/examples/form/readme.txt new file mode 100644 index 0000000..c5e32c6 --- /dev/null +++ b/examples/form/readme.txt @@ -0,0 +1 @@ +Example of handling forms in Hyde diff --git a/examples/templates/footer.rhtml b/examples/templates/footer.rhtml new file mode 100644 index 0000000..24f1eef --- /dev/null +++ b/examples/templates/footer.rhtml @@ -0,0 +1,4 @@ +
    +
    +

    Footer template part

    +
    diff --git a/examples/templates/helloworld.ru b/examples/templates/helloworld.ru new file mode 100644 index 0000000..362ef28 --- /dev/null +++ b/examples/templates/helloworld.ru @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/lib") +require 'hyde' + +app = Hyde::Server.new do + remap ENV["PWD"] + get "/" do + header "content-type", "text/html" + localrand = rand + bind = binding + erb(file("index.rhtml"), toplevel: bind).run + end +end + +run app diff --git a/examples/templates/index.rhtml b/examples/templates/index.rhtml new file mode 100644 index 0000000..ab1d1f9 --- /dev/null +++ b/examples/templates/index.rhtml @@ -0,0 +1,14 @@ + + + + Ruby template engine test + + +

    + Welcome to another ugly looking test page +

    +
    +

    This page exists only to test template engine functionality

    +

    Random value = <%= localrand %>

    + + diff --git a/examples/templates/lib b/examples/templates/lib new file mode 120000 index 0000000..58677dd --- /dev/null +++ b/examples/templates/lib @@ -0,0 +1 @@ +../../lib \ No newline at end of file diff --git a/examples/templates/readme.txt b/examples/templates/readme.txt new file mode 100644 index 0000000..8816f3c --- /dev/null +++ b/examples/templates/readme.txt @@ -0,0 +1 @@ +This example demonstrates usage of template engines. diff --git a/lib/hyde.rb b/lib/hyde.rb index f824d7f..a62dd4a 100644 --- a/lib/hyde.rb +++ b/lib/hyde.rb @@ -5,11 +5,11 @@ require_relative 'hyde/path' require_relative 'hyde/probe' require_relative 'hyde/request' require_relative 'hyde/response' +require_relative 'hyde/template' # Hyde is a hideously simple ruby web framework module Hyde # Hyde version - # @type [String] VERSION = '0.8 (beta/rewrite)' # Hyde branding and version diff --git a/lib/hyde/dsl/constructors_path.rb b/lib/hyde/dsl/constructors_path.rb new file mode 100644 index 0000000..ac919b1 --- /dev/null +++ b/lib/hyde/dsl/constructors_path.rb @@ -0,0 +1,78 @@ +# frozen_string_literal: true + +module Hyde + # Shared DSL methods + module DSL + # Path (and subclasses) DSL constructors + module PathConstructors + # Append a Node child object to the list of children + def register(obj) + unless obj.is_a? Hyde::Node + raise StandardError, "register accepts node children only" + end + + @origin.children.append(obj) + end + + # Create a new {Hyde::Path} object + def path(path, &setup) + register(Hyde::Path.new(path, parent: @origin, &setup)) + end + + # Create a new {Hyde::Handlers::Probe} object + def probe(path, &_setup) + register(Hyde::Handlers::Probe.new(path, parent: @origin)) + end + + # Create a new {Hyde::Handlers::GETHandler} object + def get(path, &setup) + register(Hyde::Handlers::GET.new(path, parent: @origin, &setup)) + end + + # create a new {Hyde::Handlers::POSTHandler} object + def post(path, &setup) + register(Hyde::Handlers::POST.new(path, parent: @origin, &setup)) + end + + # Create a new {Hyde::Handlers::PUTHandler} object + def put(path, &setup) + register(Hyde::Handlers::PUT.new(path, parent: @origin, &setup)) + end + + # Create a new {Hyde::Handlers::HEADHandler} object + def head(path, &setup) + register(Hyde::Handlers::HEAD.new(path, parent: @origin, &setup)) + end + + # Create a new {Hyde::Handlers::DELETEHandler} object + def delete(path, &setup) + register(Hyde::Handlers::DELETE.new(path, parent: @origin, &setup)) + end + + # Create a new {Hyde::Handlers::CONNECTHandler} object + def connect(path, &setup) + register(Hyde::Handlers::CONNECT.new(path, parent: @origin, &setup)) + end + + # Create a new {Hyde::Handlers::TRACEHandler} object + def trace(path, &setup) + register(Hyde::Handlers::TRACE.new(path, parent: @origin, &setup)) + end + + # Create a new {Hyde::Handlers::PATCHHandler} object + def patch(path, &setup) + register(Hyde::Handlers::PATCH.new(path, parent: @origin, &setup)) + end + + # Create a new {Hyde::Handlers::OPTIONSHandler} object + def options(path, &setup) + register(Hyde::Handlers::OPTIONS.new(path, parent: @origin, &setup)) + end + + # Create a new {Hyde::Handlers::GETHandler} that serves static files + def serve(path) + register(Hyde::Handlers::Serve.new(path, parent: @origin)) + end + end + end +end diff --git a/lib/hyde/dsl/constructors_probe.rb b/lib/hyde/dsl/constructors_probe.rb new file mode 100644 index 0000000..2c38817 --- /dev/null +++ b/lib/hyde/dsl/constructors_probe.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Hyde + module DSL + # Probe (and subclasses) DSL construct + module ProbeConstructors + # Create a new erb template + # @see Hyde::Template#new + def erb(input, toplevel: nil, locals: nil) + Hyde::Templates::ERB.new(input, toplevel: toplevel, locals: locals) + end + end + end +end diff --git a/lib/hyde/dsl/common_methods.rb b/lib/hyde/dsl/methods_common.rb similarity index 100% rename from lib/hyde/dsl/common_methods.rb rename to lib/hyde/dsl/methods_common.rb diff --git a/lib/hyde/dsl/path_methods.rb b/lib/hyde/dsl/methods_path.rb similarity index 100% rename from lib/hyde/dsl/path_methods.rb rename to lib/hyde/dsl/methods_path.rb diff --git a/lib/hyde/dsl/probe_methods.rb b/lib/hyde/dsl/methods_probe.rb similarity index 92% rename from lib/hyde/dsl/probe_methods.rb rename to lib/hyde/dsl/methods_probe.rb index 30d076d..2dadfe7 100644 --- a/lib/hyde/dsl/probe_methods.rb +++ b/lib/hyde/dsl/methods_probe.rb @@ -82,6 +82,12 @@ module Hyde request.input, opts["boundary"] ).to_h end + + # Open a file relative to current filepath + # @see File#open + def file(path, mode = "r", *all, &block) + File.open("#{request.filepath}/#{path}", mode, *all, &block) + end end end end diff --git a/lib/hyde/dsl/methods_template.rb b/lib/hyde/dsl/methods_template.rb new file mode 100644 index 0000000..0dafa1b --- /dev/null +++ b/lib/hyde/dsl/methods_template.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Hyde + module DSL + module TemplateMethods + + end + end +end diff --git a/lib/hyde/dsl/path_constructors.rb b/lib/hyde/dsl/path_constructors.rb deleted file mode 100644 index 3a3a374..0000000 --- a/lib/hyde/dsl/path_constructors.rb +++ /dev/null @@ -1,80 +0,0 @@ -# frozen_string_literal: true - -module Hyde - # Shared DSL methods - module DSL - # Path (and subclasses) DSL constructors - module PathConstructors - # Append a Node child object to the list of children - def register(obj) - unless obj.is_a? Hyde::Node - raise StandardError, "register accepts node children only" - end - - @origin.children.append(obj) - end - - # Create a new {Hyde::Path} object - def path(path, &setup) - # i don't know WHAT is wrong with this thing. it just is wrong. - # @sg-ignore - register(Hyde::Path.new(path, parent: @origin, &setup)) - end - - # Create a new {Hyde::Probe} object - def probe(path, &_setup) - register(Hyde::Probe.new(path, parent: @origin)) - end - - # Create a new {Hyde::GETHandler} object - def get(path, &setup) - register(Hyde::GETHandler.new(path, parent: @origin, &setup)) - end - - # create a new {Hyde::POSTHandler} object - def post(path, &setup) - register(Hyde::POSTHandler.new(path, parent: @origin, &setup)) - end - - # Create a new {Hyde::PUTHandler} object - def put(path, &setup) - register(Hyde::PUTHandler.new(path, parent: @origin, &setup)) - end - - # Create a new {Hyde::HEADHandler} object - def head(path, &setup) - register(Hyde::HEADHandler.new(path, parent: @origin, &setup)) - end - - # Create a new {Hyde::DELETEHandler} object - def delete(path, &setup) - register(Hyde::DELETEHandler.new(path, parent: @origin, &setup)) - end - - # Create a new {Hyde::CONNECTHandler} object - def connect(path, &setup) - register(Hyde::CONNECTHandler.new(path, parent: @origin, &setup)) - end - - # Create a new {Hyde::TRACEHandler} object - def trace(path, &setup) - register(Hyde::TRACEHandler.new(path, parent: @origin, &setup)) - end - - # Create a new {Hyde::PATCHHandler} object - def patch(path, &setup) - register(Hyde::PATCHHandler.new(path, parent: @origin, &setup)) - end - - # Create a new {Hyde::OPTIONSHandler} object - def options(path, &setup) - register(Hyde::OPTIONSHandler.new(path, parent: @origin, &setup)) - end - - # Create a new {Hyde::GETHandler} that serves static files - def serve(path) - register(Hyde::ServeHandler.new(path, parent: @origin)) - end - end - end -end diff --git a/lib/hyde/path.rb b/lib/hyde/path.rb index 3660b09..4557ef4 100644 --- a/lib/hyde/path.rb +++ b/lib/hyde/path.rb @@ -2,14 +2,14 @@ require_relative 'pattern_matching' require_relative 'node' -require_relative 'dsl/path_constructors' -require_relative 'dsl/path_methods' -require_relative 'dsl/common_methods' +require_relative 'dsl/constructors_path' +require_relative 'dsl/methods_path' +require_relative 'dsl/methods_common' require_relative 'util/lookup' module Hyde - # Binding that provides execution context for filters and preprocessors. - class ProcessorBinding + # Execution context for filters and preprocessors. + class ProcessorContext include Hyde::DSL::CommonMethods def initialize(path) @@ -17,8 +17,8 @@ module Hyde end end - # Binding that provides execution context for path setup block. - class PathBinding + # Execution context for path setup block. + class PathContext include Hyde::DSL::PathConstructors include Hyde::DSL::PathMethods @@ -29,8 +29,8 @@ module Hyde # Primary building block of request navigation. class Path < Hyde::Node - ProcBinding = Hyde::ProcessorBinding - Binding = Hyde::PathBinding + ProcContext = Hyde::ProcessorContext + Context = Hyde::PathContext # @param path [Object] Object to generate {Hyde::Pattern} from # @param parent [Hyde::Node] Parent object to inherit properties to @@ -43,10 +43,10 @@ module Hyde @preprocessors = [] @postprocessors = [] @filters = [] - # Bindings setup - binding = self.class::Binding.new(self) - binding.instance_exec(&setup) - @procbinding = self.class::ProcBinding.new(self) + # Contexts setup + context = self.class::Context.new(self) + context.instance_exec(&setup) + @proccontext = self.class::ProcContext.new(self) end # Method callback on successful request navigation. @@ -104,7 +104,7 @@ module Hyde # @return [Boolean] true if request passed all filters def run_filters(request) @filters.each do |filter| - return false unless @procbinding.instance_exec(request, &filter) + return false unless @proccontext.instance_exec(request, &filter) end true end @@ -113,7 +113,7 @@ module Hyde # @param request [Hyde::Request] def run_preprocessors(request) @preprocessors.each do |preproc| - @procbinding.instance_exec(request, &preproc) + @proccontext.instance_exec(request, &preproc) end end diff --git a/lib/hyde/probe.rb b/lib/hyde/probe.rb index ec13920..2a851ad 100644 --- a/lib/hyde/probe.rb +++ b/lib/hyde/probe.rb @@ -2,23 +2,30 @@ require_relative 'node' require_relative 'util/lookup' +require_relative 'dsl/methods_probe' +require_relative 'dsl/methods_common' +require_relative 'dsl/constructors_probe' require 'pp' module Hyde - autoload :Handler, "hyde/probe/handler" - autoload :GETHandler, "hyde/probe/http_method" - autoload :POSTHandler, "hyde/probe/http_method" - autoload :HEADHandler, "hyde/probe/http_method" - autoload :PUTHandler, "hyde/probe/http_method" - autoload :DELETEHandler, "hyde/probe/http_method" - autoload :CONNECTHandler, "hyde/probe/http_method" - autoload :OPTIONSHandler, "hyde/probe/http_method" - autoload :TRACEHandler, "hyde/probe/http_method" - autoload :PATCHHandler, "hyde/probe/http_method" - autoload :ServeHandler, "hyde/probe/serve_handler" + # All subclasses of Hyde::Probe that respond to requests + module Handlers + autoload :Handler, "hyde/probe/handler" + autoload :GET, "hyde/probe/http_method" + autoload :POST, "hyde/probe/http_method" + autoload :HEAD, "hyde/probe/http_method" + autoload :PUT, "hyde/probe/http_method" + autoload :DELETE, "hyde/probe/http_method" + autoload :CONNECT, "hyde/probe/http_method" + autoload :OPTIONS, "hyde/probe/http_method" + autoload :TRACE, "hyde/probe/http_method" + autoload :PATCH, "hyde/probe/http_method" + autoload :Serve, "hyde/probe/serve_handler" + end - # Binding that provides execution context for Probes. - class ProbeBinding + # Context that provides execution context for Probes. + class ProbeContext + include Hyde::DSL::ProbeConstructors include Hyde::DSL::ProbeMethods include Hyde::DSL::CommonMethods diff --git a/lib/hyde/probe/handler.rb b/lib/hyde/probe/handler.rb index 205d905..8a8e19f 100644 --- a/lib/hyde/probe/handler.rb +++ b/lib/hyde/probe/handler.rb @@ -1,52 +1,56 @@ # frozen_string_literal: true +require_relative "../probe" + module Hyde - # Probe that executes a callback on request - class Handler < Hyde::Probe - # @param path [Object] - # @param parent [Hyde::Node] - # @param exec [#call] - def initialize(path, parent:, &exec) - super(path, parent: parent) - @callback = exec - @binding = Hyde::ProbeBinding.new(self) - @response = nil - end - - attr_accessor :response - attr_reader :request - - # Method callback on successful request navigation. - # Runs block supplied with object initialization. - # Request's #splat and #param are passed to block. - # - # Callback's returned should be one of viable responses: - # - # - {Hyde::Response} object - # - An array that matches Rack return form - # - An array that matches old (Rack 2.x) return form - # - A string (returned as HTML with code 200) - # - false (bounces the request to next handler) - # @param request [Hyde::Request] - # @return [Boolean] true if further navigation is possible - # @raise [UncaughtThrowError] may raise if die() is called. - def process(request) - @response = nil - return reject(request) unless request.path.match?(/^\/?$/) - - @request = request - response = catch(:break) do - @binding.instance_exec(*request.splat, - **request.param, - &@callback) + module Handlers + # Probe that executes a callback on request + class Handler < Hyde::Probe + # @param path [Object] + # @param parent [Hyde::Node] + # @param exec [#call] + def initialize(path, parent:, &exec) + super(path, parent: parent) + @callback = exec + @context = Hyde::ProbeContext.new(self) + @response = nil end - return false unless response - - if @response and [String, File, IO].include? response.class - @response.body = response - throw :finish, @response + + attr_accessor :response + attr_reader :request + + # Method callback on successful request navigation. + # Runs block supplied with object initialization. + # Request's #splat and #param are passed to block. + # + # Callback's returned should be one of viable responses: + # + # - {Hyde::Response} object + # - An array that matches Rack return form + # - An array that matches old (Rack 2.x) return form + # - A string (returned as HTML with code 200) + # - false (bounces the request to next handler) + # @param request [Hyde::Request] + # @return [Boolean] true if further navigation is possible + # @raise [UncaughtThrowError] may raise if die() is called. + def process(request) + @response = nil + return reject(request) unless request.path.match?(/^\/?$/) + + @request = request + response = catch(:break) do + @context.instance_exec(*request.splat, + **request.param, + &@callback) + end + return false unless response + + if @response and [String, File, IO].include? response.class + @response.body = response + throw :finish, @response + end + throw :finish, response end - throw :finish, response end end end diff --git a/lib/hyde/probe/http_method.rb b/lib/hyde/probe/http_method.rb index 7b4ed4a..f8bc439 100644 --- a/lib/hyde/probe/http_method.rb +++ b/lib/hyde/probe/http_method.rb @@ -1,70 +1,74 @@ # frozen_string_literal: true +require_relative "../probe" + module Hyde - # Probe that executes callback on a GET - class GETHandler < Hyde::Handler - METHOD = "GET" + module Handlers + # Probe that executes callback on a GET + class GET < Hyde::Handlers::Handler + METHOD = "GET" - # Method callback on successful request navigation. - # Runs block supplied with object initialization. - # Request's #splat and #param are passed to block. - # - # Callback's returned should be one of viable responses: - # - # - {Hyde::Response} object - # - An array that matches Rack return form - # - An array that matches old (Rack 2.x) return form - # - A string (returned as HTML with code 200) - # - false (bounces the request to next handler) - # @param request [Hyde::Request] - # @return [Boolean] true if further navigation is possible - # @raise [UncaughtThrowError] may raise if die() is called. - def process(request) - unless request.request_method.casecmp(self.class::METHOD).zero? - return false + # Method callback on successful request navigation. + # Runs block supplied with object initialization. + # Request's #splat and #param are passed to block. + # + # Callback's returned should be one of viable responses: + # + # - {Hyde::Response} object + # - An array that matches Rack return form + # - An array that matches old (Rack 2.x) return form + # - A string (returned as HTML with code 200) + # - false (bounces the request to next handler) + # @param request [Hyde::Request] + # @return [Boolean] true if further navigation is possible + # @raise [UncaughtThrowError] may raise if die() is called. + def process(request) + unless request.request_method.casecmp(self.class::METHOD).zero? + return false + end + + super(request) end + end - super(request) + # Probe that executes callback on a POST + class POST < GET + METHOD = "POST" + end + + # Probe that executes callback on a HEAD + class HEAD < GET + METHOD = "HEAD" + end + + # Probe that executes callback on a PUT + class PUT < GET + METHOD = "PUT" + end + + # Probe that executes callback on a DELETE + class DELETE < GET + METHOD = "DELETE" + end + + # Probe that executes callback on a CONNECT + class CONNECT < GET + METHOD = "CONNECT" + end + + # Probe that executes callback on a OPTIONS + class OPTIONS < GET + METHOD = "OPTIONS" + end + + # Probe that executes callback on a TRACE + class TRACE < GET + METHOD = "TRACE" + end + + # Probe that executes callback on a PATCH + class PATCH < GET + METHOD = "PATCH" end end - - # Probe that executes callback on a POST - class POSTHandler < GETHandler - METHOD = "POST" - end - - # Probe that executes callback on a HEAD - class HEADHandler < GETHandler - METHOD = "HEAD" - end - - # Probe that executes callback on a PUT - class PUTHandler < GETHandler - METHOD = "PUT" - end - - # Probe that executes callback on a DELETE - class DELETEHandler < GETHandler - METHOD = "DELETE" - end - - # Probe that executes callback on a CONNECT - class CONNECTHandler < GETHandler - METHOD = "CONNECT" - end - - # Probe that executes callback on a OPTIONS - class OPTIONSHandler < GETHandler - METHOD = "OPTIONS" - end - - # Probe that executes callback on a TRACE - class TRACEHandler < GETHandler - METHOD = "TRACE" - end - - # Probe that executes callback on a PATCH - class PATCHHandler < GETHandler - METHOD = "PATCH" - end end diff --git a/lib/hyde/probe/serve_handler.rb b/lib/hyde/probe/serve_handler.rb index a2b65e6..69911fd 100644 --- a/lib/hyde/probe/serve_handler.rb +++ b/lib/hyde/probe/serve_handler.rb @@ -1,28 +1,32 @@ # frozen_string_literal: true +require_relative "../probe" + module Hyde - # Probe that sends files from a location - class ServeHandler < Hyde::Probe - # @param path [Object] - # @param parent [Hyde::Node] - # @param exec [#call] - def initialize(path, parent:) - super(path, parent: parent) - end + module Handlers + # Probe that sends files from a location + class Serve < Hyde::Probe + # @param path [Object] + # @param parent [Hyde::Node] + # @param exec [#call] + def initialize(path, parent:) + super(path, parent: parent) + end - attr_accessor :response + attr_accessor :response - # Method callback on successful request navigation. - # Tries to serve files matched by handler - # @param request [Hyde::Request] - # @return [Boolean] true if file was found - def process(request) - path = File.expand_path(request.filepath) - return unless path.start_with? @properties["path"] + # Method callback on successful request navigation. + # Tries to serve files matched by handler + # @param request [Hyde::Request] + # @return [Boolean] true if file was found + def process(request) + path = File.expand_path(request.filepath) + return unless path.start_with? @properties["path"] - File.open(path.delete_suffix("/")) - rescue StandardError - false + File.open(path.delete_suffix("/")) + rescue StandardError + false + end end end end diff --git a/lib/hyde/server.rb b/lib/hyde/server.rb index 3b38d63..cb9dbfc 100644 --- a/lib/hyde/server.rb +++ b/lib/hyde/server.rb @@ -2,16 +2,15 @@ require_relative 'path' require_relative 'request' -require_relative 'dsl/path_constructors' require_relative 'util/html' module Hyde - class ServerBinding < Hyde::PathBinding + class ServerContext < Hyde::PathContext end # A specialized path that can be used directly as a Rack application. class Server < Hyde::Path - Binding = ServerBinding + Context = ServerContext # @param parent [Hyde::Node, nil] Parent object to inherit properties to # @param setup [#call] Setup block diff --git a/lib/hyde/template.rb b/lib/hyde/template.rb index 65e9346..b39f9a8 100644 --- a/lib/hyde/template.rb +++ b/lib/hyde/template.rb @@ -1,30 +1,76 @@ # frozen_string_literal: true +require_relative 'dsl/constructors_probe' +require_relative 'dsl/methods_common' +require_relative 'dsl/methods_probe' + module Hyde - # Adapter class for template engines - # @abstract This class does not actually do anything template related. + # All template engine adapters subclassed from Template + module Templates + autoload :ERB, "hyde/template/erb" + end + + # Context for template engines + class TemplateContext + include Hyde::DSL::CommonMethods + include Hyde::DSL::ProbeMethods + include Hyde::DSL::ProbeConstructors + + def initialize(parent) + @origin = parent + end + end + + # Interface for Template engines + # @abstract does not represent any actual template engine. class Template - # @param filename [String] + # @param input [String, File] # @param context [Binding, nil] - # @param locals [Hash{Symbol => Object}, nil] - def initialize(filename, context: nil, locals: nil) - @data = File.read(filename) - @context = context or binding - @locals.each do |k, v| - @context.local_variable_set(k, v) + # @param locals [Hash, nil] + def initialize(input, toplevel: nil, locals: nil) + @template = input.is_a?(File) ? input.read : input + input.close if input.is_a? File + @binding = toplevel or binding + locals&.each do |k, v| + @binding.local_variable_set(k,v) + end + @context = TemplateContext.new(self) + end + + # Set local variable + # @param key [Symbol] + # @param value [Object] + def local_variable_set(key, value) + @binding.local_variable_set(key, value) + end + + # Get local variable + # @param key [Symbol] + # @return [Object] + def local_variable_get(key) + @binding.local_variable_get(key) + end + + # Get an array of defined local variables + # @return [Array(Symbol)] + def local_variables + @binding.local_variables + end + + # Override binding variables. + # @param vars [Hash{Symbol => Object}] + def override_locals(vars) + vars.each do |k, v| + @binding.local_variable_set(k, v) end end - # Prepare template before rendering. - # (This method is an interface stub) - def prepare - @template = nil # your template generator goes here + # Run the template + # @note This method is a stub. + def run + # ... (stub) end - # Render template - # (This method is an interface stub) - def render - (@template ||= prepare).render(@context) - end + attr_accessor :binding end end diff --git a/lib/hyde/template/erb.rb b/lib/hyde/template/erb.rb new file mode 100644 index 0000000..d329c81 --- /dev/null +++ b/lib/hyde/template/erb.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +require 'erb' +require_relative '../template' + +module Hyde + module Templates + # ERB Template language adapter + class ERB < Hyde::Template + # @see Hyde::Template#new + def initialize(input, toplevel: nil, locals: nil) + super + @template = ::ERB.new(@template) + @template.filename = input.is_a?(File) ? input.path : "(Inline)" + end + + # Run the template. + def run + @context.instance_exec(@template,@binding) do |template, binding| + template.result binding + end + end + end + end +end