Sha256: e97634220500d3fe7465b80a894548f50c23eeb9fbc7592f642d808348be5401

Contents?: true

Size: 1.07 KB

Versions: 43

Compression:

Stored size: 1.07 KB

Contents

module Marty::Diagnostic; class Controller < ActionController::Base
  def self.inherited(klass)
    namespace = klass.name.deconstantize.split('::')[0] rescue ''
    Reporter.namespaces.unshift(namespace)
    super
  end

  def op
    begin
      @result = Reporter.run(request)
    rescue NameError
      render file: 'public/400', formats: [:html], status: 400, layout: false
    else
      respond_to do |format|
        format.html {@result = display_parameters}
        format.json {render json: process_result_for_api}
      end
    end
  end

  def process_result_for_api
    @result.delete('data') unless request.params['data'] == 'true'
    @result.delete('errors') if @result['errors'] && @result['errors'].empty?
    @result
  end

  def display_parameters
    local  = params[:scope] == 'local'
    data   = local ? @result : @result['data']
    errors = local ? Reporter.errors(data) : @result['errors']
    {
      'display' => Reporter.displays(data),
      'errors' => errors
    }
  end

  def self.add_report name, diagnostics
    Reporter.reports[name] = diagnostics
  end
end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
marty-2.5.2 app/controllers/marty/diagnostic/controller.rb
marty-2.5.1 app/controllers/marty/diagnostic/controller.rb
marty-2.5.0 app/controllers/marty/diagnostic/controller.rb
marty-2.4.9 app/controllers/marty/diagnostic/controller.rb
marty-2.4.8 app/controllers/marty/diagnostic/controller.rb
marty-2.4.7 app/controllers/marty/diagnostic/controller.rb
marty-2.4.6 app/controllers/marty/diagnostic/controller.rb
marty-2.4.5 app/controllers/marty/diagnostic/controller.rb
marty-2.4.4 app/controllers/marty/diagnostic/controller.rb
marty-2.4.3 app/controllers/marty/diagnostic/controller.rb
marty-2.4.2 app/controllers/marty/diagnostic/controller.rb
marty-2.4.1 app/controllers/marty/diagnostic/controller.rb
marty-2.4.0 app/controllers/marty/diagnostic/controller.rb
marty-2.3.15 app/controllers/marty/diagnostic/controller.rb
marty-2.3.14 app/controllers/marty/diagnostic/controller.rb
marty-2.3.13 app/controllers/marty/diagnostic/controller.rb
marty-2.3.12 app/controllers/marty/diagnostic/controller.rb
marty-2.3.11 app/controllers/marty/diagnostic/controller.rb
marty-2.3.10 app/controllers/marty/diagnostic/controller.rb
marty-2.3.9 app/controllers/marty/diagnostic/controller.rb