Class: Lyre::App

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/lyre/app.rb

Overview

NOTE: Not sure this is the right name for this class

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.setup_blockObject

Returns the value of attribute setup_block.



13
14
15
# File 'lib/lyre/app.rb', line 13

def setup_block
  @setup_block
end

.teardown_blockObject

Returns the value of attribute teardown_block.



13
14
15
# File 'lib/lyre/app.rb', line 13

def teardown_block
  @teardown_block
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



10
11
12
# File 'lib/lyre/app.rb', line 10

def host
  @host
end

#portObject

Returns the value of attribute port.



10
11
12
# File 'lib/lyre/app.rb', line 10

def port
  @port
end

Class Method Details

.bootObject



23
24
25
26
27
28
29
# File 'lib/lyre/app.rb', line 23

def boot
  instance = self.new! #maybe just new

  instance.startup

  instance
end

.setup(&block) ⇒ Object



15
16
17
# File 'lib/lyre/app.rb', line 15

def setup(&block)
  self.setup_block = block
end

.teardown(&block) ⇒ Object



19
20
21
# File 'lib/lyre/app.rb', line 19

def teardown(&block)
  self.teardown_block = block
end

Instance Method Details

#endpointObject



49
50
51
# File 'lib/lyre/app.rb', line 49

def endpoint
  "http://#{host}:#{port}"
end

#shutdownObject



45
46
47
# File 'lib/lyre/app.rb', line 45

def shutdown
  self.class.teardown_block.call(self) if self.class.teardown_block
end

#startupObject



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/lyre/app.rb', line 32

def startup
  with_thin_runner do
    Capybara::Server.new(self).tap do |server|
      server.boot

      self.host = server.host
      self.port = server.port
    
      self.class.setup_block.call(self) if self.class.setup_block
    end
  end
end