module ECSBundler

Constants

VERSION

Contains version string

Public Class Methods

config() click to toggle source

Return config class

# File lib/ecs_bundler.rb, line 16
def config
  @@config ||= Config.new
end
rest_client(options = {}) click to toggle source

Return rest-client class

# File lib/ecs_bundler.rb, line 21
def rest_client(options = {})
  @@rest_client ||= RestClient.new(options)
end
run(options = {}) click to toggle source

Run application

# File lib/ecs_bundler.rb, line 46
def run(options = {})
  config.load(options[:config] ? options[:config] : nil)
  options = config.data.merge(options)
  validate_options!(options)
  rest_client(options)
  scan = Scan.create(BundlerScanner.run)
  if scan.id
    print "ecs-bundler successfully transferred scan to server: scanId => #{scan.id}\n"
  else
    print "ecs-bundler error transferring scan: #{scan.message}\n"
  end
end
run_cli() click to toggle source

Run cli application

# File lib/ecs_bundler.rb, line 26
def run_cli
  require 'cli'
  cli = ::CLI.new do
    version(ECSBundler::VERSION)
    option :apiKey, short: :k, description: 'api key'
    option :userName,       short: :u, description: 'user name'
    option :url, description: 'Base url'
    option :project, short: :p, description: 'Project name'
    option :config, short: :c, description: 'Config path'
  end
  settings = cli.parse
  print settings.help if settings.help
  print settings.version.gsub('"', '') if settings.version
  exit 0 if settings.help || settings.version
  run(settings.to_h.compact)
rescue CLI::ParsingError => pe
  cli.usage!(pe)
end

Private Class Methods

validate_options!(options) click to toggle source

validate options

# File lib/ecs_bundler.rb, line 62
def validate_options!(options)
  if !options[:userName] || !options[:apiKey]
    raise "Please provide a 'userName' and 'apiKey' property in credentials file('#{Config::FILE_NAME}')."
  end
  raise "Please provide a 'project' property in credentials file('#{Config::FILE_NAME}')." unless options[:project]
end