daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. MyProgram
  2.  
  3. MyProgramsrcmyclass.rb
  4.  
  5. MyProgramtestmytest.rb
  6.    
  7. require_relative '../src/myclass'
  8.    
  9. $LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), "..", "src"))
  10.    
  11. $:.unshift File.expand_path("../../src", __FILE__)
  12. require 'myclass'
  13.    
  14. require File.expand_path "../../src/myclass", __FILE__
  15.    
  16. Pathname(__FILE__).dirname.realpath
  17.    
  18. # Read application config                                                      
  19. $hConf, $fConf = {}, File.expand_path("../config.rb", __FILE__)
  20. $hConf = File.open($fConf) {|f| eval(f.read)} if File.exist? $fConf
  21.  
  22.   # Application classpath                                                        
  23. $: << ($hConf[:appRoot] || File.expand_path("../bin/app", __FILE__))
  24.  
  25.   # Ruby libs                                                                    
  26. $lib = ($hConf[:rubyLib] || File.expand_path("../bin/lib", __FILE__))
  27. ($: << [$lib]).flatten! # lib is string or array, standardize
  28.    
  29. # Site- and server specific config - location of DB, tmp files etc.
  30. {
  31.   :webRoot => "/srv/www/myapp/data",
  32.   :rubyLib => "/somewhere/lib",
  33.   :tmpDir => "/tmp/myapp"
  34. }
  35.    
  36. path='../specific_folder/' # relative path from current file to required folder
  37.  
  38. Dir[File.dirname(__FILE__) + '/'+path+'*.rb'].each do |file|
  39.   require_relative path+File.basename(file) # require all files with .rb extension in this folder
  40. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top