Sha256: 4f38188f289174d2f37c746ba54873cb14580d9eeeab8167d18f51b8d52e3349

Contents?: true

Size: 1.76 KB

Versions: 1

Compression:

Stored size: 1.76 KB

Contents

module Main
# top level constants
#
  Main::VERSION = '4.7.6' unless
    defined? Main::VERSION
  def self.version() Main::VERSION end

  Main::LIBDIR = File.join(File.dirname(File.expand_path(__FILE__)), self.name.downcase, '') unless
    defined? Main::LIBDIR
  def self.libdir() Main::LIBDIR end

  Main::EXIT_SUCCESS = 0 unless defined? Main::EXIT_SUCCESS
  Main::EXIT_FAILURE = 1 unless defined? Main::EXIT_FAILURE
  Main::EXIT_WARN = 42 unless defined? Main::EXIT_WARN
  Main::EXIT_WARNING = 42 unless defined? Main::EXIT_WARNING

## deps
#
  def Main.dependencies
    {
      'chronic'     => [ 'chronic'     , '~> 0.6.2' ] , 
      'fattr'       => [ 'fattr'       , '~> 2.2.0' ] , 
      'arrayfields' => [ 'arrayfields' , '~> 4.7.4' ] , 
      'map'         => [ 'map'         , '~> 4.3.0' ]
    }
  end

  def Main.libdir(*args, &block)
    @libdir ||= File.expand_path(__FILE__).sub(/\.rb$/,'')
    args.empty? ? @libdir : File.join(@libdir, *args)
  ensure
    if block
      begin
        $LOAD_PATH.unshift(@libdir)
        block.call()
      ensure
        $LOAD_PATH.shift()
      end
    end
  end

  def Main.load(*libs)
    libs = libs.join(' ').scan(/[^\s+]+/)
    Main.libdir{ libs.each{|lib| Kernel.load(lib) } }
  end
end
 



# built-in
#
  require 'logger'
  require 'enumerator'
  require 'set'
  require 'uri'
  require 'time'
  require 'date'
 
# use gems to pick up dependancies
#
  begin
    require 'rubygems'
  rescue LoadError
    42
  end

  if defined?(gem)
    Main.dependencies.each do |lib, dependency|
      gem(*dependency)
      require(lib)
    end
  end
 
# main's own libs
#
  Main.load %w[
    stdext.rb
    softspoken.rb
    util.rb
    logger.rb
    usage.rb
    cast.rb
    parameter.rb
    getoptlong.rb
    mode.rb
    program.rb
    factories.rb
  ]

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
main-4.7.6 lib/main.rb