Sha256: fbdc8c27c3097844e4cb85e7047c204e39a26c479a25d77b1b5469ebc8940afa
Contents?: true
Size: 1 KB
Versions: 19
Compression:
Stored size: 1 KB
Contents
module Wordmove class Guardian attr_reader :movefile, :environment, :action, :logger def initialize(options: nil, action: nil) @movefile = Wordmove::Movefile.new(options[:config]) @environment = @movefile.environment(options).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.fetch(false)[environment] return {} unless environment_options.key?(:forbid) return {} unless environment_options[:forbid].key?(action) environment_options[:forbid][action] end end end
Version data entries
19 entries across 19 versions & 1 rubygems