Class: VAProfile::Exceptions::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/va_profile/exceptions/builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBuilder

Returns a new instance of Builder.



12
13
14
15
16
17
18
# File 'lib/va_profile/exceptions/builder.rb', line 12

def initialize
  @known_exceptions = VAProfile::Exceptions::Parser.instance.known_exceptions
  @stats = initial_stats
  @error_codes = []
  @needs_title = []
  @needs_detail = []
end

Instance Attribute Details

#detailObject (readonly)

Returns the value of attribute detail.



10
11
12
# File 'lib/va_profile/exceptions/builder.rb', line 10

def detail
  @detail
end

#error_codesObject (readonly)

Returns the value of attribute error_codes.



10
11
12
# File 'lib/va_profile/exceptions/builder.rb', line 10

def error_codes
  @error_codes
end

#known_exceptionsObject (readonly)

Returns the value of attribute known_exceptions.



10
11
12
# File 'lib/va_profile/exceptions/builder.rb', line 10

def known_exceptions
  @known_exceptions
end

#needs_detailObject (readonly)

Returns the value of attribute needs_detail.



10
11
12
# File 'lib/va_profile/exceptions/builder.rb', line 10

def needs_detail
  @needs_detail
end

#needs_titleObject (readonly)

Returns the value of attribute needs_title.



10
11
12
# File 'lib/va_profile/exceptions/builder.rb', line 10

def needs_title
  @needs_title
end

#statsObject (readonly)

Returns the value of attribute stats.



10
11
12
# File 'lib/va_profile/exceptions/builder.rb', line 10

def stats
  @stats
end

#statusObject (readonly)

Returns the value of attribute status.



10
11
12
# File 'lib/va_profile/exceptions/builder.rb', line 10

def status
  @status
end

#titleObject (readonly)

Returns the value of attribute title.



10
11
12
# File 'lib/va_profile/exceptions/builder.rb', line 10

def title
  @title
end

Instance Method Details

#construct_exceptions_from_csvObject

Takes the content from VAProfile’s CSV of current error codes, and converts them into formatted exceptions. These exceptions temporarily live in tmp/test.yml, until a developer replaces the old VAProfile exceptions in config/locales/exceptions.en.yml with these updated ones.

A sample formatted exception in tmp/test.yml looks like this:

- VET360_ADDR101:
  :<<: "*external_defaults"
  title: Address Type Size
  code: VET360_ADDR101
  detail: Address type size must be between 0 and 35.
  status: '400'

It also outputs to the console a breakdown of what was done, and what action needs to be taken by a developer. For example:

"Needs a title:"
["VET360_CORE108", "VET360_CORE301", "VET360_CORE503", ...]

"Needs detail:"
["VET360_CORE301"]

"Existing Codes: 94"
"New Codes: 74"
"Total Created: 168"
"Needs Title: 74"
"Needs Detail: 1"


47
48
49
50
51
52
# File 'lib/va_profile/exceptions/builder.rb', line 47

def construct_exceptions_from_csv
  build_formatted_exceptions
  include_custom_exceptions
  write_exceptions_to_yaml
  output_results_to_console
end