Class: Kameleon::Shell::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/kameleon/shell.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Command

Returns a new instance of Command.



357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/kameleon/shell.rb', line 357

def initialize(raw)
  @value = raw.to_s.strip
  @number = self.class.counter
  @slug = Kameleon::Utils.generate_slug(@value)[0...30]
  @id = "%d_%d_%d" % [@number, $$, rand(Time.now.usec)]
  @begin_out = "__CMD_OUT_%s_BEGIN__" % @id
  @end_out = "__CMD_OUT_%s_END__" % @id
  @begin_out_pat = %r/#{ Regexp.escape(@begin_out) }(.*)/m
  @end_out_pat = %r/(.*)#{ Regexp.escape(@end_out) }/m
  @begin_err = "__CMD_ERR_%s_BEGIN__" % @id
  @end_err = "__CMD_ERR_%s_END__" % @id
  @begin_err_pat = %r/#{ Regexp.escape(@begin_err) }(.*)/m
  @end_err_pat = %r/(.*)#{ Regexp.escape(@end_err) }/m
  self.class.counter += 1
end

Instance Attribute Details

#begin_errObject (readonly)

Returns the value of attribute begin_err.



352
353
354
# File 'lib/kameleon/shell.rb', line 352

def begin_err
  @begin_err
end

#begin_err_patObject (readonly)

Returns the value of attribute begin_err_pat.



353
354
355
# File 'lib/kameleon/shell.rb', line 353

def begin_err_pat
  @begin_err_pat
end

#begin_outObject (readonly)

Returns the value of attribute begin_out.



348
349
350
# File 'lib/kameleon/shell.rb', line 348

def begin_out
  @begin_out
end

#begin_out_patObject (readonly)

Returns the value of attribute begin_out_pat.



349
350
351
# File 'lib/kameleon/shell.rb', line 349

def begin_out_pat
  @begin_out_pat
end

#end_errObject (readonly)

Returns the value of attribute end_err.



354
355
356
# File 'lib/kameleon/shell.rb', line 354

def end_err
  @end_err
end

#end_err_patObject (readonly)

Returns the value of attribute end_err_pat.



355
356
357
# File 'lib/kameleon/shell.rb', line 355

def end_err_pat
  @end_err_pat
end

#end_outObject (readonly)

Returns the value of attribute end_out.



350
351
352
# File 'lib/kameleon/shell.rb', line 350

def end_out
  @end_out
end

#end_out_patObject (readonly)

Returns the value of attribute end_out_pat.



351
352
353
# File 'lib/kameleon/shell.rb', line 351

def end_out_pat
  @end_out_pat
end

#idObject (readonly)

Returns the value of attribute id.



346
347
348
# File 'lib/kameleon/shell.rb', line 346

def id
  @id
end

#numberObject (readonly)

Returns the value of attribute number.



345
346
347
# File 'lib/kameleon/shell.rb', line 345

def number
  @number
end

#slugObject (readonly)

Returns the value of attribute slug.



347
348
349
# File 'lib/kameleon/shell.rb', line 347

def slug
  @slug
end

#valueObject (readonly)

Returns the value of attribute value.



344
345
346
# File 'lib/kameleon/shell.rb', line 344

def value
  @value
end

Class Method Details

.counterObject



341
# File 'lib/kameleon/shell.rb', line 341

def counter; @counter ||= 0; end

.counter=(n) ⇒ Object



342
# File 'lib/kameleon/shell.rb', line 342

def counter= n; @counter = n; end

Instance Method Details

#to_sObject



373
374
375
# File 'lib/kameleon/shell.rb', line 373

def to_s
  "%05d_#{@slug}" % @number
end