Class: FluidCLI::Theme::DevServer
- Inherits:
-
Object
- Object
- FluidCLI::Theme::DevServer
- Includes:
- Singleton
- Defined in:
- lib/fluid_cli/theme/dev_server.rb,
lib/fluid_cli/theme/dev_server/sse.rb,
lib/fluid_cli/theme/dev_server/proxy.rb,
lib/fluid_cli/theme/dev_server/errors.rb,
lib/fluid_cli/theme/dev_server/watcher.rb,
lib/fluid_cli/theme/dev_server/hot_reload.rb,
lib/fluid_cli/theme/dev_server/web_server.rb,
lib/fluid_cli/theme/dev_server/header_hash.rb,
lib/fluid_cli/theme/dev_server/reload_mode.rb,
lib/fluid_cli/theme/dev_server/local_assets.rb,
lib/fluid_cli/theme/dev_server/certificate_manager.rb,
lib/fluid_cli/theme/dev_server/proxy_param_builder.rb,
lib/fluid_cli/theme/dev_server/hooks/file_change_hook.rb,
lib/fluid_cli/theme/dev_server/hot_reload/script_injector.rb
Defined Under Namespace
Modules: Hooks, WEBrickGenericServerThreadJoinWithTimeout Classes: CertificateManager, Error, HeaderHash, HotReload, LocalAssets, Proxy, ProxyParamBuilder, ReloadMode, SSE, Watcher, WebServer
Constant Summary collapse
- HOP_BY_HOP_HEADERS =
[ "connection", "keep-alive", "proxy-authenticate", "proxy-authorization", "te", "trailer", "transfer-encoding", "upgrade", "content-security-policy", "content-length", ]
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#ctx ⇒ Object
readonly
Returns the value of attribute ctx.
-
#editor_sync ⇒ Object
readonly
Returns the value of attribute editor_sync.
-
#force ⇒ Object
readonly
Returns the value of attribute force.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#ignores ⇒ Object
readonly
Returns the value of attribute ignores.
-
#includes ⇒ Object
readonly
Returns the value of attribute includes.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#navigate ⇒ Object
readonly
Returns the value of attribute navigate.
-
#poll ⇒ Object
readonly
Returns the value of attribute poll.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#stopped ⇒ Object
readonly
Returns the value of attribute stopped.
-
#theme_identifier ⇒ Object
readonly
Returns the value of attribute theme_identifier.
Class Method Summary collapse
- .start(ctx, root, host: "127.0.0.1", theme: nil, port: 9292, poll: false, editor_sync: false, force: false, overwrite_json: false, navigate: false, mode: ReloadMode.default, includes: nil, ignores: nil, &block) ⇒ Object
- .stop ⇒ Object
Instance Method Summary collapse
-
#setup(ctx, root, host, theme_identifier, port, poll, editor_sync, force, overwrite_json, navigate, mode, includes, ignores, &block) ⇒ Object
rubocop:disable Metrics/ParameterLists.
- #start ⇒ Object
- #stop(signal = nil) ⇒ Object
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
31 32 33 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 31 def app @app end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
31 32 33 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 31 def block @block end |
#ctx ⇒ Object (readonly)
Returns the value of attribute ctx.
31 32 33 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 31 def ctx @ctx end |
#editor_sync ⇒ Object (readonly)
Returns the value of attribute editor_sync.
31 32 33 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 31 def editor_sync @editor_sync end |
#force ⇒ Object (readonly)
Returns the value of attribute force.
31 32 33 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 31 def force @force end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
31 32 33 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 31 def host @host end |
#ignores ⇒ Object (readonly)
Returns the value of attribute ignores.
31 32 33 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 31 def ignores @ignores end |
#includes ⇒ Object (readonly)
Returns the value of attribute includes.
31 32 33 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 31 def includes @includes end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
31 32 33 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 31 def mode @mode end |
#navigate ⇒ Object (readonly)
Returns the value of attribute navigate.
31 32 33 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 31 def navigate @navigate end |
#poll ⇒ Object (readonly)
Returns the value of attribute poll.
31 32 33 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 31 def poll @poll end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
31 32 33 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 31 def port @port end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
31 32 33 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 31 def root @root end |
#stopped ⇒ Object (readonly)
Returns the value of attribute stopped.
31 32 33 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 31 def stopped @stopped end |
#theme_identifier ⇒ Object (readonly)
Returns the value of attribute theme_identifier.
31 32 33 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 31 def theme_identifier @theme_identifier end |
Class Method Details
.start(ctx, root, host: "127.0.0.1", theme: nil, port: 9292, poll: false, editor_sync: false, force: false, overwrite_json: false, navigate: false, mode: ReloadMode.default, includes: nil, ignores: nil, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 35 def start( ctx, root, host: "127.0.0.1", theme: nil, port: 9292, poll: false, editor_sync: false, force: false, overwrite_json: false, navigate: false, mode: ReloadMode.default, includes: nil, ignores: nil, &block ) instance.setup( ctx, root, host, theme, port, poll, editor_sync, force, overwrite_json, navigate, mode, includes, ignores, &block ) instance.start end |
.stop ⇒ Object
70 71 72 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 70 def stop instance.stop end |
Instance Method Details
#setup(ctx, root, host, theme_identifier, port, poll, editor_sync, force, overwrite_json, navigate, mode, includes, ignores, &block) ⇒ Object
rubocop:disable Metrics/ParameterLists
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 101 102 103 104 105 106 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 76 def setup( ctx, root, host, theme_identifier, port, poll, editor_sync, force, overwrite_json, navigate, mode, includes, ignores, &block ) @ctx = ctx @root = root @host = host @theme_identifier = theme_identifier @port = port @poll = poll @editor_sync = editor_sync @force = force @overwrite_json = overwrite_json @navigate = navigate @mode = mode @includes = includes @ignores = ignores @block = block end |
#start ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/fluid_cli/theme/dev_server.rb', line 108 def start sync_theme # Handle process stop trap("INT") { stop("SIGINT") } trap("TERM") { stop("SIGTERM") } # Setup the middleware stack. Mimics Rack::Builder / config.ru, but in reverse order @app = middleware_stack # Start development server setup_server start_server teardown_server rescue FluidCLI::API::APIRequestForbiddenError, FluidCLI::API::APIRequestUnauthorizedError ctx.abort() rescue Errno::EADDRINUSE ctx.abort(, ) rescue Errno::EADDRNOTAVAIL ctx.abort() end |