Sha256: 31188e9cf50511865eeed3c00c858f514cd1d996a3a617d7c921fe8cea7ad1d7

Contents?: true

Size: 881 Bytes

Versions: 2

Compression:

Stored size: 881 Bytes

Contents

module HubLink
  module Api
    class Review < SimpleDelegator
      EXPORT_COLUMNS = %i(
        id
        pull_request_id
        submitted_at
        reviewer
        reply?
        state
        html_url
        body
        review_comments_count
      )

      def reviewer
        user&.login
      end

      def reply?
        reviewer == submitter
      end

      def submitted_at
        if submitted?
          super
        end
      end

      def review_comments_count
        review_comments.size
      end

      def to_h
        Slicer.new(self, columns: EXPORT_COLUMNS).to_h
      end

      private

        def review_comments
          @_review_comments ||= Octokit.pull_request_review_comments(repo, number, id)
        end

        def submitted?
          !draft?
        end

        def draft?
          state == "PENDING"
        end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hub_link-0.19.0 lib/hub_link/api/review.rb
hub_link-0.18.0 lib/hub_link/api/review.rb