Class: MobyCommand::Application

Inherits:
CommandData show all
Defined in:
lib/tdriver/base/sut/generic/commands/application.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from CommandData

#get_application_id, #get_sut, #set_application_uid, #set_sut

Constructor Details

#initialize(command, arguments = {}) ⇒ Application

TODO: document me



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 27

def initialize( command, arguments = {} )
    
  arguments.check_type Hash, "wrong argument type $1 for #{ self.class } arguments (expected $2)"  

  # default values
  arguments.default = nil

  @command_arguments = arguments

  @_command = command

  @_application_name = nil
  @_application_uid = nil
  @_sut = nil
  @_arguments = nil
  @_events_to_listen = nil
  @_signals_to_listen = nil
  @_environment = nil
  @_working_directory = nil
  @_flags = nil
  @_start_command = nil
  @_refresh_args = nil
  @_attribute_csv_string = nil
  @_checksum = nil
  
  # store values from arguments - call setter method only when required      
  arguments.each_pair{ | key, value |
  
    # skip if value is nil (default)   
    next if value.nil?
  
    case key
    
      when :application_name
        name( value )
        
      when :application_uid
        uid( value )

      when :sut
        sut( value )
      
      when :arguments
        arguments( value )
      
      when :events_to_listen
        events_to_listen( value )

      when :signals_to_listen
        signals_to_listen( value )

      when :environment
        environment( value )

      when :working_directory
        working_directory( value )
                   
      when :flags
        flags( value )

      when :start_command
        start_command( value ) 

      when :refresh_arguments
        refresh_args( value )

      when :attribute_filter
        attribute_filter( value )

      when :checksum
        @_checksum = value

    else

      # show warning/exception?        
                        
    end
  
  }
  
  self

end

Instance Attribute Details

#command_argumentsObject (readonly)

Returns the value of attribute command_arguments.



24
25
26
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 24

def command_arguments
  @command_arguments
end

Instance Method Details

#arguments(arguments) ⇒ Object



166
167
168
169
170
171
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 166

def arguments( arguments )

  arguments.check_type [ String, NilClass ], 'wrong argument type $1 for application arguments (expected $2)'
  @_arguments = arguments

end

#attribute_filter(attribute_string) ⇒ Object



256
257
258
259
260
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 256

def attribute_filter(attribute_string)

  @_attribute_csv_string = attribute_string

end

#command(command_type) ⇒ Object

Defines the type of command this Application CommandData object represents

params

command_type

Symbol, defines the command to perform on the application

returns

Application

This CommandData object

raises

ArgumentError

When the supplied command_type is invalid.



128
129
130
131
132
133
134
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 128

def command( command_type )        

  @_command = command_type

  self    

end

#environment(env) ⇒ Object



180
181
182
183
184
185
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 180

def environment( env )

  env.check_type [ String, NilClass ], 'wrong argument type $1 for application environment (expected $2)'
  @_environment = env

end

#events_to_listen(events) ⇒ Object



194
195
196
197
198
199
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 194

def events_to_listen( events )

  events.check_type [ String, NilClass ], 'wrong argument type $1 for events to be listened (expected $2)'   
  @_events_to_listen = events

end

#flags(flags) ⇒ Object



173
174
175
176
177
178
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 173

def flags( flags ) 

  flags.check_type [ Hash, NilClass ], 'wrong argument type $1 for application flags (expected $2)'
  @_flags = flags

end

#get_applicationObject



238
239
240
241
242
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 238

def get_application

  @_application_name

end

#get_attribute_filterObject



262
263
264
265
266
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 262

def get_attribute_filter

  @_attribute_csv_string

end

#get_commandObject



232
233
234
235
236
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 232

def get_command

  @_command

end

#get_flagsObject



250
251
252
253
254
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 250

def get_flags

  @_flags

end

#get_refresh_argsObject



116
117
118
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 116

def get_refresh_args
  @_refresh_args
end

#get_uidObject



244
245
246
247
248
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 244

def get_uid

  @_application_uid

end

#name(name) ⇒ Object

Defines the name of the application this Application CommandData object is associated with

params

app_name

String, name of application to perform this command on

returns

Application

This CommandData object

raises

ArgumentError

When app_name is not nil or a String



158
159
160
161
162
163
164
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 158

def name( name )    

  name.check_type [ String, NilClass ], 'wrong argument type $1 for application name (expected $2)'
  @_application_name = name    
  self

end

#refresh_args(refresh_args = {}) ⇒ Object

Store the args for possible future use



112
113
114
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 112

def refresh_args(refresh_args={})
  @_refresh_args = refresh_args
end

#signals_to_listen(signals) ⇒ Object



201
202
203
204
205
206
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 201

def signals_to_listen( signals )

  signals.check_type [ String, NilClass ], 'wrong argument type $1 for signals to be listened (expected $2)'
  @_signals_to_listen = signals

end

#start_command(start_command) ⇒ Object



208
209
210
211
212
213
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 208

def start_command( start_command )

  start_command.check_type [ String, NilClass ], 'wrong argument type $1 for application start command (expected $2)'
  @_start_command = start_command

end

#sut(sut) ⇒ Object

Defines the used SUT to be able to access parameters when creating messages

params

sut

SUT, creator of the command.

returns

Application

This CommandData object

raises

ArgumentError

When sut is not nil or a SUT



143
144
145
146
147
148
149
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 143

def sut( sut )

  sut.check_type [ MobyBase::SUT, NilClass ], 'wrong argument type $1 for SUT (expected $2)'
  @_sut = sut
  self

end

#uid(app_uid) ⇒ Object

Defines the uid of the application this Application CommandData object is associated with

params

app_uid

FixNum, uid of application to perform this command on

returns

Application

This CommandData object

raises

ArgumentError

When app_name is not nil or a String



222
223
224
225
226
227
228
229
230
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 222

def uid( app_uid )

  app_uid.check_type [ Fixnum, String, NilClass ], 'wrong argument type $1 for application UID (expected $2)'

  @_application_uid = app_uid
  @_application_uid = @_application_uid.to_i unless @_application_uid == nil    
  self    

end

#working_directory(dir) ⇒ Object



187
188
189
190
191
192
# File 'lib/tdriver/base/sut/generic/commands/application.rb', line 187

def working_directory( dir )

  dir.check_type [ String, NilClass ], 'wrong argument type $1 for application working directory (expected $2)'
  @_working_directory = dir
  
end