bin/ttk in ttk-0.1.580 vs bin/ttk in ttk-0.2.0

- old
+ new

@@ -1,36 +1,36 @@ #!/usr/bin/env ruby # Author:: The TTK Team. # Copyright:: Copyright (c) 2004, 2005 TTK team. All rights reserved. # License:: LGPL -# $Id: ttk 578 2005-04-14 20:46:09Z ertai $ +# $Id: ttk 611 2005-06-05 17:17:11Z ertai $ -require 'pathname' +begin + require 'pathname' + require 'yaml' -ME = Pathname.new($0).basename -ME_DIR = Pathname.new(__FILE__).dirname + ME = Pathname.new($0).basename + ME_DIR = Pathname.new(__FILE__).dirname -$PROGRAME_NAME = ME -$PROGRAME_NAME.freeze -$VERBOSE = true # you can use 'export RUBYOPT="-w"' too + $PROGRAME_NAME = ME + $PROGRAME_NAME.freeze + $VERBOSE = true # you can use 'export RUBYOPT="-w"' too -dir = Pathname.new(__FILE__).dirname -$: << dir + '..' + 'lib' -$: << dir + '..' + 'ruby_ex' -$: << dir + require 'ostruct' + require Pathname.new(__FILE__).dirname.parent + 'lib/ttk' -REVISION = (ME_DIR + '..' + 'REVISION').read.gsub!(/\D/, '').to_i -DATE = (ME_DIR + '..' + 'DATE').read.sub!(/^.*?\((.*?)\).*?$/, '\1').chomp -require 'erb' -rev, date = REVISION, DATE -VERSION = ERB.new((ME_DIR + '..' + 'VERSION').read, nil, '<%>').result(binding) + SPEC_DYN_YML = ME_DIR + '..' + 'SPEC.dyn.yml' + SPEC_DYN = YAML::load(SPEC_DYN_YML.read) + TTK_VERSION = SPEC_DYN.version.to_s + TTK_DATE = SPEC_DYN.date + VERSION_PATH = ME_DIR + '..' + 'VERSION' + require 'erb' + TTK_VERSION_TEXT = ERB.new(VERSION_PATH.read, nil, '<%>').result(binding) -require 'ttk' -require "#{ME_DIR}/getopts/ttk" + require "#{ME_DIR}/getopts/ttk" -begin argv = ARGV.dup opts = TTK::Getopts::TTK.parse(argv) require 'profile' if opts[:profile_on] @@ -40,19 +40,23 @@ log_factory = TTK::LoggerFactory.new log_factory.severity_level = opts[:log_severity] log_factory.severity_level = ENV['TTK_DEBUG'] if ENV.has_key?('TTK_DEBUG') log_factory.verbosity_level = opts[:log_verbosity] + log_factory.section_tree << TTK::Logger::SectionNode.new('basicObserver') log_factory.active_section = opts[:log_section] - if opts[:log_severity] <= Logger::Severity::DEBUG - opts[:observers] << TTK::Filters::BasicLogger.new - end - log = log_factory.create(*opts[:observers]) - + + log.info_basicObserver do + log.add_observer(TTK::Dumpers::Basic.new(STDERR)) + nil + end + symtbl = TTK::SymTbl.new + symtbl[:ttk] = Pathname.new($0).expand_path + symtbl[:core_ex] = CoreEx.dir symtbl[:symtbl_class] = symtbl.class symtbl[:pwd] = Pathname.pwd.expand_path symtbl[:loader] = opts[:current_loader].new symtbl[:tester_uris] = opts[:tester_uris] symtbl.freeze_key(:tester_uris) @@ -77,11 +81,11 @@ t.contents = argv # Load the cache file if cache_dir is set. if cache_dir = opts[:cache_dir] cache = cache_dir + 'cache.yml' - t.symtbl[:use_cache] = TTK::Loaders::Yaml.new.load_doc(cache.read) + t.symtbl[:use_cache] = TTK::Loaders::Yaml.new.load(cache.read) end # Disable the automatic cleaning of TempPath for the cache mode. if opts[:cache] TempPath.auto_clean = false @@ -151,21 +155,25 @@ end end # Handle the --dump-status option. STDOUT.puts status.to_yaml if opts[:dump_status] + exit(2) unless status.pass? else - symtbl[:loader].load_doc(opts[:current_input]).to_ttk_log(log) + symtbl[:loader].load(opts[:current_input]).to_ttk_log(log) end -rescue => exc - - TempPath.auto_clean = true - Thread.critical = true - unless exc.is_a?(OptionParser::ParseError) - raise if log.nil? or log.severity_level < TTK::Logger::Severity::WARN +rescue Exception => ex + + TempPath.auto_clean = true if defined? TempPath + Thread.critical = true if defined? Thread + raise ex if ex.is_a? SystemExit + if log.nil? + msg = (ex.respond_to? :tiny_pp)? ex.tiny_pp : "#{ex.inspect}" + STDERR.puts "ERROR:\n #{msg}" + else + log.error { ex } end - STDERR << "#{ME}: #{exc}\n" exit(1) ensure log.close unless log.nil?