moving files to pc

This commit is contained in:
Yessiest 2023-09-11 21:42:19 +04:00
parent 20559149eb
commit d05faeac39
6 changed files with 41 additions and 26 deletions

View File

@ -16,6 +16,17 @@ module Hyde
autoload :TRACEHandler, "hyde/probe/http_method" autoload :TRACEHandler, "hyde/probe/http_method"
autoload :PATCHHandler, "hyde/probe/http_method" autoload :PATCHHandler, "hyde/probe/http_method"
autoload :ServeHandler, "hyde/probe/serve_handler" autoload :ServeHandler, "hyde/probe/serve_handler"
# Binding that provides execution context for Probes.
class ProbeBinding
include Hyde::DSL::ProbeMethods
include Hyde::DSL::CommonMethods
def initialize(origin)
@origin = origin
end
end
# Test probe. Also base for all "reactive" nodes. # Test probe. Also base for all "reactive" nodes.
class Probe < Hyde::Node class Probe < Hyde::Node
# @param path [Object] # @param path [Object]

View File

@ -1,16 +0,0 @@
# frozen_string_literal: true
require_relative "../dsl/probe_methods"
require_relative "../dsl/common_methods"
module Hyde
# Binding that provides execution context for Probes.
class ProbeBinding
include Hyde::DSL::ProbeMethods
include Hyde::DSL::CommonMethods
def initialize(origin)
@origin = origin
end
end
end

View File

@ -1,8 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require_relative '../probe'
require_relative 'binding'
module Hyde module Hyde
# Probe that executes a callback on request # Probe that executes a callback on request
class Handler < Hyde::Probe class Handler < Hyde::Probe

View File

@ -1,9 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require_relative '../probe'
require_relative 'binding'
require_relative 'handler'
module Hyde module Hyde
# Probe that executes callback on a GET # Probe that executes callback on a GET
class GETHandler < Hyde::Handler class GETHandler < Hyde::Handler

View File

@ -1,8 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require_relative '../probe'
require_relative 'binding'
module Hyde module Hyde
# Probe that sends files from a location # Probe that sends files from a location
class ServeHandler < Hyde::Probe class ServeHandler < Hyde::Probe

30
lib/hyde/template.rb Normal file
View File

@ -0,0 +1,30 @@
# frozen_string_literal: true
module Hyde
# Adapter class for template engines
# @abstract This class does not actually do anything template related.
class Template
# @param filename [String]
# @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)
end
end
# Prepare template before rendering.
# (This method is an interface stub)
def prepare
@template = nil # your template generator goes here
end
# Render template
# (This method is an interface stub)
def render
(@template ||= prepare).render(@context)
end
end
end