Class: SiteDiff::Webserver
- Inherits:
-
Object
- Object
- SiteDiff::Webserver
- Defined in:
- lib/sitediff/webserver.rb,
lib/sitediff/webserver/resultserver.rb
Direct Known Subclasses
Defined Under Namespace
Classes: FixtureServer, ResultServer
Constant Summary collapse
- DEFAULT_PORT =
Simple webserver for testing purposes
13_080
Instance Attribute Summary collapse
-
#ports ⇒ Object
Returns the value of attribute ports.
Instance Method Summary collapse
-
#initialize(start_port, dirs, opts = {}) ⇒ Webserver
constructor
Serve a list of directories.
- #kill ⇒ Object
- #uris ⇒ Object
- #wait ⇒ Object
Constructor Details
#initialize(start_port, dirs, opts = {}) ⇒ Webserver
Serve a list of directories
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/sitediff/webserver.rb', line 13 def initialize(start_port, dirs, opts = {}) start_port ||= DEFAULT_PORT @ports = (start_port...(start_port + dirs.size)).to_a @dirs = dirs @opts = opts setup start_servers if block_given? yield self kill end end |
Instance Attribute Details
#ports ⇒ Object
Returns the value of attribute ports.
10 11 12 |
# File 'lib/sitediff/webserver.rb', line 10 def ports @ports end |
Instance Method Details
#kill ⇒ Object
28 29 30 |
# File 'lib/sitediff/webserver.rb', line 28 def kill @threads.each(&:kill) end |
#uris ⇒ Object
36 37 38 |
# File 'lib/sitediff/webserver.rb', line 36 def uris ports.map { |p| "http://localhost:#{p}" } end |
#wait ⇒ Object
32 33 34 |
# File 'lib/sitediff/webserver.rb', line 32 def wait @threads.each(&:join) end |