Module: PuppetComply::Check
- Defined in:
- lib/puppet_comply/check.rb
Class Method Summary collapse
- .download_forge_module(forge_module) ⇒ Object
- .execute_rspec(module_path) ⇒ Object
- .module_path(forge_module) ⇒ Object
- .run(forge_module:) ⇒ Object
Class Method Details
.download_forge_module(forge_module) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/puppet_comply/check.rb', line 22 def self.download_forge_module(forge_module) modules_dir = File.join(Dir.pwd, 'modules') if File.exist?(modules_dir) FileUtils.rm_rf(modules_dir) end Dir.mkdir(modules_dir) system("bundle exec puppet module install #{forge_module} --target-dir #{modules_dir}") end |
.execute_rspec(module_path) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/puppet_comply/check.rb', line 36 def self.execute_rspec(module_path) Dir.chdir(module_path) do Bundler.with_clean_env do system('bundle install && bundle exec rake spec_prep') if File.directory?('spec/fixtures/modules') Dir.chdir('spec/fixtures/modules') do Dir.glob('../../../../*').each do |path| next if ['.', '..'].include?(path) next if File.exist?(File.basename(path)) puts "symlinking #{path} to #{File.basename(path)}" FileUtils.ln_s(path, File.basename(path)) end end else raise 'oh no' end system('bundle exec rake spec') end end end |
.module_path(forge_module) ⇒ Object
32 33 34 |
# File 'lib/puppet_comply/check.rb', line 32 def self.module_path(forge_module) File.join(Dir.pwd, 'modules', forge_module.split(/[\/-]/, 2).last) end |
.run(forge_module:) ⇒ Object
17 18 19 20 |
# File 'lib/puppet_comply/check.rb', line 17 def self.run(forge_module:) self.download_forge_module(forge_module) self.execute_rspec(self.module_path(forge_module)) end |