Class: Legendary::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/legendary/repository.rb

Constant Summary collapse

DB_REPO =
'https://github.com/rubysec/ruby-advisory-db'

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pathObject

Returns the value of attribute path.



5
6
7
# File 'lib/legendary/repository.rb', line 5

def path
  @path
end

Instance Method Details

#cloneObject



15
16
17
# File 'lib/legendary/repository.rb', line 15

def clone
  Git.clone(DB_REPO, path)
end

#clone_or_updateObject



24
25
26
# File 'lib/legendary/repository.rb', line 24

def clone_or_update
  repo_exists? ? pull : clone
end

#pullObject



19
20
21
22
# File 'lib/legendary/repository.rb', line 19

def pull
  repo = Git.open(path)
  repo.pull
end

#repo_exists?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/legendary/repository.rb', line 11

def repo_exists?
  File.directory?(File.join(path, '/.git/'))
end