Class: Byebug::InfoCommand::FileCommand

Inherits:
Command
  • Object
show all
Includes:
Helpers::FileHelper, Helpers::StringHelper
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::StringHelper

#camelize, #deindent, #prettify

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

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/byebug/commands/info/file.rb', line 23

def self.description
  <<-DESCRIPTION
    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.
  DESCRIPTION
end

.regexpObject



19
20
21
# File 'lib/byebug/commands/info/file.rb', line 19

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

.short_descriptionObject



34
35
36
# File 'lib/byebug/commands/info/file.rb', line 34

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

Instance Method Details

#executeObject



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

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

  puts prettify <<-RUBY
    File #{info_file_basic(file)}

    Breakpoint line numbers: #{info_file_breakpoints(file)}

    Modification time: #{info_file_mtime(file)}

    Sha1 Signature: #{info_file_sha1(file)}
  RUBY
end