Class: ZendeskAppsSupport::Validations::JSHintValidationError

Inherits:
ValidationError
  • Object
show all
Defined in:
lib/zendesk_apps_support/validations/validation_error.rb

Constant Summary

Constants inherited from ValidationError

ValidationError::KEY_PREFIX

Instance Attribute Summary collapse

Attributes inherited from ValidationError

#data, #key

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ValidationError

from_hash, from_json, #to_json, #to_s

Constructor Details

#initialize(filename, jshint_errors) ⇒ JSHintValidationError

Returns a new instance of JSHintValidationError.



82
83
84
85
86
87
88
89
90
# File 'lib/zendesk_apps_support/validations/validation_error.rb', line 82

def initialize(filename, jshint_errors)
  errors = jshint_errors.compact.map { |err| "\n  L#{err['line']}: #{err['reason']}" }.join('')
  @filename = filename, @jshint_errors = jshint_errors
  super(:jshint, {
    file: filename,
    errors: errors,
    count: jshint_errors.length
  })
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



76
77
78
# File 'lib/zendesk_apps_support/validations/validation_error.rb', line 76

def filename
  @filename
end

#jshint_errorsObject (readonly)

Returns the value of attribute jshint_errors.



76
77
78
# File 'lib/zendesk_apps_support/validations/validation_error.rb', line 76

def jshint_errors
  @jshint_errors
end

Class Method Details

.vivify(hash) ⇒ Object



78
79
80
# File 'lib/zendesk_apps_support/validations/validation_error.rb', line 78

def self.vivify(hash)
  new(hash['filename'], hash['jshint_errors'])
end

Instance Method Details

#as_jsonObject



92
93
94
95
96
97
98
# File 'lib/zendesk_apps_support/validations/validation_error.rb', line 92

def as_json(*)
  {
    'class' => self.class.to_s,
    'filename' => filename,
    'jshint_errors' => jshint_errors
  }
end