Class: Supermarket::SupermarketCLI

Inherits:
Inspec::BaseCLI show all
Defined in:
lib/bundles/inspec-supermarket/cli.rb

Instance Method Summary collapse

Methods inherited from Inspec::BaseCLI

target_options

Instance Method Details

#exec(*tests) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/bundles/inspec-supermarket/cli.rb', line 26

def exec(*tests)
  # iterate over tests and add compliance scheme
  tests = tests.map { |t| 'supermarket://' + t }

  # execute profile from inspec exec implementation
  diagnose
  run_tests(opts, tests)
end

#info(profile) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/bundles/inspec-supermarket/cli.rb', line 36

def info(profile)
  info = Supermarket::API.info(profile)

  puts "#{mark_text('name: ')}  #{info['slug']}"
  puts "#{mark_text('owner:')}  #{info['owner']}"
  puts "#{mark_text('url:  ')}  #{info['source_url']}"
  puts
  puts "#{mark_text('description:  ')} #{info['description']}"
end

#profilesObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/bundles/inspec-supermarket/cli.rb', line 10

def profiles
  # display profiles in format user/profile
  supermarket_profiles = Supermarket::API.profiles

  headline('Available profiles:')
  supermarket_profiles.each { |p|
    m = %r{^#{Supermarket::API.supermarket_url}/api/v1/tools/(?<slug>[\w-]+)(/)?$}.match(p['tool'])
    li("#{p['tool_owner']}/#{m[:slug]}")
  }
end