Class: Lissio::Server

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/lissio/server.rb

Defined Under Namespace

Classes: Index, Prerender, SourceMap

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Server

Returns a new instance of Server.



103
104
105
106
107
108
109
110
111
112
# File 'lib/lissio/server.rb', line 103

def initialize(&block)
	@sprockets = Sprockets::Environment.new
	@main      = 'app'

	Opal.paths.each {|path|
		@sprockets.append_path path
	}

	block.call(self) if block
end

Instance Attribute Details

#debugObject

Returns the value of attribute debug.



100
101
102
# File 'lib/lissio/server.rb', line 100

def debug
  @debug
end

#indexObject

Returns the value of attribute index.



100
101
102
# File 'lib/lissio/server.rb', line 100

def index
  @index
end

#mainObject

Returns the value of attribute main.



100
101
102
# File 'lib/lissio/server.rb', line 100

def main
  @main
end

#source_mapsObject

Returns the value of attribute source_maps.



100
101
102
# File 'lib/lissio/server.rb', line 100

def source_maps
  @source_maps
end

#sprocketsObject

Returns the value of attribute sprockets.



100
101
102
# File 'lib/lissio/server.rb', line 100

def sprockets
  @sprockets
end

#staticObject

Returns the value of attribute static.



100
101
102
# File 'lib/lissio/server.rb', line 100

def static
  @static
end

Instance Method Details

#appObject



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/lissio/server.rb', line 132

def app
	this  = self
	block = @extend

	@app ||= Rack::Builder.app do
		use Rack::ShowExceptions
		use Rack::Deflater

		map '/assets' do
			run this.sprockets
		end

		if this.source_maps?
			map this.source_maps.prefix do
				run this.source_maps
			end
		end

		use Prerender, this
		use Rack::Static, urls: this.static if this.static

		instance_exec(&block) if block

		run Index.new(this)
	end
end

#append_static(path) ⇒ Object



120
121
122
# File 'lib/lissio/server.rb', line 120

def append_static(path)
	(@static ||= []) << path
end

#call(env) ⇒ Object



159
160
161
# File 'lib/lissio/server.rb', line 159

def call(env)
	app.call(env)
end

#extend(&block) ⇒ Object



128
129
130
# File 'lib/lissio/server.rb', line 128

def extend(&block)
	@extend = block
end

#path=(values) ⇒ Object



114
115
116
117
118
# File 'lib/lissio/server.rb', line 114

def path=(values)
	values.each { |path|
		append_path path
	}
end

#source_maps?Boolean

Returns:

  • (Boolean)


124
125
126
# File 'lib/lissio/server.rb', line 124

def source_maps?
	@source_maps
end