Sha256: 9da7d47712fcce5db52fd1f3e35b5e13600ba795cf3abff45bfabb59d5951066

Contents?: true

Size: 960 Bytes

Versions: 2

Compression:

Stored size: 960 Bytes

Contents

$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
require 'rubygems'
require 'sinatra'

require 'rack-sparklines'
require 'rack-sparklines/handlers/csv_data'
require 'rack-sparklines/cachers/filesystem'

pub_dir = File.expand_path(File.join(File.dirname(__FILE__), 'public'))
use Rack::Sparklines, :prefix => 'sparks',
  :handler => Rack::Sparklines::Handlers::CsvData.new(File.join(pub_dir, 'temps')),
  :cacher  => Rack::Sparklines::Cachers::Filesystem.new(File.join(pub_dir, 'sparks'))

get '/' do
  @body = $readme
  erb :readme
end

def simple_format(text)
  start_tag = "<p>"
  text = text.to_s.dup
  text.gsub!(/\r\n?/, "\n")                    # \r\n and \r -> \n
  text.gsub!(/\n\n+/, "</p>\n\n#{start_tag}")  # 2+ newline  -> paragraph
  text.gsub!(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline   -> br
  text.insert 0, start_tag
  text << "</p>"
end

$readme = simple_format IO.read(File.join(File.dirname(__FILE__), '..', 'README.rdoc'))

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-sparklines-1.1.0 demo/sparkline_demo.rb
rack-sparklines-1.0.0 demo/sparkline_demo.rb