Sha256: 293b3a98fdc2b1d2c8dfc3cfa8c8c1c572c0f947bf5a990530d6311b19818dfb

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

module Fasterer
  module Github
    class OutputComposer
      def initialize(owner, repo)
        @repo_owner = owner
        @repo_name = repo
      end

      def add_offences(offences, path)
        offences.each do |offence_name, lines|
          details = { path: path, lines: lines }
          (fasterer_offences[offence_name] ||= []) << details
        end
      end

      def add_errors(path)
        errors << { path: path }
      end

      def add_api_errors(new_api_errors)
        new_api_errors.each { |e| api_errors << e }
      end

      def result
        {
          repo_owner: repo_owner,
          repo_name: repo_name,
          fasterer_offences: fasterer_offences,
          errors: errors,
          api_errors: api_errors
        }
      end

      private

      attr_accessor :repo_owner, :repo_name

      def fasterer_offences
        @fasterer_offenses ||= {}
      end

      def errors
        @errors ||= []
      end

      def api_errors
        @api_errors ||= []
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fasterer-github-0.1.1 lib/fasterer/github/output_composer.rb
fasterer-github-0.1.0 lib/fasterer/github/output_composer.rb