Sha256: df32902e4028e6709b3dae4c791ad1a7768b502bc3b43c1e621c0d8444910f06

Contents?: true

Size: 912 Bytes

Versions: 5

Compression:

Stored size: 912 Bytes

Contents

require 'tessellator/fetcher'

class HowIs
  # This entire class is a monstrous hack, because GitHub doesn't provide a good
  # API for Pulse.
  class Pulse
    def initialize(repository)
      @repository = repository
      @pulse_page_response = fetch_pulse!(repository)
    end

    def text_summary
      raise NotImplementedError
    end

    def html_summary
      parts = 
        @pulse_page_response.body
          .split('<div class="section diffstat-summary">')

      if parts.length == 1
        return "There hasn't been any activity on #{@repository} in the last month."
      end

      parts
        .last
        .split('</div>').first
        .gsub('<a href="/', '<a href="https://github.com/')
        .strip
    end

  private
    def fetch_pulse!(repository, period='monthly')
      Tessellator::Fetcher.new.call('get', "https://github.com/#{repository}/pulse/#{period}")
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
how_is-17.0.0 lib/how_is/pulse.rb
how_is-16.0.0 lib/how_is/pulse.rb
how_is-15.0.0 lib/how_is/pulse.rb
how_is-14.0.0 lib/how_is/pulse.rb
how_is-13.0.0 lib/how_is/pulse.rb