lib/stella.rb in solutious-stella-0.5.5 vs lib/stella.rb in solutious-stella-0.6.0

- old
+ new

@@ -1,101 +1,119 @@ - require 'date' require 'time' -require 'tempfile' -require 'socket' -require 'ostruct' -require 'optparse' require 'rubygems' +require 'logger' +require 'uri' +require 'httpclient' +require 'storable' +require 'stella/stats' +require 'threadify' +require 'timeunits' -# Common utilities -require 'utils/domainutil' -require 'utils/httputil' -require 'utils/fileutil' -require 'utils/mathutil' -require 'utils/escape' -require 'utils/stats' +require 'stella/crypto' -# Common dependencies -$: << File.join(STELLA_HOME, 'vendor', 'useragent', 'lib') -require 'user_agent' +require 'stella/common' -# Common Stella dependencies -require 'stella/support' -require 'stella/storable' - -# Common Stella Data Objects require 'stella/data/http' require 'stella/data/domain' -# Common Stella objects -require 'stella/text' +require 'stella/environment' +require 'stella/clients' +require 'stella/testrunner' +require 'stella/testplan' +require 'stella/loadtest' +require 'stella/functest' -require 'stella/logger' -require 'stella/response' -require 'stella/sysinfo' -require 'stella/test/definition' -require 'stella/test/run/summary' -require 'stella/test/stats' +srand -# Commands -require 'stella/command/base' -require 'stella/command/localtest' +# Common dependencies +STELLA_HOME = File.expand_path(File.join(File.dirname(__FILE__), '..')) +$: << File.join(STELLA_HOME, 'vendor', 'useragent', 'lib') -# Adapters -require 'stella/adapter/base' -require 'stella/adapter/ab' -require 'stella/adapter/siege' -require 'stella/adapter/httperf' -# = Stella # A friend in performance testing. -# -# This class ties Stella together. It must be required because it defines -# several constants which are used througout the other classes. +SYSINFO+ -# is particularly important because it detects the platform and requires -# platform specific modules. module Stella - # Autodetecets information about the local system, - # including OS (unix), implementation (freebsd), and architecture (x64) - SYSINFO = Stella::SystemInfo.new unless defined? SYSINFO - # A global logger for info, error, and debug messages. - LOGGER = Stella::Logger.new(:debug=>false) unless defined? LOGGER - # A global resource for all interface text. - TEXT = Stella::Text.new('en') unless defined? TEXT + + LOGGER = Logger.new(:debug_level=>0) unless defined? LOGGER module VERSION #:nodoc: MAJOR = 0.freeze unless defined? MAJOR - MINOR = 5.freeze unless defined? MINOR - TINY = 5.freeze unless defined? TINY + MINOR = 6.freeze unless defined? MINOR + TINY = 0.freeze unless defined? TINY def self.to_s [MAJOR, MINOR, TINY].join('.') end def self.to_f self.to_s.to_f end end - def self.debug=(enable=false) - Stella::LOGGER.debug_level = enable - end - def self.text(*args) - TEXT.msg(*args) + def self.debug_level + Stella::LOGGER.debug_level end - def self.sysinfo - SYSINFO + def self.debug_level=(level) + Stella::LOGGER.debug_level = level end def self.info(*args) LOGGER.info(*args) end def self.error(*args) LOGGER.error(*args) end + def self.fatal(*args) + LOGGER.error(*args) + exit 1 + end + + def self.debug(*args) + LOGGER.debug(*args) + end end +module Stella + module DSL + include Stella::DSL::TestPlan + include Stella::DSL::FunctionalTest + include Stella::DSL::LoadTest + include Stella::DSL::Environment + # For Modules + #extend Stella::DSL::TestPlan + #extend Stella::DSL::FunctionalTest + end +end + +class Object #:nodoc: all +# The hidden singleton lurks behind everyone + def metaclass; class << self; self; end; end + def meta_eval &blk; metaclass.instance_eval &blk; end + + # Adds methods to a metaclass + def meta_def name, &blk + meta_eval { define_method name, &blk } + end + + # Defines an instance method within a class + def class_def name, &blk + class_eval { define_method name, &blk } + end + +end + +class Array + # create a hash from an array of [key,value] tuples + # you can set default or provide a block just as with Hash::new + # Note: if you use [key, value1, value2, value#], hash[key] will + # be [value1, value2, value#] + # From: http://www.ruby-forum.com/topic/138218#615260 + def stella_to_hash(default=nil, &block) + hash = block_given? ? Hash.new(&block) : Hash.new(default) + each { |(key, *value)| hash[key]=*value } + hash + end +end