class Metamatter::Repository

Attributes

name[RW]
owner[RW]

Public Class Methods

new(repo_with_owner) click to toggle source

Public: Initialize a new Repository from a GitHub repo with owner

repo_with_owner - e.g. arfon/metamatter

Returns a Repository.

# File lib/metamatter.rb, line 22
def initialize(repo_with_owner)
  @owner, @name = repo_with_owner.split('/')
end

Public Instance Methods

authors() click to toggle source

Public: Returns the full list of contributors to the repository sorted

by their contribution count

Returns authors hash.

# File lib/metamatter.rb, line 48
def authors
  Metamatter::Authors.new(self).list
end
doi() click to toggle source

Public: Returns any known DOIs for the repository

Returns a DOI string or nil

# File lib/metamatter.rb, line 69
def doi
  # Try README first
  if readme_doi = Metamatter::Readme.new(self).doi
    return readme_doi
  elsif datacite_doi = Metamatter::Datacite.new(self).doi
    return datacite_doi.first
  else
    return nil
  end
end
extract() click to toggle source

Public: Returns the full metadata for the repository

Returns metatdata hash.

# File lib/metamatter.rb, line 36
def extract
  return JSON.pretty_generate({ :repository => self.to_hash,
                                :authors => authors,
                                :tags => tags,
                                :license => license,
                                :doi => doi })
end
github_response() click to toggle source

Private: The GitHub Repository response

Returns a cached Octokit response hash

# File lib/metamatter.rb, line 83
def github_response
  @github_response ||= client.repository(name_with_owner)
end
license() click to toggle source

Public: Returns the license detected for the repository

Returns license hash or nil

# File lib/metamatter.rb, line 62
def license
  Metamatter::License.new(self).license
end
name_with_owner() click to toggle source

Public: Convenience method for returning the owner with name

Returns a string e.g. ‘arfon/metamatter’

# File lib/metamatter.rb, line 29
def name_with_owner
  [owner, name].join('/')
end
tags() click to toggle source

Public: Returns the tags from the Algorithmia classification

Returns list of tags or nil.

# File lib/metamatter.rb, line 55
def tags
  Metamatter::Classification.new(self).tags
end
to_hash() click to toggle source

Private: Returns a summary hash for the repository

Returns a hash

# File lib/metamatter.rb, line 90
def to_hash
  {
    :name => github_response.name,
    :location => github_response.html_url,
    :description => github_response.description,
    :created_at => github_response.created_at
  }
end