Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

improve documentation for req

  • Loading branch information...
commit 59378366637d758f530fcdc16e404fee2436d380 1 parent 666e043
@alexch authored
Showing with 25 additions and 5 deletions.
  1. +19 −5 setup.rb
  2. +6 −0 todo.txt
24 setup.rb
@@ -1,21 +1,35 @@
require 'rubygems'
require 'activerecord'
+require 'erector/lib/erector'
+# 'req' is a simple replacement for 'require' for use in a project
+# whose file layout uses subdirectories that does away with some
+# annoyances like using '..' or 'RAILS_ROOT' all over the place.
+# Put this file in your project root directory and add your source
+# root directories to the ROOT_DIRS array. In your main app, require
+# this file. Then inside your sources, do all your requires with req
+# relative to this root directory and they'll get found.
+# It also tries to pre-require all files it finds in those source dirs,
+# in alphabetical order, but it'll miss some, so you may need to declare
+# more req's in files that need them.
ROOT = File.expand_path(File.dirname(__FILE__))
$: << ROOT
+ROOT_DIRS = ["lib", "domain", "views"]
def req(file)
unless file =~ /^\//
file = "#{ROOT}/#{file}"
- # puts "requiring #{file}"
- require file # using "load" allows auto-reloading, in theory
+ # puts "requiring #{file}" # uncomment for debugging
+ require file # using "load" allows auto-reloading, in theory, but I can't get it to work
-require 'erector/lib/erector'
-["lib", "domain", "views"].each do |dir|
+ROOT_DIRS.each do |dir|
Dir["#{ROOT}/#{dir}/*.rb"].sort.each do |file|
req file
6 todo.txt
@@ -0,0 +1,6 @@
+Use Warden for authentication

0 comments on commit 5937836

Please sign in to comment.
Something went wrong with that request. Please try again.