Exception: 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.



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

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.



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

def filename
  @filename
end

#jshint_errorsObject (readonly)

Returns the value of attribute jshint_errors.



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

def jshint_errors
  @jshint_errors
end

Class Method Details

.vivify(hash) ⇒ Object



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

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

Instance Method Details

#as_jsonObject



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

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