Class: Nandi::MigrationViolations

Inherits:
Object
  • Object
show all
Defined in:
lib/nandi/migration_violations.rb

Instance Method Summary collapse

Constructor Details

#initializeMigrationViolations

Returns a new instance of MigrationViolations.



5
6
7
8
9
10
# File 'lib/nandi/migration_violations.rb', line 5

def initialize
  @ungenerated_files = []
  @handwritten_files = []
  @out_of_date_files = []
  @hand_edited_files = []
end

Instance Method Details

#add_hand_edited(altered_files, directory) ⇒ Object



33
34
35
36
37
38
# File 'lib/nandi/migration_violations.rb', line 33

def add_hand_edited(altered_files, directory)
  return if altered_files.empty?

  full_paths = build_full_paths(altered_files, directory)
  @hand_edited_files.concat(full_paths)
end

#add_handwritten(handwritten_files, directory) ⇒ Object



19
20
21
22
23
24
# File 'lib/nandi/migration_violations.rb', line 19

def add_handwritten(handwritten_files, directory)
  return if handwritten_files.empty?

  full_paths = build_full_paths(handwritten_files, directory)
  @handwritten_files.concat(full_paths)
end

#add_out_of_date(changed_files, directory) ⇒ Object



26
27
28
29
30
31
# File 'lib/nandi/migration_violations.rb', line 26

def add_out_of_date(changed_files, directory)
  return if changed_files.empty?

  full_paths = build_full_paths(changed_files, directory)
  @out_of_date_files.concat(full_paths)
end

#add_ungenerated(missing_files, directory) ⇒ Object



12
13
14
15
16
17
# File 'lib/nandi/migration_violations.rb', line 12

def add_ungenerated(missing_files, directory)
  return if missing_files.empty?

  full_paths = build_full_paths(missing_files, directory)
  @ungenerated_files.concat(full_paths)
end

#any?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/nandi/migration_violations.rb', line 40

def any?
  [@ungenerated_files, @handwritten_files, @out_of_date_files, @hand_edited_files].any?(&:any?)
end

#to_error_messageObject



44
45
46
47
48
49
50
51
52
53
# File 'lib/nandi/migration_violations.rb', line 44

def to_error_message
  error_messages = []

  error_messages << ungenerated_error if @ungenerated_files.any?
  error_messages << handwritten_error if @handwritten_files.any?
  error_messages << out_of_date_error if @out_of_date_files.any?
  error_messages << hand_edited_error if @hand_edited_files.any?

  error_messages.join("\n\n")
end