Module: BlackStack

Defined in:
lib/functions.rb

Defined Under Namespace

Modules: DateTime, Netting, Number, Strings

Class Method Summary collapse

Class Method Details

.require_local(filename = 'config.rb') ⇒ Object

This method does a require of the config.rb that must then then ruby script that is running, or where an .exe file genrated by OCRA is running.

When you run an OCRA .exe file, such .exe will unpackage the ruby script in a temporal folder. So any require will look for conf.rb into the temporal folder.

This function resolves that problem, by forcing the require to look into the folder where the .exe command is hosted.



14
15
16
17
18
19
20
# File 'lib/functions.rb', line 14

def self.require_local(filename='config.rb')
  current_dir = ($0) || __FILE__
  current_dir = File.expand_path('..', current_dir)
  source_dir = ENV["OCRA_EXECUTABLE"] || __FILE__ 
  source_dir = File.expand_path('..', source_dir)
  require File.expand_path('config', source_dir)
end