From 72c3a902a00ff9d88ed2fb666f22a5303c3fe8cd Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 4 Jun 2009 10:19:50 -0700 Subject: more generic require system --- code/directory.rb | 1 + code/types.rb | 2 +- ranger.rb | 32 ++++++++------------------------ 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)) -- cgit 1.4.1-2-gfad0