Class: Bundler::Advise::Advisories
- Inherits:
-
Object
- Object
- Bundler::Advise::Advisories
- Defined in:
- lib/bundler/advise/advisories.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Instance Method Summary collapse
- #clean_update! ⇒ Object
- #dir_missing_or_empty ⇒ Object
- #gem_advisories_for(gem_name) ⇒ Object
-
#initialize(dir: File.expand_path('~/.ruby-advisory-db'), repo: 'https://github.com/rubysec/ruby-advisory-db.git') ⇒ Advisories
constructor
A new instance of Advisories.
- #update ⇒ Object
Constructor Details
#initialize(dir: File.expand_path('~/.ruby-advisory-db'), repo: 'https://github.com/rubysec/ruby-advisory-db.git') ⇒ Advisories
Returns a new instance of Advisories.
7 8 9 10 11 |
# File 'lib/bundler/advise/advisories.rb', line 7 def initialize(dir: File.('~/.ruby-advisory-db'), repo: 'https://github.com/rubysec/ruby-advisory-db.git') @dir = dir @repo = repo end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
5 6 7 |
# File 'lib/bundler/advise/advisories.rb', line 5 def dir @dir end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
5 6 7 |
# File 'lib/bundler/advise/advisories.rb', line 5 def repo @repo end |
Instance Method Details
#clean_update! ⇒ Object
26 27 28 29 |
# File 'lib/bundler/advise/advisories.rb', line 26 def clean_update! FileUtils.rmtree @dir update end |
#dir_missing_or_empty ⇒ Object
22 23 24 |
# File 'lib/bundler/advise/advisories.rb', line 22 def dir_missing_or_empty !File.exist?(@dir) || Dir.empty?(@dir) end |
#gem_advisories_for(gem_name) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/bundler/advise/advisories.rb', line 31 def gem_advisories_for(gem_name) # Sorting the results isn't strictly needed but provides deterministic # results for testing. Dir[File.join(@dir, 'gems', gem_name, '*.yml')].sort.map do |ad_yml| Advisory.from_yml(ad_yml) end end |
#update ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/bundler/advise/advisories.rb', line 13 def update dir_missing_or_empty ? clone : pull rescue ArgumentError => e # git gem is dorky in this case, putting the path into the backtrace. msg = "Unexpected problem with working dir for advisories: #{e.} #{e.backtrace}.\n" + "Call clean_update! to remove #{@dir} and re-clone it." raise RuntimeError, msg end |