Class: Metamatter::Repository
- Inherits:
-
Object
- Object
- Metamatter::Repository
- Includes:
- Helpers
- Defined in:
- lib/metamatter.rb
Constant Summary
Constants included from Helpers
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#owner ⇒ Object
Returns the value of attribute owner.
Instance Method Summary collapse
-
#authors ⇒ Object
Public: Returns the full list of contributors to the repository sorted by their contribution count.
-
#doi ⇒ Object
Public: Returns any known DOIs for the repository.
-
#extract ⇒ Object
Public: Returns the full metadata for the repository.
-
#github_response ⇒ Object
Private: The GitHub Repository response.
-
#initialize(repo_with_owner) ⇒ Repository
constructor
Public: Initialize a new Repository from a GitHub repo with owner.
-
#license ⇒ Object
Public: Returns the license detected for the repository.
-
#name_with_owner ⇒ Object
Public: Convenience method for returning the owner with name.
-
#tags ⇒ Object
Public: Returns the tags from the Algorithmia classification.
-
#to_hash ⇒ Object
Private: Returns a summary hash for the repository.
Methods included from Helpers
Constructor Details
#initialize(repo_with_owner) ⇒ Repository
Public: Initialize a new Repository from a GitHub repo with owner
repo_with_owner - e.g. arfon/metamatter
Returns a Repository.
22 23 24 |
# File 'lib/metamatter.rb', line 22 def initialize(repo_with_owner) @owner, @name = repo_with_owner.split('/') end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/metamatter.rb', line 15 def name @name end |
#owner ⇒ Object
Returns the value of attribute owner.
14 15 16 |
# File 'lib/metamatter.rb', line 14 def owner @owner end |
Instance Method Details
#authors ⇒ Object
Public: Returns the full list of contributors to the repository sorted
by their contribution count
Returns authors hash.
48 49 50 |
# File 'lib/metamatter.rb', line 48 def Metamatter::Authors.new(self).list end |
#doi ⇒ Object
Public: Returns any known DOIs for the repository
Returns a DOI string or nil
69 70 71 72 73 74 75 76 77 78 |
# 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 ⇒ Object
Public: Returns the full metadata for the repository
Returns metatdata hash.
36 37 38 39 40 41 42 |
# File 'lib/metamatter.rb', line 36 def extract return JSON.pretty_generate({ :repository => self.to_hash, :authors => , :tags => , :license => license, :doi => doi }) end |
#github_response ⇒ Object
Private: The GitHub Repository response
Returns a cached Octokit response hash
83 84 85 |
# File 'lib/metamatter.rb', line 83 def github_response @github_response ||= client.repository(name_with_owner) end |
#license ⇒ Object
Public: Returns the license detected for the repository
Returns license hash or nil
62 63 64 |
# File 'lib/metamatter.rb', line 62 def license Metamatter::License.new(self).license end |
#name_with_owner ⇒ Object
Public: Convenience method for returning the owner with name
Returns a string e.g. ‘arfon/metamatter’
29 30 31 |
# File 'lib/metamatter.rb', line 29 def name_with_owner [owner, name].join('/') end |
#tags ⇒ Object
Public: Returns the tags from the Algorithmia classification
Returns list of tags or nil.
55 56 57 |
# File 'lib/metamatter.rb', line 55 def Metamatter::Classification.new(self). end |
#to_hash ⇒ Object
Private: Returns a summary hash for the repository
Returns a hash
90 91 92 93 94 95 96 97 |
# 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 |