Module: Dependagrab

Defined in:
lib/dependagrab.rb,
lib/dependagrab/cli.rb,
lib/dependagrab/gh_api.rb,
lib/dependagrab/version.rb,
lib/dependagrab/file_writer.rb,
lib/dependagrab/github_client.rb,
lib/dependagrab/console_writer.rb

Defined Under Namespace

Modules: GHAPI Classes: CLI, ConsoleWriter, Error, FileWriter, GhApiError, GithubClient, MissingConfigError

Constant Summary collapse

VERSION =
"0.1.7"

Class Method Summary collapse

Class Method Details

.run(options) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dependagrab.rb', line 13

def self.run(options)
  result = Dependagrab::GithubClient.new(options).grab

  if options[:output]
    begin
      output_file = FileWriter.new(options[:output]).write!(result[:alerts])
      if options[:print]
        puts "#{result[:alerts].count} dependency warnings written to '#{options.fetch(:output)}'"
      end
      output_file
    rescue => e
      STDERR.puts "Failed to write file '#{options.fetch(:output)}'"
      STDERR.puts "Error: #{e.message} (set DEBUG=true for detailed backtrace)"
      STDERR.puts e.backtrace if ENV['DEBUG']
      exit 1
    end
  else
    if options[:print]
      ConsoleWriter.new.write!(result[:alerts])
    else
      result[:alerts]
    end
  end
end