Skip to content

Commit

Permalink
Entirely decouple helper modules from Sinatra
Browse files Browse the repository at this point in the history
  • Loading branch information
Phrogz committed Mar 19, 2012
1 parent c31ec08 commit fec32d8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
7 changes: 6 additions & 1 deletion helpers/init.rb
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
require_relative 'partials'
# encoding: utf-8
require_relative 'partials'
MyApp.helpers PartialPartials

require_relative 'nicebytes'
MyApp.helpers NiceBytes
2 changes: 1 addition & 1 deletion helpers/nicebytes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
module NiceBytes
K = 2.0**10
M = 2.0**20
Expand Down Expand Up @@ -27,4 +28,3 @@ def nice_bytes( bytes, max_digits=3 )
end
module_function :nice_bytes
end
Sinatra.helpers NiceBytes if defined? Sinatra
19 changes: 7 additions & 12 deletions helpers/partials.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
# encoding: utf-8
require 'sinatra/base'

module Sinatra
module PartialPartials
def local_get(url)
call(env.merge("PATH_INFO" => url)).last.join
end
module PartialPartials
def spoof_request(uri,env_modifications={})
call(env.merge("PATH_INFO" => uri).merge(env_modifications)).last.join
end

def partial( page, variables={} )
haml page, {layout:false}, variables
end
def partial( page, variables={} )
haml page, {layout:false}, variables
end
helpers PartialPartials
end
end

0 comments on commit fec32d8

Please sign in to comment.