class Conjur::Policy::YAML::Handler
Attributes
filename[RW]
parser[RW]
result[RW]
Public Class Methods
new()
click to toggle source
# File lib/conjur/policy/yaml/handler.rb, line 305 def initialize @root = Root.new self @handlers = [ @root ] @anchors = {} @filename = "<no-filename>" end
Public Instance Methods
alias(key)
click to toggle source
# File lib/conjur/policy/yaml/handler.rb, line 344 def alias key log {"#{indent}WARNING: anchor '#{key}' is not defined"} unless anchor(key) log {"#{indent}anchor '#{key}'=#{anchor(key)}"} handler.alias key end
anchor(*args)
click to toggle source
Get or set an anchor. Invoke with just the anchor name to get the value. Invoke with the anchor name and value to set the value.
# File lib/conjur/policy/yaml/handler.rb, line 328 def anchor *args key, value, _ = args if _ raise ArgumentError, "Expecting 1 or 2 arguments, got #{args.length}" elsif key && value raise "Duplicate anchor #{key}" if @anchors[key] @anchors[key] = value elsif key @anchors[key] else nil end end
end_mapping()
click to toggle source
# File lib/conjur/policy/yaml/handler.rb, line 368 def end_mapping log {"#{indent}end mapping"} handler.end_mapping end
end_sequence()
click to toggle source
# File lib/conjur/policy/yaml/handler.rb, line 363 def end_sequence log {"#{indent}end sequence"} handler.end_sequence end
handler()
click to toggle source
# File lib/conjur/policy/yaml/handler.rb, line 342 def handler; @handlers.last; end
indent()
click to toggle source
# File lib/conjur/policy/yaml/handler.rb, line 386 def indent " " * [ @handlers.length - 1, 0 ].max end
log() { || ... }
click to toggle source
# File lib/conjur/policy/yaml/handler.rb, line 380 def log &block logger.debug('conjur/policy/handler') { yield } end
pop_handler()
click to toggle source
# File lib/conjur/policy/yaml/handler.rb, line 321 def pop_handler @handlers.pop log {"#{indent}popped to handler #{handler.class}"} end
push_handler(handler)
click to toggle source
# File lib/conjur/policy/yaml/handler.rb, line 316 def push_handler handler @handlers.push handler log {"#{indent}pushed handler #{handler.class}"} end
scalar(*args)
click to toggle source
# File lib/conjur/policy/yaml/handler.rb, line 373 def scalar *args # value, anchor, tag, plain, quoted, style value, anchor, tag, _, quoted = args log {"#{indent}got scalar #{tag ? tag + '=' : ''}#{value}#{anchor ? '#' + anchor : ''}"} handler.scalar value, tag, quoted, anchor end
start_mapping(*args)
click to toggle source
# File lib/conjur/policy/yaml/handler.rb, line 350 def start_mapping *args log {"#{indent}start mapping #{args}"} anchor, tag, _ = args tag = "!automatic-role" if %w(!managed-role !managed_role).include?(tag) handler.start_mapping tag, anchor end
start_sequence(*args)
click to toggle source
# File lib/conjur/policy/yaml/handler.rb, line 357 def start_sequence *args log {"#{indent}start sequence : #{args}"} anchor, _ = args handler.start_sequence anchor end