Class: Metamatter::Readme
- Inherits:
-
Object
- Object
- Metamatter::Readme
- Includes:
- Helpers
- Defined in:
- lib/metamatter/readme.rb
Constant Summary
Constants included from Helpers
Instance Attribute Summary collapse
-
#repository ⇒ Object
Returns the value of attribute repository.
Instance Method Summary collapse
- #contents ⇒ Object
-
#doi ⇒ Object
Find the Zenodo DOI if it’s there Returns a DOI URL 10.5281/zenodo.9789 or nil.
- #github_response ⇒ Object
- #has_zenodo_badge? ⇒ Boolean
-
#initialize(repository) ⇒ Readme
constructor
A new instance of Readme.
Methods included from Helpers
Constructor Details
#initialize(repository) ⇒ Readme
Returns a new instance of Readme.
9 10 11 |
# File 'lib/metamatter/readme.rb', line 9 def initialize(repository) @repository = repository end |
Instance Attribute Details
#repository ⇒ Object
Returns the value of attribute repository.
7 8 9 |
# File 'lib/metamatter/readme.rb', line 7 def repository @repository end |
Instance Method Details
#contents ⇒ Object
13 14 15 16 |
# File 'lib/metamatter/readme.rb', line 13 def contents contents = github_response return Base64.decode64(contents.content) end |
#doi ⇒ Object
Find the Zenodo DOI if it’s there Returns a DOI URL 10.5281/zenodo.9789 or nil
24 25 26 27 28 29 30 31 |
# File 'lib/metamatter/readme.rb', line 24 def doi if has_zenodo_badge? match = contents.match(/\d{2}.\d{4}\/zenodo.\d*/)[0] return match else return nil end end |
#github_response ⇒ Object
33 34 35 |
# File 'lib/metamatter/readme.rb', line 33 def github_response @github_response ||= client.readme(repository.name_with_owner) end |
#has_zenodo_badge? ⇒ Boolean
18 19 20 |
# File 'lib/metamatter/readme.rb', line 18 def has_zenodo_badge? contents.include?('zenodo.org/badge') end |