Class: Bundler::Audit::Task

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/bundler/audit/task.rb

Overview

Defines the bundle:audit rake tasks.

Defined Under Namespace

Classes: CommandNotFound

Instance Method Summary collapse

Constructor Details

#initializeTask

Initializes the task.



15
16
17
# File 'lib/bundler/audit/task.rb', line 15

def initialize
  define
end

Instance Method Details

#bundler_audit(*arguments) ⇒ true

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

If the bundler-audit command exits with an error, the rake task will also exit with the same error code.

Runs the bundler-audit command with the additional arguments.

Parameters:

  • arguments (Array<String>)

    Additional command-line arguments for bundler-audit.

Returns:

  • (true)

    The bundler-audit command successfully exited.

Raises:

  • (CommandNotFound)

    The bundler-audit command could not be executed or was not found.



37
38
39
40
41
42
43
44
45
46
# File 'lib/bundler/audit/task.rb', line 37

def bundler_audit(*arguments)
  case system('bundler-audit',*arguments)
  when false
    exit $?.exitstatus || 1
  when nil
    raise(CommandNotFound,"bundler-audit could not be executed")
  else
    return true
  end
end

#checktrue

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

If the bundler-audit command exits with an error, the rake task will also exit with the same error code.

Runs the bundle-audit check command.

Returns:

  • (true)

    The bundler-audit command successfully exited.

Raises:

  • (CommandNotFound)

    The bundler-audit command could not be executed or was not found.



63
64
65
# File 'lib/bundler/audit/task.rb', line 63

def check
  bundler_audit 'check'
end

#defineObject (protected)

Defines the bundle:audit and bundle:audit:update task.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/bundler/audit/task.rb', line 91

def define
  namespace :bundle do
    namespace :audit do
      desc 'Checks the Gemfile.lock for insecure dependencies'
      task :check do
        check
      end

      desc 'Updates the bundler-audit vulnerability database'
      task :update do
        update
      end
    end

    task :audit => 'audit:check'
  end

  task 'bundler:audit'        => 'bundle:audit'
  task 'bundler:audit:check'  => 'bundle:audit:check'
  task 'bundler:audit:update' => 'bundle:audit:update'
end

#updatetrue

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

If the bundler-audit command exits with an error, the rake task will also exit with the same error code.

Runs the bundle-audit update command.

Returns:

  • (true)

    The bundler-audit command successfully exited.

Raises:

  • (CommandNotFound)

    The bundler-audit command could not be executed or was not found.



82
83
84
# File 'lib/bundler/audit/task.rb', line 82

def update
  bundler_audit 'update'
end