Sha256: c1e610f668dd86ee65613ee4a77ecfbbcc9e7f7a4ff1f1bed5cb0979b7c071dd
Contents?: true
Size: 1 KB
Versions: 8
Compression:
Stored size: 1 KB
Contents
module Wordmove class Guardian attr_reader :movefile, :environment, :action, :logger def initialize(cli_options: nil, action: nil) @movefile = Wordmove::Movefile.new(cli_options, nil, false) @environment = @movefile.environment.to_sym @action = action @logger = Logger.new($stdout).tap { |l| l.level = Logger::DEBUG } end def allows(task) if forbidden?(task) logger.task("#{action.capitalize}ing #{task.capitalize}") logger.warn("You tried to #{action} #{task}, but is forbidden by configuration. Skipping") end !forbidden?(task) end private def forbidden?(task) return false unless forbidden_tasks[task].present? forbidden_tasks[task] == true end def forbidden_tasks environment_options = movefile.options[environment] return {} unless environment_options.key?(:forbid) return {} unless environment_options[:forbid].key?(action) environment_options[:forbid][action] end end end
Version data entries
8 entries across 8 versions & 1 rubygems