Module: ZendeskAppsSupport::Validations::Manifest

Defined in:
lib/zendesk_apps_support/validations/manifest.rb

Constant Summary collapse

RUBY_TO_JSON =
ZendeskAppsSupport::Manifest::RUBY_TO_JSON
REQUIRED_MANIFEST_FIELDS =
RUBY_TO_JSON.select { |k| %i[author default_locale].include? k }.freeze
OAUTH_REQUIRED_FIELDS =
%w[client_id client_secret authorize_uri access_token_uri].freeze
PARAMETER_TYPES =
ZendeskAppsSupport::Manifest::Parameter::TYPES

Class Method Summary collapse

Class Method Details

.call(package) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/zendesk_apps_support/validations/manifest.rb', line 15

def call(package)
  unless package.has_file?('manifest.json')
    nested_manifest = package.files.find { |file| file =~ %r{\A[^/]+?/manifest\.json\Z} }
    if nested_manifest
      return [ValidationError.new(:nested_manifest, found_path: nested_manifest.relative_path)]
    end
    return [ValidationError.new(:missing_manifest)]
  end

  collate_manifest_errors(package)
rescue JSON::ParserError => e
  return [ValidationError.new(:manifest_not_json, errors: e)]
rescue ZendeskAppsSupport::Manifest::OverrideError => e
  return [ValidationError.new(:duplicate_manifest_keys, errors: e.message)]
end