Class: SiSU_Load::Load

Inherits:
Object
  • Object
show all
Defined in:
lib/sisu/se_load.rb

Direct Known Subclasses

SiSU_Env::Load

Instance Method Summary collapse

Constructor Details

#initialize(prog, mandatory = false) ⇒ Load

Returns a new instance of Load.



61
62
63
# File 'lib/sisu/se_load.rb', line 61

def initialize(prog,mandatory=false)
  @prog,@mandatory=prog,mandatory
end

Instance Method Details

#progObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/sisu/se_load.rb', line 64

def prog
  load_prog=false
  $:.each do |reqpath|
    if FileTest.exist?("#{reqpath}/#{@prog}.rb")
      load_prog=true
      #SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).ok("#{reqpath}/#{@prog}.rb loaded")
      break
    #else SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).warn("#{reqpath}/#{@prog}.rb not found")
    end
  end
  if load_prog \
  and @prog=~/dbi/
    begin
      require 'dbi'
    rescue LoadError
      SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
        error('dbi NOT FOUND (LoadError)')
    end
  end
  if load_prog
    begin
      require @prog
    rescue LoadError
      SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
        error("#{@prog} NOT FOUND (LoadError)")
    end
  else
    @mandatory \
    ? (SiSU_Screen::Ansi.new(@prog,"*WARN* module required: #{@prog}").warn)
    : '' #(SiSU_Screen::Ansi.new(@prog,"*WARN* #{@prog} load requested").warn)
  end
  load_prog
end

#prog?Boolean

Returns:

  • (Boolean)


97
98
99
100
101
102
103
104
105
# File 'lib/sisu/se_load.rb', line 97

def prog?
  load_prog=false
  $:.each do |reqpath|
    if FileTest.exist?("#{reqpath}/#{@prog}.rb"); load_prog=true
      break
    end
  end
  load_prog
end