Class: Supermarket::SupermarketHelper
- Inherits:
-
Inspec::Targets::UrlHelper
- Object
- Inspec::Targets::UrlHelper
- Supermarket::SupermarketHelper
- Defined in:
- lib/bundles/inspec-supermarket/target.rb
Instance Method Summary collapse
- #build_target_url(target) ⇒ Object
-
#get_profile_name(uri) ⇒ Object
extracts profile name from url.
- #handles?(profile) ⇒ Boolean
-
#resolve(profile, opts = {}) ⇒ Object
generates proper url.
- #to_s ⇒ Object
Methods inherited from Inspec::Targets::UrlHelper
#download_archive, #resolve_archive
Instance Method Details
#build_target_url(target) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bundles/inspec-supermarket/target.rb', line 31 def build_target_url(target) # read details from json # extracts github url supermarket, slug = target.split('/') # search profile with slug # get github url # return github url "https://github.com/nathenharvey/tmp_compliance_profile/" end |
#get_profile_name(uri) ⇒ Object
extracts profile name from url
27 28 29 |
# File 'lib/bundles/inspec-supermarket/target.rb', line 27 def get_profile_name(uri) uri.host + uri.path end |
#handles?(profile) ⇒ Boolean
10 11 12 13 14 15 16 17 |
# File 'lib/bundles/inspec-supermarket/target.rb', line 10 def handles?(profile) # check for local scheme supermarket:// return unless URI(profile).scheme == 'supermarket' # emulate supermarket namespace profile == 'supermarket://nathenharvey/tmp-compliance-profile' rescue URI::Error => e false end |
#resolve(profile, opts = {}) ⇒ Object
generates proper url
20 21 22 23 24 |
# File 'lib/bundles/inspec-supermarket/target.rb', line 20 def resolve(profile, opts = {}) profile = get_profile_name(URI(target)) target = build_target_url(profile) super(target, opts) end |
#to_s ⇒ Object
43 44 45 |
# File 'lib/bundles/inspec-supermarket/target.rb', line 43 def to_s 'Chef Compliance Profile Loader' end |