Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MyProgram
- MyProgramsrcmyclass.rb
- MyProgramtestmytest.rb
- require_relative '../src/myclass'
- $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "src"))
- $:.unshift File.expand_path("../../src", __FILE__)
- require 'myclass'
- require File.expand_path "../../src/myclass", __FILE__
- Pathname(__FILE__).dirname.realpath
- # Read application config
- $hConf, $fConf = {}, File.expand_path("../config.rb", __FILE__)
- $hConf = File.open($fConf) {|f| eval(f.read)} if File.exist? $fConf
- # Application classpath
- $: << ($hConf[:appRoot] || File.expand_path("../bin/app", __FILE__))
- # Ruby libs
- $lib = ($hConf[:rubyLib] || File.expand_path("../bin/lib", __FILE__))
- ($: << [$lib]).flatten! # lib is string or array, standardize
- # Site- and server specific config - location of DB, tmp files etc.
- {
- :webRoot => "/srv/www/myapp/data",
- :rubyLib => "/somewhere/lib",
- :tmpDir => "/tmp/myapp"
- }
- path='../specific_folder/' # relative path from current file to required folder
- Dir[File.dirname(__FILE__) + '/'+path+'*.rb'].each do |file|
- require_relative path+File.basename(file) # require all files with .rb extension in this folder
- end
Add Comment
Please, Sign In to add comment