Class: Byebug::InfoCommand::FileCommand

Inherits:
Command
  • Object
show all
Includes:
Helpers::FileHelper
Defined in:
lib/byebug/commands/info/file.rb

Overview

Information about a particular source file

Instance Attribute Summary

Attributes inherited from Command

#processor

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers::FileHelper

#get_line, #get_lines, #n_lines, #normalize, #shortpath, #virtual_file?

Methods inherited from Command

#arguments, columnize, #context, #frame, help, #initialize, match, to_s

Methods included from Helpers::StringHelper

#camelize, #prettify

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/byebug/commands/info/file.rb', line 20

def self.description
  <<-EOD
    inf[o] f[ile]

    #{short_description}

    It informs about file name, number of lines, possible breakpoints in
    the file, last modification time and sha1 digest.
  EOD
end

.regexpObject



16
17
18
# File 'lib/byebug/commands/info/file.rb', line 16

def self.regexp
  /^\s* f(?:ile)? (?:\s+ (.+))? \s*$/x
end

.short_descriptionObject



31
32
33
# File 'lib/byebug/commands/info/file.rb', line 31

def self.short_description
  'Information about a particular source file.'
end

Instance Method Details

#executeObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/byebug/commands/info/file.rb', line 35

def execute
  file = @match[1] || frame.file
  unless File.exist?(file)
    return errmsg(pr('info.errors.undefined_file', file: file))
  end

  puts <<-EOC.gsub(/^ {6}/, '')

    File #{info_file_basic(file)}

    Breakpoint line numbers: #{info_file_breakpoints(file)}

    Modification time: #{info_file_mtime(file)}

    Sha1 Signature: #{info_file_sha1(file)}

  EOC
end