Permalink
Browse files

Move DingHelpers to their own file (and load it)

  • Loading branch information...
1 parent e8d575b commit 9c6d64561bd16bd334aa70f6bc214b9acaf31679 Stephen Caudill committed Oct 16, 2009
Showing with 35 additions and 31 deletions.
  1. +2 −3 config/environment.rb
  2. +0 −28 lib/ding.rb
  3. +33 −0 lib/helpers/ding_helpers.rb
View
@@ -5,9 +5,8 @@
database_file = File.read(File.join(config_dir,'database.yml'))
database_hash = YAML.load(ERB.new(database_file).result)
-Dir.glob(File.join(config_dir,'..','lib','**','*.rb')) do |file|
- require file
-end
+Dir.glob(File.join(config_dir,'..','lib','helpers','*.rb')){|f| require f }
+Dir.glob(File.join(config_dir,'..','lib','**','*.rb')){|f| require f }
DataMapper.setup(:default, ENV['DATABASE_URL'] || database_hash[Ding.environment])
View
@@ -4,34 +4,6 @@
require 'config/environment'
-module DingHelpers
- def root_path
- "/"
- end
- def session_path(session)
- "/#{session.display_name}"
- end
- def session_reset_path(session)
- "/#{session.display_name}/reset"
- end
- def session_timers_path(session)
- "#{session_path(session)}/timers"
- end
- def timer
- return nil unless @session
- @timer ||= @session.last_timer
- end
- def next_timer
- @next_timer ||= @session.next_timer
- end
- def timer_class(session,type)
- case
- when session.next_timer == type; 'next'
- when session.last_timer.kind_of?(type); 'current'
- end
- end
-end
-
class Ding < Sinatra::Default
enable :raise_errors
@@ -0,0 +1,33 @@
+module DingHelpers
+ def root_path
+ "/"
+ end
+
+ def session_path(session)
+ "/#{session.display_name}"
+ end
+
+ def session_reset_path(session)
+ "/#{session.display_name}/reset"
+ end
+
+ def session_timers_path(session)
+ "#{session_path(session)}/timers"
+ end
+
+ def timer
+ return nil unless @session
+ @timer ||= @session.last_timer
+ end
+
+ def next_timer
+ @next_timer ||= @session.next_timer
+ end
+
+ def timer_class(session,type)
+ case
+ when session.next_timer == type; 'next'
+ when session.last_timer.kind_of?(type); 'current'
+ end
+ end
+end

0 comments on commit 9c6d645

Please sign in to comment.