class Faf::Repo

Attributes

name[R]
owner[R]
pushed_at[R]

Public Class Methods

new(url, options = {}) click to toggle source
# File lib/faf/repo.rb, line 7
def initialize(url, options = {})
  @owner, @name = url.split('/', 2)
  @pushed_at = options[:pushed_at]
end

Public Instance Methods

fork_count() click to toggle source
# File lib/faf/repo.rb, line 16
def fork_count
  repository.fork_count
end
forks() click to toggle source
# File lib/faf/repo.rb, line 12
def forks
  @forks ||= Faf::Forks.new(self)
end
repository() click to toggle source
# File lib/faf/repo.rb, line 20
def repository
  data.repository
end
to_s() click to toggle source
# File lib/faf/repo.rb, line 28
def to_s
  "#{url} (#{pushed_at.ago_in_words})"
end
url() click to toggle source
# File lib/faf/repo.rb, line 24
def url
  "https://github.com/#{owner}/#{name}"
end

Private Instance Methods

data() click to toggle source
# File lib/faf/repo.rb, line 34
def data
  @data ||= get_data.data
end
get_data() click to toggle source
# File lib/faf/repo.rb, line 38
    def get_data
      query = <<-GRAPHQL
        query($owner: String!, $name: String!) {
          repository(owner: $owner, name: $name) {
            name
            forkCount
          }
        }
      GRAPHQL

      query_options = {
        owner: owner,
        name: name
      }

      Faf::Connection.query(query, query_options)
    end