Class: Bundler::Audit::CLI
- Inherits:
-
Thor
- Object
- Thor
- Bundler::Audit::CLI
- Defined in:
- lib/bundler/audit/cli.rb
Constant Summary collapse
- DEFAULT_PRESENTER =
'plain'
- Error =
Class.new(RuntimeError)
- PresenterUnkown =
Class.new(Error)
- PresenterInvalid =
Class.new(Error)
Instance Method Summary collapse
- #check ⇒ Object
- #presenter_klass(presenter_string) ⇒ Object protected
- #say(message = "", color = nil) ⇒ Object protected
- #update ⇒ Object
- #version ⇒ Object
Instance Method Details
#check ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/bundler/audit/cli.rb', line 45 def check update if [:update] scanner = Scanner.new presenter = presenter_klass([:format]).new(self.shell, ) scanner.scan(:ignore => .ignore) do |result| case result when Scanner::InsecureSource presenter.push_warning "Insecure Source URI found: #{result.source}" when Scanner::UnpatchedGem presenter.push_advisory result end end presenter.print_report exit presenter.exit_code rescue Error => e say e., :red exit 1 end |
#presenter_klass(presenter_string) ⇒ Object (protected)
103 104 105 106 107 108 109 110 |
# File 'lib/bundler/audit/cli.rb', line 103 def presenter_klass(presenter_string) presenter_name = presenter_string.capitalize.to_sym raise PresenterUnkown, "Unknown Presenter '#{presenter_name}'" unless Presenter.const_defined? presenter_name Presenter.const_get presenter_name rescue NameError raise PresenterInvalid, "Invalid Presenter Name '#{presenter_name}'" end |
#say(message = "", color = nil) ⇒ Object (protected)
98 99 100 101 |
# File 'lib/bundler/audit/cli.rb', line 98 def say(="", color=nil) color = nil unless $stdout.tty? super(.to_s, color) end |
#update ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/bundler/audit/cli.rb', line 71 def update say("Updating ruby-advisory-db ...") unless .quiet? case Database.update!(quiet: .quiet?) when true say("Updated ruby-advisory-db", :green) unless .quiet? when false say "Failed updating ruby-advisory-db!", :red exit 1 when nil say "Skipping update", :yellow end unless .quiet? puts("ruby-advisory-db: #{Database.new.size} advisories") end end |