diff --git a/lib/bundler/audit/database.rb b/lib/bundler/audit/database.rb index a1a378f9..0a7b60e1 100644 --- a/lib/bundler/audit/database.rb +++ b/lib/bundler/audit/database.rb @@ -92,13 +92,10 @@ def self.exists?(path=DEFAULT_PATH) # # Downloads the ruby-advisory-db. # - # @param [Hash] options - # Additional options. - # - # @option options [String] :path (DEFAULT_PATH) + # @param [String] path # The destination path for the new ruby-advisory-db. # - # @option options [Boolean] :quiet + # @param [Boolean] quiet # Specify whether `git` should be `--quiet`. # # @return [Dataase] @@ -112,15 +109,9 @@ def self.exists?(path=DEFAULT_PATH) # # @since 0.8.0 # - def self.download(options={}) - unless (options.keys - [:path, :quiet]).empty? - raise(ArgumentError,"Invalid option(s)") - end - - path = options.fetch(:path,DEFAULT_PATH) - + def self.download(path: DEFAULT_PATH, quiet: false) command = %w[git clone] - command << '--quiet' if options[:quiet] + command << '--quiet' if quiet command << URL << path unless system(*command) @@ -133,19 +124,16 @@ def self.download(options={}) # # Updates the ruby-advisory-db. # - # @param [Hash] options - # Additional options. + # @param [Hash{Symbol => Object}] kwargs + # Additional optional keyword arguments for {download} or {#update!}. # - # @option options [Boolean] :quiet + # @option kwargs [Boolean] :quiet # Specify whether `git` should be `--quiet`. # # @return [Boolean, nil] # Specifies whether the update was successful. # A `nil` indicates no update was performed. # - # @raise [ArgumentError] - # Invalid options were given. - # # @note # Requires network access. # @@ -153,17 +141,15 @@ def self.download(options={}) # # @deprecated Use {#update!} instead. # - def self.update!(options={}) - raise "Invalid option(s)" unless (options.keys - [:quiet]).empty? - + def self.update!(**kwargs) if File.directory?(DEFAULT_PATH) begin - new(DEFAULT_PATH).update!(options) + new(DEFAULT_PATH).update!(**kwargs) rescue UpdateFailed then false end else begin - download(options.merge(path: DEFAULT_PATH)) + download(**kwargs, path: DEFAULT_PATH) rescue DownloadFailed then false end end @@ -183,10 +169,7 @@ def git? # # Updates the ruby-advisory-db. # - # @param [Hash] options - # Additional options. - # - # @option options [Boolean] :quiet + # @param [Boolean] quiet # Specify whether `git` should be `--quiet`. # # @return [true, nil] @@ -196,11 +179,11 @@ def git? # # @since 0.8.0 # - def update!(options={}) + def update!(quiet: false) if git? Dir.chdir(@path) do command = %w[git pull] - command << '--quiet' if options[:quiet] + command << '--quiet' if quiet command << 'origin' << 'master' unless system(*command) diff --git a/spec/database_spec.rb b/spec/database_spec.rb index 97d89ce1..4b203835 100644 --- a/spec/database_spec.rb +++ b/spec/database_spec.rb @@ -156,12 +156,6 @@ end end end - - context "when given an invalid option" do - it do - expect { subject.update!(foo: 1) }.to raise_error(RuntimeError) - end - end end describe "#initialize" do