Module: Sanitize
- Defined in:
- lib/what_cd/sanitize.rb
Class Method Summary collapse
-
.run(path) ⇒ Object
Load from config file.
- .run_plugins(path, configured_plugins) ⇒ Object
Class Method Details
.run(path) ⇒ Object
Load from config file
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/what_cd/sanitize.rb', line 16 def self.run(path) # Load configured plugins begin # Get config config = YAML.load_file(WhatCD::CONFIG) # Get configured plugins configured_plugins = config['commands']['sanitize']['plugins'] # Run them self.run_plugins(path, configured_plugins) rescue Errno::ENOENT @log.error "Missing gem config file '~/.what_cd'" end end |
.run_plugins(path, configured_plugins) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/what_cd/sanitize.rb', line 31 def self.run_plugins(path, configured_plugins) @log.info "Sanitizing release located at #{path}" # Get this directory current_dir = File.dirname(__FILE__) # Set the context to be passed around between plugins context = {} context[:path] = path # Iterate over the configured plugins and dynamically execute them configured_plugins.each do |configured_plugin| file = "#{current_dir}/sanitize_plugins/#{configured_plugin}.rb" require file file_name = File.basename(file, '.rb') # using ActiveSupport for camelcase and constantize plugin = file_name.camelcase.constantize # Check to ensure ruby file defines a class if plugin.class == Class @log.info "Sanitizing with plugin #{plugin}" context = plugin.new.sanitize(context) @log.debug "Context returned as #{context}" end end @log.info "Sanitization finished. Sanitized release located at #{context[:path]}" end |