Class: Legendary::Repository
- Inherits:
-
Object
- Object
- Legendary::Repository
- Defined in:
- lib/legendary/repository.rb
Constant Summary collapse
- DB_REPO =
'https://github.com/rubysec/ruby-advisory-db'
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #clone ⇒ Object
- #clone_or_update ⇒ Object
-
#initialize(path = nil) ⇒ Repository
constructor
A new instance of Repository.
- #pull ⇒ Object
- #repo_exists? ⇒ Boolean
Constructor Details
#initialize(path = nil) ⇒ Repository
Returns a new instance of Repository.
7 8 9 |
# File 'lib/legendary/repository.rb', line 7 def initialize(path=nil) @path = path || '/tmp/.legendary-repo' end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/legendary/repository.rb', line 5 def path @path end |
Instance Method Details
#clone ⇒ Object
15 16 17 |
# File 'lib/legendary/repository.rb', line 15 def clone Git.clone(DB_REPO, path) end |
#clone_or_update ⇒ Object
24 25 26 |
# File 'lib/legendary/repository.rb', line 24 def clone_or_update repo_exists? ? pull : clone end |
#pull ⇒ Object
19 20 21 22 |
# File 'lib/legendary/repository.rb', line 19 def pull repo = Git.open(path) repo.pull end |
#repo_exists? ⇒ Boolean
11 12 13 |
# File 'lib/legendary/repository.rb', line 11 def repo_exists? File.directory?(File.join(path, '/.git/')) end |