Class: Machined::Server
- Inherits:
-
Object
- Object
- Machined::Server
- Defined in:
- lib/machined/server.rb
Instance Attribute Summary collapse
-
#machined ⇒ Object
readonly
A reference to the Machined environment which created this instance.
Instance Method Summary collapse
-
#call(env) ⇒ Object
Using the URLMap, determine which sprocket should handle the request and then…let it handle it.
-
#initialize(machined) ⇒ Server
constructor
Creates a new Rack server that will serve up the processed files.
-
#reload ⇒ Object
Rebuilds the Rack app with the current Machined configuration.
Constructor Details
#initialize(machined) ⇒ Server
Creates a new Rack server that will serve up the processed files.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/machined/server.rb', line 12 def initialize(machined) @machined = machined if machined.environment.development? # Configure watchable files files = [] files << machined.config_path if machined.config_path.exist? # Configure watchable dirs dirs = {} dirs[machined.lib_path.to_s] = [:rb] if machined.lib_path.exist? # Setup file watching using ActiveSupport::FileUpdateChecker @reloader = ActiveSupport::FileUpdateChecker.new(files, dirs) do machined.reload reload end end reload end |
Instance Attribute Details
#machined ⇒ Object (readonly)
A reference to the Machined environment which created this instance.
8 9 10 |
# File 'lib/machined/server.rb', line 8 def machined @machined end |
Instance Method Details
#call(env) ⇒ Object
Using the URLMap, determine which sprocket should handle the request and then…let it handle it.
37 38 39 40 |
# File 'lib/machined/server.rb', line 37 def call(env) @reloader.execute_if_updated if machined.environment.development? @app.call(env) end |
#reload ⇒ Object
Rebuilds the Rack app with the current Machined configuration.
44 45 46 |
# File 'lib/machined/server.rb', line 44 def reload @app = to_app end |