Class: InspecPlugins::Init::CLI
- Inherits:
-
Object
- Object
- InspecPlugins::Init::CLI
- Defined in:
- lib/plugins/inspec-init/lib/inspec-init/cli.rb
Class Method Summary collapse
-
.valid_profile_platforms ⇒ Object
——————————————————————-# inspec init profile ——————————————————————-#.
Instance Method Summary collapse
Class Method Details
.valid_profile_platforms ⇒ Object
——————————————————————-#
inspec init profile
——————————————————————-#
14 15 16 17 18 |
# File 'lib/plugins/inspec-init/lib/inspec-init/cli.rb', line 14 def self.valid_profile_platforms # Look in the 'template/profiles' directory and detect which platforms are available. profile_templates_dir = File.join(File.dirname(__FILE__), 'templates', 'profiles') Dir.glob(File.join(profile_templates_dir, '*')).select { |p| File.directory?(p) }.map { |d| File.basename(d) } end |
Instance Method Details
#profile(new_profile_name) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/plugins/inspec-init/lib/inspec-init/cli.rb', line 31 def profile(new_profile_name) unless valid_profile_platforms.include?([:platform]) puts "Unable to generate profile: No template available for platform '#{[:platform]}' (expected one of: #{valid_profile_platforms.join(', ')})" exit 1 end template_path = File.join('profiles', [:platform]) renderer = InspecPlugins::Init::Renderer.new(self, ) renderer.render_with_values(template_path, name: new_profile_name) end |