Sha256: 12505edee5be39d99f5241f1a6ec5019425f88d33ddcafcfcac7048f36ec1a66

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

module Fasterer
  module Github
    class OutputComposer

      CONFIG_FILE_NAME = '.fasterer.yml'
      SPEEDUPS_KEY     = 'speedups'

      def initialize(owner, repo, ignored_offences)
        @repo_owner = owner
        @repo_name = repo
        @ignored_offences = ignored_offences
      end

      def add_offences(offences, path)
        offences.each do |offence_name, lines|
          details = { path: path, lines: lines }
          next if ignored_offences.include?(offence_name)
          (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, :ignored_offences

      def fasterer_offences
        @fasterer_offenses ||= {}
      end

      def errors
        @errors ||= []
      end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fasterer-github-0.2.3 lib/fasterer/github/output_composer.rb
fasterer-github-0.2.2 lib/fasterer/github/output_composer.rb
fasterer-github-0.2.1 lib/fasterer/github/output_composer.rb
fasterer-github-0.2.0 lib/fasterer/github/output_composer.rb