Class: Pronto::BigFiles::MessageCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/pronto/bigfiles/message_creator.rb

Overview

Creates Pronto warning message objects

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(num_files, total_lines, target_num_lines) ⇒ MessageCreator

Returns a new instance of MessageCreator.



12
13
14
15
16
# File 'lib/pronto/bigfiles/message_creator.rb', line 12

def initialize(num_files, total_lines, target_num_lines)
  @num_files = num_files
  @total_lines = total_lines
  @target_num_lines = target_num_lines
end

Instance Attribute Details

#num_filesObject (readonly)

Returns the value of attribute num_files.



10
11
12
# File 'lib/pronto/bigfiles/message_creator.rb', line 10

def num_files
  @num_files
end

#target_num_linesObject (readonly)

Returns the value of attribute target_num_lines.



10
11
12
# File 'lib/pronto/bigfiles/message_creator.rb', line 10

def target_num_lines
  @target_num_lines
end

#total_linesObject (readonly)

Returns the value of attribute total_lines.



10
11
12
# File 'lib/pronto/bigfiles/message_creator.rb', line 10

def total_lines
  @total_lines
end

Instance Method Details

#create_message(patch_wrapper, num_lines) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/pronto/bigfiles/message_creator.rb', line 18

def create_message(patch_wrapper, num_lines)
  path = patch_wrapper.path
  line = patch_wrapper.first_added_line
  level = :warning
  msg = "This file, one of the #{num_files} largest in the project, " \
        "increased in size to #{num_lines} lines.  The total size " \
        "of those files is now #{total_lines} lines " \
        "(target: #{target_num_lines}).  Is this file complex " \
        "enough to refactor?"
  Message.new(path, line, level, msg, nil, Pronto::BigFiles)
end