Class: Command::RecordingInterpreter

Inherits:
TextInterpreter show all
Defined in:
lib/command-set/interpreter/recording.rb

Defined Under Namespace

Classes: Complete, Event, Execute

Instance Attribute Summary

Attributes inherited from TextInterpreter

#complete_line

Attributes inherited from BaseInterpreter

#command_set, #logger, #out_io, #sub_modes, #subject

Instance Method Summary collapse

Methods inherited from TextInterpreter

#complete, #cook_input, #get_prompt, #go, #output_exception, #pause_before_dying, #prompt_user, #split_line, #stop

Methods inherited from BaseInterpreter

#behavior, #fill_subject, #get_formatter, #get_subject, #next_command, #pop_mode, #prep_subject, #process_input, #prompt_user, #push_mode, #subject_requirements

Constructor Details

#initialize(file, mod) ⇒ RecordingInterpreter

Returns a new instance of RecordingInterpreter.



62
63
64
65
66
67
68
69
70
71
# File 'lib/command-set/interpreter/recording.rb', line 62

def initialize(file, mod)
  @events = []
  @current_hash_array = nil
  @set_path = File::expand_path(file)
  @module_name = mod
  super()
  self.command_set = CommandSet::define_commands do
    require_commands(mod, file)
  end
end

Instance Method Details

#dump_to(io) ⇒ Object



91
92
93
94
95
96
97
98
# File 'lib/command-set/interpreter/recording.rb', line 91

def dump_to(io)
  setup = {
    'events' => @events,
    'set_path' => @set_path,
    'module_name' => @module_name
  }
  io.write(YAML::dump(setup))
end

#get_formattersObject



86
87
88
89
# File 'lib/command-set/interpreter/recording.rb', line 86

def get_formatters
  @current_hasharray = Results::HashArrayFormatter.new
  return [get_formatter, @current_hasharray]
end

#process_line(line) ⇒ Object



79
80
81
82
83
84
# File 'lib/command-set/interpreter/recording.rb', line 79

def process_line(line)
  event = Execute.new(line)
  @events << event
  super
  event.result = @current_hasharray.structure
end

#readline_complete(buffer, prefix) ⇒ Object



73
74
75
76
77
# File 'lib/command-set/interpreter/recording.rb', line 73

def readline_complete(buffer, prefix)
  result = super
  @events << Complete.new(buffer, prefix, result)
  return result
end