Module: Hoverboard::Assets

Included in:
Hoverboard
Defined in:
lib/hoverboard/assets.rb,
lib/hoverboard/assets/image.rb,
lib/hoverboard/assets/context.rb

Defined Under Namespace

Classes: Context, Image

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.rebuild!Object



5
6
7
8
9
10
# File 'lib/hoverboard/assets.rb', line 5

def rebuild!
  Hoverboard.assets_path.mkpath

  Hoverboard.javascript_file.open('w') {|f| f << Hoverboard.javascript}
  Hoverboard.css_file.open('w')        {|f| f << Hoverboard.css       }
end

Instance Method Details

#cssObject



31
32
33
# File 'lib/hoverboard/assets.rb', line 31

def css
  mustache.render(css_template_file.read, Context.new)
end

#css_fileObject



51
52
53
# File 'lib/hoverboard/assets.rb', line 51

def css_file
  @css_file ||= assets_path+'hoverboard.css'
end

#css_template_fileObject



43
44
45
# File 'lib/hoverboard/assets.rb', line 43

def css_template_file
  @css_template_file ||= dev_root+'stylesheets/hoverboard.css.mustache'
end

#dev_rootObject



35
36
37
# File 'lib/hoverboard/assets.rb', line 35

def dev_root
  @dev_root ||= gem_root+'dev'
end

#inline_cssObject



59
60
61
# File 'lib/hoverboard/assets.rb', line 59

def inline_css
  css_file.exist? ? css_file.read : ''
end

#inline_javascriptObject



55
56
57
# File 'lib/hoverboard/assets.rb', line 55

def inline_javascript
  javascript_file.exist? ? javascript_file.read : ''
end

#javascriptObject



27
28
29
# File 'lib/hoverboard/assets.rb', line 27

def javascript
  mustache.render(javascript_template_file.read, Context.new)
end

#javascript_fileObject



47
48
49
# File 'lib/hoverboard/assets.rb', line 47

def javascript_file
  @javascript_file ||= assets_path+'hoverboard.js'
end

#javascript_template_fileObject



39
40
41
# File 'lib/hoverboard/assets.rb', line 39

def javascript_template_file
  @javascript_template_file ||= dev_root+'javascripts/hoverboard.js.mustache'
end

#mustacheObject



20
21
22
23
24
25
# File 'lib/hoverboard/assets.rb', line 20

def mustache
  @mustache ||= begin
                  require 'mustache'
                  Mustache
                end
end

#template_ctxObject



16
17
18
# File 'lib/hoverboard/assets.rb', line 16

def template_ctx
  Context.new
end