module Flunkey::Helpers

Constants

DOWNLOAD_SPEEDS

Byte per second

Public Instance Methods

breadcrumbs(root, path) click to toggle source
config() click to toggle source
# File lib/flunkey/helpers.rb, line 13
def config
  settings
end
debug(obj) click to toggle source
# File lib/flunkey/helpers.rb, line 59
def debug(obj)
  "<pre>#{Rack::Utils.escape_html obj.inspect}</pre>"
end
download_estimates(size) click to toggle source
# File lib/flunkey/helpers.rb, line 45
def download_estimates(size)
  result = []
  DOWNLOAD_SPEEDS.each do |name, speed|
    result << [name, (size/speed).round(1)]
  end
  result.sort{|a,b| b[1]<=>a[1]}
end
icon_for(path) click to toggle source
# File lib/flunkey/helpers.rb, line 25
def icon_for(path)
  icon = case
    when path.directory? then "fa-folder"
    when path.bundle? then "fa-file-o"
    else "fa-file-o"
  end
  "<i class='fa #{icon}'></i>"
end
l(date)
Alias for: localize
localize(date) click to toggle source
# File lib/flunkey/helpers.rb, line 53
def localize(date)
  date.strftime('%d.%m.%Y %H:%M')
end
Also aliased as: l
title() click to toggle source
# File lib/flunkey/helpers.rb, line 17
def title
  return @title if @title
  if @path && @root
    return (@root.basename + @path.relative_path_from(@root)).to_s
  end
  "Flunkey #{Flunkey::VERSION}"
end
to_url(root, path) click to toggle source
# File lib/flunkey/helpers.rb, line 34
def to_url(root, path)
  "/#{root.basename + path.relative_path_from(root)}"
end