aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v6/sysenv.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2014-02-05 00:27:47 -0500
committerRalph Amissah <ralph@amissah.com>2014-02-05 00:27:47 -0500
commitbd5e94912c594372eca319e75e15c364b7e124ea (patch)
treef18f7aec63b42bb9062a22ac000d197a241d1536 /lib/sisu/v6/sysenv.rb
parentv5 v6: html, cleaning, minor (diff)
v5 v6: wrappers round require
Diffstat (limited to 'lib/sisu/v6/sysenv.rb')
-rw-r--r--lib/sisu/v6/sysenv.rb99
1 files changed, 79 insertions, 20 deletions
diff --git a/lib/sisu/v6/sysenv.rb b/lib/sisu/v6/sysenv.rb
index 46bb30ca..437d4088 100644
--- a/lib/sisu/v6/sysenv.rb
+++ b/lib/sisu/v6/sysenv.rb
@@ -66,12 +66,20 @@
module SiSU_Env
require_relative 'constants' # constants.rb
require_relative 'utils' # utils.rb
- require 'fileutils'
- include FileUtils::Verbose
- require 'singleton'
+ begin
+ require 'singleton'
+ require 'fileutils'
+ include FileUtils::Verbose
+ rescue LoadError
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('singleton or fileutils NOT FOUND (LoadError)')
+ end
@@noyaml=false
class InfoDate
- require 'date'
+ begin
+ require 'date'
+ rescue LoadError
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('date NOT FOUND (LoadError)')
+ end
attr_accessor :dt,:t
def initialize
@dt,@t=Date.today.to_s,Time.now
@@ -97,7 +105,11 @@ module SiSU_Env
end
end
class InfoSystemGen
- require 'rbconfig'
+ begin
+ require 'rbconfig'
+ rescue LoadError
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('rbconfig NOT FOUND (LoadError)')
+ end
@@user,@@home,@@hostname,@@pwd,@@sisu_etc,@@host,@@arch,@@rbver,@@dir_arch,@@dir_sitearch,@@dir_bin,@@locale,@@rc,@@sisurc_path,@@ad=ENV['USER'],ENV['HOME'],ENV['HOSTNAME'],ENV['PWD'],Config::CONFIG['sysconfdir'] + '/sisu',Config::CONFIG['host'],Config::CONFIG['arch'],%x{ruby -v}.strip,Config::CONFIG['archdir'],Config::CONFIG['sitearchdir'],Config::CONFIG['bindir'],%x{locale charmap}.strip,nil,nil,{} # %x{ruby -v}.strip # Config::CONFIG['rb_ver']
out=Config::CONFIG['localstatedir']
etc=Config::CONFIG['sysconfdir'] + '/sisu'
@@ -242,10 +254,18 @@ module SiSU_Env
end
if load_prog \
and @prog=~/dbi/
- require 'dbi' #revisit
+ begin
+ require 'dbi'
+ rescue LoadError
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('dbi NOT FOUND (LoadError)')
+ end
end
if load_prog
- require @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)
@@ -330,7 +350,11 @@ module SiSU_Env
f=S_CONF[:rc_yml]
p_f="#{v}/#{f}"
if FileTest.exist?(p_f)
- require 'yaml'
+ begin
+ require 'yaml'
+ rescue LoadError
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('yaml NOT FOUND (LoadError)')
+ end
@@sisurc_path=v
@@rc=YAML::load(File::open(p_f))
break
@@ -339,7 +363,11 @@ module SiSU_Env
f='sisurc.yaml'
p_f="#{v}/#{f}"
if FileTest.exist?(p_f)
- require 'yaml'
+ begin
+ require 'yaml'
+ rescue LoadError
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('yaml NOT FOUND (LoadError)')
+ end
@@sisurc_path=v
@@rc=YAML::load(File::open(p_f))
break
@@ -378,7 +406,11 @@ module SiSU_Env
else
if FileTest.exist?("#{v}/list.yml")
unless @@ad[:promo_list]
- require 'yaml'
+ begin
+ require 'yaml'
+ rescue LoadError
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('yaml NOT FOUND (LoadError)')
+ end
@@ad[:promo_list] ||= YAML::load(File::open("#{v}/list.yml"))
end
@@ad[:flag_promo]=true
@@ -396,7 +428,11 @@ module SiSU_Env
else
if FileTest.exist?("#{v}/promo.yml")
unless @@ad[:promo]
- require 'yaml'
+ begin
+ require 'yaml'
+ rescue LoadError
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('yaml NOT FOUND (LoadError)')
+ end
@@ad[:promo] ||= YAML::load(File::open("#{v}/promo.yml"))
end
@@ad[:flag_promo]=true
@@ -1030,9 +1066,13 @@ module SiSU_Env
end
end
class InfoEnv < EnvCall
- require 'pathname'
- require 'fileutils'
- include FileUtils
+ begin
+ require 'pathname'
+ require 'fileutils'
+ include FileUtils
+ rescue LoadError
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('pathname or fileutils NOT FOUND (LoadError)')
+ end
attr_accessor :filename,:sys,:home,:hostname,:user,:env,:rc,:www,:fnb,:fnn,:fnt,:flv,:webserv_path,:stub_pwd,:stub_src,:webserv_host_cgi,:webserv_port_cgi,:processing,:processing_git,:etc,:yamlrc_dir
@@image_flag,@@local_image=true,true #warning on @@image_flag
@@fb,@@man_path=nil,nil
@@ -3169,8 +3209,12 @@ WOK
end
end
class CleanOutput
- require 'fileutils'
- include FileUtils::Verbose
+ begin
+ require 'fileutils'
+ include FileUtils::Verbose
+ rescue LoadError
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('fileutils NOT FOUND (LoadError)')
+ end
def initialize(opt)
@opt=opt
z=SiSU_Env::FileMap.new(opt)
@@ -3326,7 +3370,11 @@ WOK
end
class InfoRemote < FileMap
@@flag_remote=false
- require 'socket'
+ begin
+ require 'socket'
+ rescue LoadError
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('socket NOT FOUND (LoadError)')
+ end
def initialize(opt)
super(opt) #
@opt=opt
@@ -3674,8 +3722,12 @@ WOK
end
class InfoVersion <InfoEnv
include Singleton
- require 'rbconfig'
- require 'yaml'
+ begin
+ require 'rbconfig'
+ require 'yaml'
+ rescue LoadError
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('rbconfig or yaml NOT FOUND (LoadError)')
+ end
@@lib_path=nil
def get_version
@version={}
@@ -4291,7 +4343,14 @@ WOK
DBI.connect(sqlite_discrete.dbi)
end
def conn_sqlite3
- SQLite3::Database.new(sqlite_discrete.sqlite3)
+ begin
+ $sqlite3=:yes
+ require 'sqlite3'
+ SQLite3::Database.new(sqlite_discrete.sqlite3)
+ rescue LoadError
+ $sqlite3=:no
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('sqlite3 NOT FOUND (LoadError)')
+ end
end
self
end