Module: Syntropy
- Defined in:
- lib/syntropy.rb,
lib/syntropy/app.rb,
lib/syntropy/test.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/controller_extensions.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: ControllerExtensions, HTTP, Markdown, MimeTypes, RequestInfoClassMethods, RequestInfoMethods, RequestValidationMethods, ResponseMethods, SideRun, Storage, TestRequestExtensions Classes: App, BadRequestError, Error, Flash, InvalidRequestContentTypeError, JSONAPI, Logger, MockAdapter, ModuleContext, ModuleLoader, NowFlash, ProtocolError, Request, RoutingTree, Session, Test, TestHarness, UnsupportedHTTPVersionError, ValidationError
Constant Summary collapse
- VERSION =
'0.38.0'
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.
Class Attribute Details
.dev_mode ⇒ Object
Returns the value of attribute dev_mode.
27 28 29 |
# File 'lib/syntropy.rb', line 27 def dev_mode @dev_mode end |
.machine ⇒ Object
Returns the value of attribute machine.
27 28 29 |
# File 'lib/syntropy.rb', line 27 def machine @machine end |
.test_mode ⇒ Object
Returns the value of attribute test_mode.
27 28 29 |
# File 'lib/syntropy.rb', line 27 def test_mode @test_mode end |
Class Method Details
.load_config(env) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/syntropy.rb', line 75 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) if (config = loader.load(env[:mode], raise_on_missing: false)) env[:config] = config end 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.
45 46 47 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 |
# File 'lib/syntropy.rb', line 45 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).
33 34 35 36 37 |
# File 'lib/syntropy.rb', line 33 def side_run(&block) raise 'Syntropy.machine not set' if !@machine SideRun.call(@machine, &block) end |