about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-06-04 10:19:50 -0700
committerhut <hut@lavabit.com>2009-06-11 14:51:37 +0200
commit72c3a902a00ff9d88ed2fb666f22a5303c3fe8cd (patch)
treed275db368f03682b58b127efeefb8776478a430d
parente8beb6eb5a2db419e1426e23aee9d919888af5da (diff)
downloadranger-72c3a902a00ff9d88ed2fb666f22a5303c3fe8cd.tar.gz
more generic require system
-rw-r--r--code/directory.rb1
-rw-r--r--code/types.rb2
-rwxr-xr-xranger.rb32
3 files changed, 10 insertions, 25 deletions
diff --git a/code/directory.rb b/code/directory.rb
index c42392aa..a5bee819 100644
--- a/code/directory.rb
+++ b/code/directory.rb
@@ -1,3 +1,4 @@
+require 'code/extensions/basic.rb'
 class Directory
 	BAD_TIME = Time.at(0)
 	MOVIE_EXTENSIONS = %w(avi mpg mpeg mp4 mp5 ogv ogm wmv mkv flv fid vob div divx)
diff --git a/code/types.rb b/code/types.rb
index adb03219..6d3999c7 100644
--- a/code/types.rb
+++ b/code/types.rb
@@ -1,6 +1,6 @@
 module Fm
 	MIMETYPES = Marshal.load(File.read(
-		File.join(FM_DIR, 'data', 'mime.dat')))
+		File.join(MYDIR, 'data', 'mime.dat')))
 
 	def self.get_default_flags(file)
 		case file.mimetype
diff --git a/ranger.rb b/ranger.rb
index d6ca28fd..a3d893fb 100755
--- a/ranger.rb
+++ b/ranger.rb
@@ -11,19 +11,12 @@ LOG_LEVEL = 3
 
 require 'pathname'
 
-def File::resolve_symlink( path = __FILE__ )
-	Pathname.new(path).realpath
-end
-
-def require_from_here ( *list )
-	require File.join( FM_DIR, *list )
-end
-
 def fj( *args ) File.join( *args ) end
 
-$: << FM_DIR = File::dirname(File::resolve_symlink)
+$: << MYDIR = File.dirname(Pathname.new(__FILE__).realpath)
+
 
-#SCREENSAVER = fj FM_DIR, 'code', 'screensaver', 'clock.rb'
+#SCREENSAVER = fj MYDIR, 'code', 'screensaver', 'clock.rb'
 
 PID = Process.pid
 
@@ -51,20 +44,11 @@ require 'ostruct'
 class OpenStruct; def __table__() @table end end
 require 'thread'
 
-require_from_here 'interface/ncurses.rb'
-require_from_here 'code/extensions/basic.rb'
-require_from_here 'code/extensions/fileutils.rb'
-require_from_here 'code/fm.rb'
-require_from_here 'code/keys.rb'
-require_from_here 'code/types.rb'
-require_from_here 'code/bars.rb'
-require_from_here 'code/action.rb'
-require_from_here 'code/draw.rb'
-require_from_here 'code/directory.rb'
-require_from_here 'code/debug.rb'
-
-# Screensaver
-require_from_here 'code/screensaver/clock.rb'
+require 'interface/ncurses.rb'
+for file in Dir["#{MYDIR}/code/**/*.rb"]
+	file.slice! 0..MYDIR.size
+	require file
+end
 
 unless ARGV.empty? or File.directory?(pwd)
 	exec(Fm.getfilehandler_frompath(pwd))