Class: Bundler::Audit::Task

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ Task

Returns a new instance of Task.



15
16
17
18
19
20
21
# File 'lib/bundler/audit/task.rb', line 15

def initialize(*args, &block)
  @options = args || []
  @block = block if block
  @verbose = false

  define
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



11
12
13
# File 'lib/bundler/audit/task.rb', line 11

def block
  @block
end

#ignoreObject

Returns the value of attribute ignore.



13
14
15
# File 'lib/bundler/audit/task.rb', line 13

def ignore
  @ignore
end

#nameObject

Returns the value of attribute name.



9
10
11
# File 'lib/bundler/audit/task.rb', line 9

def name
  @name
end

#optionsObject

Returns the value of attribute options.



10
11
12
# File 'lib/bundler/audit/task.rb', line 10

def options
  @options
end

#verboseObject

Returns the value of attribute verbose.



12
13
14
# File 'lib/bundler/audit/task.rb', line 12

def verbose
  @verbose
end

Instance Method Details

#defineObject (protected)



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bundler/audit/task.rb', line 24

def define
  desc "Run Bundler-audit" unless ::Rake.application.last_comment
  @name = options.shift || :audit

  task @name, *options do |_, task_args|
    RakeFileUtils.send(:verbose, @verbose) do
      block.call(self) if block
      run
    end
  end
end

#runObject (protected)



36
37
38
39
40
41
# File 'lib/bundler/audit/task.rb', line 36

def run
  t = ['check']
  t << '-v' if verbose
  t << '-i' << ignore if ignore
  Bundler::Audit::CLI.start t
end