Module: Syntropy
- Extended by:
- Utilities
- Defined in:
- lib/syntropy.rb,
lib/syntropy/app.rb,
lib/syntropy/test.rb,
lib/syntropy/utils.rb,
lib/syntropy/errors.rb,
lib/syntropy/logger.rb,
lib/syntropy/request.rb,
lib/syntropy/session.rb,
lib/syntropy/version.rb,
lib/syntropy/json_api.rb,
lib/syntropy/markdown.rb,
lib/syntropy/side_run.rb,
lib/syntropy/mime_types.rb,
lib/syntropy/http/client.rb,
lib/syntropy/http/server.rb,
lib/syntropy/http/status.rb,
lib/syntropy/routing_tree.rb,
lib/syntropy/module_loader.rb,
lib/syntropy/storage/store.rb,
lib/syntropy/storage/schema.rb,
lib/syntropy/request/response.rb,
lib/syntropy/storage/kv_store.rb,
lib/syntropy/http/io_extensions.rb,
lib/syntropy/request/validation.rb,
lib/syntropy/request/mock_adapter.rb,
lib/syntropy/request/request_info.rb,
lib/syntropy/http/client_connection.rb,
lib/syntropy/http/server_connection.rb,
lib/syntropy/storage/prepared_query.rb,
lib/syntropy/storage/connection_pool.rb
Overview
Syntropy is a web framework for building web apps in Ruby. Syntropy uses UringMachine for I/O and concurrency, and provides a comprehensive and flexible solution for writing web apps with minimal boilerplate.
Defined Under Namespace
Modules: HTTP, Markdown, MimeTypes, RequestInfoClassMethods, RequestInfoMethods, RequestValidationMethods, ResponseMethods, SideRun, Storage, TestRequestExtensions, Utilities Classes: App, BadRequestError, Error, Flash, InvalidRequestContentTypeError, JSONAPI, Logger, MockAdapter, Module, ModuleLoader, NowFlash, ProtocolError, Request, RoutingTree, Session, Test, TestHarness, UnsupportedHTTPVersionError, ValidationError
Constant Summary collapse
- VERSION =
'0.36.0'
Constants included from Utilities
Utilities::BUILTIN_APPLET_app_root
Class Attribute Summary collapse
-
.dev_mode ⇒ Object
Returns the value of attribute dev_mode.
-
.machine ⇒ Object
Returns the value of attribute machine.
-
.test_mode ⇒ Object
Returns the value of attribute test_mode.
Class Method Summary collapse
- .load_config(env) ⇒ Object
-
.run(env = {}, &app) ⇒ void
Runs a web app with the given environment hash.
-
.side_run(&block) ⇒ any
Runs the given block on a separate thread.
Methods included from Utilities
app, builtin_applet, page_list, route_by_host, tmp_path
Class Attribute Details
.dev_mode ⇒ Object
Returns the value of attribute dev_mode.
30 31 32 |
# File 'lib/syntropy.rb', line 30 def dev_mode @dev_mode end |
.machine ⇒ Object
Returns the value of attribute machine.
30 31 32 |
# File 'lib/syntropy.rb', line 30 def machine @machine end |
.test_mode ⇒ Object
Returns the value of attribute test_mode.
30 31 32 |
# File 'lib/syntropy.rb', line 30 def test_mode @test_mode end |
Class Method Details
.load_config(env) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/syntropy.rb', line 78 def load_config(env) return if !env[:config_root] loader_env = env.merge( app_root: env[:config_root], logger: nil ) loader = ModuleLoader.new(loader_env) config = loader.load(env[:mode]) env[:config] = config end |
.run(env = {}, &app) ⇒ void
This method returns an undefined value.
Runs a web app with the given environment hash. The given block is either an instance of Syntropy::App, or a Proc/callable that takes a request as argument.
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 |
# File 'lib/syntropy.rb', line 48 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 if (logger = env[:logger]) logger.info( message: "Syntropy #{Syntropy::VERSION}, UringMachine #{UM::VERSION}, Ruby #{RUBY_VERSION}" ) logger.info( message: "Running in #{env[:mode]} mode" ) end server = HTTP::Server.new(machine, env, &app) setup_signal_handling(machine, Fiber.current) server.run ensure @in_run = false end end |
.side_run(&block) ⇒ any
Runs the given block on a separate thread. Use this method for running code that is not fiber-aware (i.e. does not use UringMachine).
36 37 38 39 40 |
# File 'lib/syntropy.rb', line 36 def side_run(&block) raise 'Syntropy.machine not set' if !@machine SideRun.call(@machine, &block) end |