Module: Syntropy
- Extended by:
- Utilities
- Defined in:
- lib/syntropy.rb,
lib/syntropy/app.rb,
lib/syntropy/utils.rb,
lib/syntropy/errors.rb,
lib/syntropy/logger.rb,
lib/syntropy/module.rb,
lib/syntropy/server.rb,
lib/syntropy/version.rb,
lib/syntropy/json_api.rb,
lib/syntropy/markdown.rb,
lib/syntropy/side_run.rb,
lib/syntropy/connection.rb,
lib/syntropy/routing_tree.rb,
lib/syntropy/connection_pool.rb,
lib/syntropy/request_extensions.rb
Defined Under Namespace
Modules: RequestExtensions, SideRun, Utilities Classes: App, Connection, ConnectionPool, Error, JSONAPI, Logger, Module, ModuleLoader, ProtocolError, RoutingTree, Server, UnsupportedHTTPVersionError, ValidationError
Constant Summary collapse
- Status =
Qeweney::Status
- GREEN =
"\e[32m"- CLEAR =
"\e[0m"- YELLOW =
"\e[33m"- BANNER =
"\n"\ " #{GREEN}\n"\ " #{GREEN} ooo\n"\ " #{GREEN}ooooo\n"\ " #{GREEN} ooo vvv #{CLEAR}Syntropy - a web framework for Ruby\n"\ " #{GREEN} o vvvvv #{CLEAR}--------------------------------------\n"\ " #{GREEN} #{YELLOW}|#{GREEN} vvv o #{CLEAR}https://github.com/digital-fabric/syntropy\n"\ " #{GREEN} :#{YELLOW}|#{GREEN}:::#{YELLOW}|#{GREEN}::#{YELLOW}|#{GREEN}:\n"\ "#{YELLOW}+++++++++++++++++++++++++++++++++++++++++++++++++++++++++\e[0m\n\n"
- VERSION =
'0.29.0'- DATE_REGEXP =
/(\d{4}-\d{2}-\d{2})/- FRONT_MATTER_REGEXP =
/\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m- YAML_OPTS =
{ permitted_classes: [Date], symbolize_names: true }
Constants included from Utilities
Utilities::BUILTIN_APPLET_ROOT_DIR
Class Attribute Summary collapse
-
.machine ⇒ Object
Returns the value of attribute machine.
Class Method Summary collapse
- .env(env = nil, &app) ⇒ Object
-
.parse_markdown_file(path, env) ⇒ Array
Parses the markdown file at the given path.
- .run(env = {}, &app) ⇒ Object
- .side_run(&block) ⇒ Object
Instance Method Summary collapse
Methods included from Utilities
app, builtin_applet, page_list, route_by_host
Class Attribute Details
.machine ⇒ Object
Returns the value of attribute machine.
29 30 31 |
# File 'lib/syntropy.rb', line 29 def machine @machine end |
Class Method Details
.env(env = nil, &app) ⇒ Object
82 83 84 85 86 87 |
# File 'lib/syntropy.rb', line 82 def env(env = nil, &app) return @env if !env && !app @env = env || {} @env[:app] = app if app end |
.parse_markdown_file(path, env) ⇒ Array
Parses the markdown file at the given path.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/syntropy/markdown.rb', line 17 def self.parse_markdown_file(path, env) content = IO.read(path) || '' atts = {} # Parse date from file name m = path.match(DATE_REGEXP) atts[:date] ||= Date.parse(m[1]) if m if (m = content.match(FRONT_MATTER_REGEXP)) front_matter = m[1] content = m.post_match yaml = YAML.safe_load(front_matter, **YAML_OPTS) atts = atts.merge(yaml) end if env[:root_dir] atts[:url] = path .gsub(/#{env[:root_dir]}/, '') .gsub(/\.md$/, '') end [atts, content] end |
.run(env = {}, &app) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/syntropy.rb', line 58 def run(env = {}, &app) if @in_run @env = env @env[:app] = app if app return end env ||= @env || {} begin @in_run = true machine = env[:machine] || UM.new machine.puts(env[:banner]) if env[:banner] env[:logger]&.info(message: "Running Syntropy #{Syntropy::VERSION}, UringMachine #{UM::VERSION}, Ruby #{RUBY_VERSION}") server = Server.new(machine, env, &app) setup_signal_handling(machine, Fiber.current) server.run ensure @in_run = false end end |
Instance Method Details
#colorize(color_code) ⇒ Object
38 39 40 |
# File 'lib/syntropy.rb', line 38 def colorize(color_code) "\e[#{color_code}m#{self}\e[0m" end |