Module: Whereuat::Assets

Included in:
Whereuat
Defined in:
lib/whereuat/assets.rb,
lib/whereuat/assets/image.rb,
lib/whereuat/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/whereuat/assets.rb', line 5

def rebuild!
  Whereuat.assets_path.mkpath

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

Instance Method Details

#cssObject



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

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

#css_fileObject



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

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

#css_template_fileObject



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

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

#dev_rootObject



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

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

#inline_cssObject



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

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

#inline_javascriptObject



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

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

#javascriptObject



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

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

#javascript_fileObject



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

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

#javascript_template_fileObject



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

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

#mustacheObject



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

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

#template_ctxObject



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

def template_ctx
  Context.new
end