Class: TDriver::Parameter

Inherits:
Object show all
Defined in:
lib/tdriver/util/parameter/parameter.rb

Overview

ParameterHash

Class Method Summary collapse

Class Method Details

.[](key, *default) ⇒ Object

TODO: document me



962
963
964
965
966
# File 'lib/tdriver/util/parameter/parameter.rb', line 962

def []( key, *default )

  @parameters[ key, *default ]
      
end

.[]=(key, value) ⇒ Object

TODO: document me



969
970
971
972
973
# File 'lib/tdriver/util/parameter/parameter.rb', line 969

def []=( key, value )

  @parameters[ key ] = value

end

.apply_template(name) ⇒ Object

TODO: document me



923
924
925
926
927
928
929
930
931
# File 'lib/tdriver/util/parameter/parameter.rb', line 923

def apply_template( name )
  
  @parameters.recursive_merge!( 
    @templates.fetch( name.to_s ){           
      raise MobyUtil::TemplateNotFoundError, "Template #{ name.inspect } not found"
    }
  )

end

.clearObject

TODO: document me



891
892
893
894
895
896
897
# File 'lib/tdriver/util/parameter/parameter.rb', line 891

def clear

  @parameter_files.clear

  @parameters.clear

end

.configured_sutsObject

TODO: document me



1032
1033
1034
1035
1036
# File 'lib/tdriver/util/parameter/parameter.rb', line 1032

def configured_suts

  @sut_list

end

.delete(key) ⇒ Object

TODO: document me



990
991
992
993
994
# File 'lib/tdriver/util/parameter/parameter.rb', line 990

def delete( key )

  @parameters.delete( key )

end

.fetch(key, *default, &block) ⇒ Object

TODO: document me



976
977
978
979
980
# File 'lib/tdriver/util/parameter/parameter.rb', line 976

def fetch( key, *default, &block )

  @parameters.__send__( :[], key, *default, &block )

end

.filesObject

TODO: document me



900
901
902
903
904
905
# File 'lib/tdriver/util/parameter/parameter.rb', line 900

def files

  # return loaded parameter files list
  @parameter_files

end

.has_key?(key) ⇒ Boolean

TODO: document me

Returns:

  • (Boolean)


934
935
936
937
938
# File 'lib/tdriver/util/parameter/parameter.rb', line 934

def has_key?( key )

  @parameters.has_key?( key )

end

.has_template?(name) ⇒ Boolean

TODO: document me

Returns:

  • (Boolean)


916
917
918
919
920
# File 'lib/tdriver/util/parameter/parameter.rb', line 916

def has_template?( name )

  @templates.has_key?( name.to_s )

end

.has_value?(key) ⇒ Boolean

TODO: document me

Returns:

  • (Boolean)


941
942
943
944
945
# File 'lib/tdriver/util/parameter/parameter.rb', line 941

def has_value?( key )

  @parameters.has_value?( key )

end

.hashObject



1018
1019
1020
1021
1022
# File 'lib/tdriver/util/parameter/parameter.rb', line 1018

def hash

  @parameters
  
end

.if_found(key, &block) ⇒ Object

TODO: document me



983
984
985
986
987
# File 'lib/tdriver/util/parameter/parameter.rb', line 983

def if_found( key, &block )

  @parameters.__send__( :if_found, key, &block )

end

.initObject

TODO: document me



223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/tdriver/util/parameter/parameter.rb', line 223

def init

  # initialize only once 
  return if defined?( @initalized )

  # retrieve platform name
  @platform = MobyUtil::EnvironmentHelper.platform

  # detect is posix platform
  @is_posix = MobyUtil::EnvironmentHelper.posix?

  # retrieve parameter filenames from command line arguments
  parse_command_line_arguments

  # reset templates and parameters
  reset_hashes

  # indicates that class is already initialized - templates and parameters will not reset
  @initialized = true

end

.inspectObject

TODO: document me



997
998
999
1000
1001
# File 'lib/tdriver/util/parameter/parameter.rb', line 997

def inspect

  @parameters.inspect

end

.keysObject

TODO: document me



948
949
950
951
952
# File 'lib/tdriver/util/parameter/parameter.rb', line 948

def keys

  @parameters.keys

end

.load_parameters_xml(filename, reset = false) ⇒ Object

load parameter xml files



1048
1049
1050
1051
1052
1053
1054
# File 'lib/tdriver/util/parameter/parameter.rb', line 1048

def load_parameters_xml( filename, reset = false )

  warn "warning: deprecated method #{ self.name }##{ __method__ }; please use #{ self.name }#parse_file instead"

  parse_file( filename, reset )

end

.newObject



214
215
216
217
218
219
220
# File 'lib/tdriver/util/parameter/parameter.rb', line 214

def new

  warn_caller "$1:$2 warning: #{ to_s } is static class; unable initialize new instance of it"

  nil

end

.parametersObject



1010
1011
1012
1013
1014
1015
1016
# File 'lib/tdriver/util/parameter/parameter.rb', line 1010

def parameters

  warn "warning: deprecated method #{ self.name }##{ __method__ }; please use #{ self.name }#hash instead"

  hash
  
end

.parse_file(filename, reset_parameters = false) ⇒ Object

TODO: document me



850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
# File 'lib/tdriver/util/parameter/parameter.rb', line 850

def parse_file( filename, reset_parameters = false )

  # check argument type for filename
  filename.check_type [ String ], 'wrong argument type $1 for filename argument (expected $2)'

  # check argument type for filename
  reset_parameters.check_type [ TrueClass, FalseClass ], 'wrong argument type $1 for reset_parameters boolean argument (expected $2)'

  # reset parameter hash if requested
  @parameters.clear if reset_parameters == true

  # load and parse given file
  load_parameters_file( filename )

end

.parse_string(source, merge_hashes = true) ⇒ Object

TODO: document me



867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
# File 'lib/tdriver/util/parameter/parameter.rb', line 867

def parse_string( source, merge_hashes = true )

  # check argument type for source
  source.check_type [ String ], 'wrong argument type $1 for source XML argument (expected $2)'

  # check argument type for merge_hashes
  merge_hashes.check_type [ TrueClass, FalseClass ], 'wrong argument type $1 for merge_hashes argument (expected $2)'

  # process xml string, returns hash as result
  hash = process_string( source )  

  if merge_hashes
  
    @parameters.recursive_merge!( hash )
  
  else

    @parameters.merge!( hash )
  
  end

end

.resetObject

TODO: document me



1025
1026
1027
1028
1029
# File 'lib/tdriver/util/parameter/parameter.rb', line 1025

def reset

  reset_hashes
      
end

.reset_parametersObject

deprecated methods



1039
1040
1041
1042
1043
1044
1045
# File 'lib/tdriver/util/parameter/parameter.rb', line 1039

def reset_parameters

  warn "warning: deprecated method #{ self.name }##{ __method__ }; please use #{ self.name }#reset instead"

  reset

end

.template_filesObject

TODO: document me



908
909
910
911
912
913
# File 'lib/tdriver/util/parameter/parameter.rb', line 908

def template_files

  # return loaded parameter files list
  @template_files

end

.templatesObject

TODO: document me



1004
1005
1006
1007
1008
# File 'lib/tdriver/util/parameter/parameter.rb', line 1004

def templates

  @templates

end

.valuesObject

TODO: document me



955
956
957
958
959
# File 'lib/tdriver/util/parameter/parameter.rb', line 955

def values

  @parameters.values

end