module TurnipFormatter::Renderer::Html

Attributes

script_codes[RW]
script_files[RW]
style_codes[RW]
style_files[RW]

Public Class Methods

add_javascript(script) click to toggle source
# File lib/turnip_formatter/renderer/html.rb, line 23
def add_javascript(script)
  case
  when local_file?(script)
    script_codes << File.read(script)
  when remote_url?(script)
    script_files << script
  end
end
add_stylesheet(stylesheet) click to toggle source
# File lib/turnip_formatter/renderer/html.rb, line 32
def add_stylesheet(stylesheet)
  case
  when local_file?(stylesheet)
    style_codes << File.read(stylesheet)
  when remote_url?(stylesheet)
    style_files << stylesheet
  end
end
project_name() click to toggle source
# File lib/turnip_formatter/renderer/html.rb, line 19
def project_name
  TurnipFormatter.configuration.title
end
render_javascript_codes() click to toggle source
# File lib/turnip_formatter/renderer/html.rb, line 41
def render_javascript_codes
  script_codes.join("\n")
end
render_step_template_stylesheet_codes() click to toggle source
# File lib/turnip_formatter/renderer/html.rb, line 61
def render_step_template_stylesheet_codes
  TurnipFormatter.step_templates.map do |template|
    template.class.css
  end.join("\n")
end
render_stylesheet_codes() click to toggle source
# File lib/turnip_formatter/renderer/html.rb, line 51
def render_stylesheet_codes
  style_codes.join("\n")
end
reset!() click to toggle source
# File lib/turnip_formatter/renderer/html.rb, line 12
def reset!
  @script_codes = []
  @script_files = []
  @style_codes = []
  @style_files = []
end

Private Class Methods

local_file?(path) click to toggle source
# File lib/turnip_formatter/renderer/html.rb, line 69
def local_file?(path)
  File.exist? path
end
remote_url?(path) click to toggle source
# File lib/turnip_formatter/renderer/html.rb, line 73
def remote_url?(path)
  uri = URI.parse(path)
  return true if %w(http https).include?(uri.scheme)
  return true if uri.scheme.nil? && path.start_with?('//')
  false
rescue URI::InvalidURIError
  false
end