Class: Gitlab::Sherlock::FileSample

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/sherlock/file_sample.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, line_samples, duration, events) ⇒ FileSample

file - The full path to the file this sample belongs to. line_samples - An array of LineSample objects. duration - The total execution time in milliseconds. events - The total amount of events.


12
13
14
15
16
17
18
# File 'lib/gitlab/sherlock/file_sample.rb', line 12

def initialize(file, line_samples, duration, events)
  @id = SecureRandom.uuid
  @file = file
  @line_samples = line_samples
  @duration = duration
  @events = events
end

Instance Attribute Details

#durationObject (readonly)

Returns the value of attribute duration


6
7
8
# File 'lib/gitlab/sherlock/file_sample.rb', line 6

def duration
  @duration
end

#eventsObject (readonly)

Returns the value of attribute events


6
7
8
# File 'lib/gitlab/sherlock/file_sample.rb', line 6

def events
  @events
end

#fileObject (readonly)

Returns the value of attribute file


6
7
8
# File 'lib/gitlab/sherlock/file_sample.rb', line 6

def file
  @file
end

#idObject (readonly)

Returns the value of attribute id


6
7
8
# File 'lib/gitlab/sherlock/file_sample.rb', line 6

def id
  @id
end

#line_samplesObject (readonly)

Returns the value of attribute line_samples


6
7
8
# File 'lib/gitlab/sherlock/file_sample.rb', line 6

def line_samples
  @line_samples
end

Instance Method Details

#relative_pathObject


20
21
22
# File 'lib/gitlab/sherlock/file_sample.rb', line 20

def relative_path
  @relative_path ||= @file.gsub(%r{^#{Rails.root}/?}, '')
end

#sourceObject


28
29
30
# File 'lib/gitlab/sherlock/file_sample.rb', line 28

def source
  @source ||= File.read(@file)
end

#to_paramObject


24
25
26
# File 'lib/gitlab/sherlock/file_sample.rb', line 24

def to_param
  @id
end