Class: Lissio::Builder
- Inherits:
-
Object
- Object
- Lissio::Builder
- Extended by:
- Forwardable
- Defined in:
- lib/lissio/builder.rb
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#index ⇒ Object
Returns the value of attribute index.
-
#main ⇒ Object
Returns the value of attribute main.
-
#source_maps ⇒ Object
Returns the value of attribute source_maps.
-
#sprockets ⇒ Object
Returns the value of attribute sprockets.
-
#static ⇒ Object
Returns the value of attribute static.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(&block) ⇒ Builder
constructor
A new instance of Builder.
- #lissio(source = main) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Builder
Returns a new instance of Builder.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/lissio/builder.rb', line 13 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
#debug ⇒ Object
Returns the value of attribute debug.
10 11 12 |
# File 'lib/lissio/builder.rb', line 10 def debug @debug end |
#index ⇒ Object
Returns the value of attribute index.
10 11 12 |
# File 'lib/lissio/builder.rb', line 10 def index @index end |
#main ⇒ Object
Returns the value of attribute main.
10 11 12 |
# File 'lib/lissio/builder.rb', line 10 def main @main end |
#source_maps ⇒ Object
Returns the value of attribute source_maps.
10 11 12 |
# File 'lib/lissio/builder.rb', line 10 def source_maps @source_maps end |
#sprockets ⇒ Object
Returns the value of attribute sprockets.
10 11 12 |
# File 'lib/lissio/builder.rb', line 10 def sprockets @sprockets end |
#static ⇒ Object
Returns the value of attribute static.
10 11 12 |
# File 'lib/lissio/builder.rb', line 10 def static @static end |
Instance Method Details
#build ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/lissio/builder.rb', line 24 def build source = if @path unless File.exist?(@path) raise "index does not exist: #{@path}" end File.read @path elsif File.exist? 'index.html.erb' File.read 'index.html.erb' else <<-HTML <!DOCTYPE html> <html> <head> <%= lissio %> </head> <body> </body> </html> HTML end ::ERB.new(source).result binding end |
#lissio(source = main) ⇒ Object
49 50 51 |
# File 'lib/lissio/builder.rb', line 49 def lissio(source = main) "<script>#{Uglifier.compile(@sprockets[source].to_s)}</script>" end |