module Kungfuig
Constants
- LAMBDA
- MX
- VERSION
Public Class Methods
extended(base)
click to toggle source
# File lib/kungfuig.rb, line 121 def self.extended base base.include ClassMethods end
included(base)
click to toggle source
# File lib/kungfuig.rb, line 112 def self.included base base.include InstanceMethods base.extend ClassMethods if (base.instance_methods & [:[], :[]=]).empty? base.send :alias_method, :[], :option base.send :alias_method, :[]=, :option! end end
load_stuff(hos)
click to toggle source
rubocop:enable Style/MethodName
# File lib/kungfuig.rb, line 19 def load_stuff hos case hos when NilClass then Hashie::Mash.new # aka skip when Hash then Hashie::Mash.new(hos) when String begin File.exist?(hos) ? Hashie::Mash.load(hos) : Hashie::Mash.new(YAML.load(hos)) rescue ArgumentError raise ArgumentError, "#{__callee__} expects valid YAML configuration file. “#{hos.inspect}” contains invalid syntax." rescue Psych::SyntaxError raise ArgumentError, "#{__callee__} expects valid YAML configuration string. Got:\n#{hos.inspect}" rescue raise ArgumentError, "#{__callee__} expects valid YAML configuration string (misspelled file name?). Got:\n#{hos.inspect}" end when ->(h) { h.respond_to?(:to_h) } then Hashie::Mash.new(h.to_h) when ->(h) { h.respond_to?(:to_hash) } then Hashie::Mash.new(h.to_hash) else fail ArgumentError.new "#{__callee__} accepts either String or Hash as parameter." end end
✍(receiver: nil, method: nil, result: nil, args: nil, **params)
click to toggle source
rubocop:disable Style/MethodName
# File lib/kungfuig.rb, line 12 def ✍(receiver: nil, method: nil, result: nil, args: nil, **params) require 'logger' Logger.new($stdout).debug({receiver: receiver, method: method, result: result, args: args, **params}.inspect) end
Private Instance Methods
load_stuff(hos)
click to toggle source
rubocop:enable Style/MethodName
# File lib/kungfuig.rb, line 19 def load_stuff hos case hos when NilClass then Hashie::Mash.new # aka skip when Hash then Hashie::Mash.new(hos) when String begin File.exist?(hos) ? Hashie::Mash.load(hos) : Hashie::Mash.new(YAML.load(hos)) rescue ArgumentError raise ArgumentError, "#{__callee__} expects valid YAML configuration file. “#{hos.inspect}” contains invalid syntax." rescue Psych::SyntaxError raise ArgumentError, "#{__callee__} expects valid YAML configuration string. Got:\n#{hos.inspect}" rescue raise ArgumentError, "#{__callee__} expects valid YAML configuration string (misspelled file name?). Got:\n#{hos.inspect}" end when ->(h) { h.respond_to?(:to_h) } then Hashie::Mash.new(h.to_h) when ->(h) { h.respond_to?(:to_hash) } then Hashie::Mash.new(h.to_hash) else fail ArgumentError.new "#{__callee__} accepts either String or Hash as parameter." end end
✍(receiver: nil, method: nil, result: nil, args: nil, **params)
click to toggle source
rubocop:disable Style/MethodName
# File lib/kungfuig.rb, line 12 def ✍(receiver: nil, method: nil, result: nil, args: nil, **params) require 'logger' Logger.new($stdout).debug({receiver: receiver, method: method, result: result, args: args, **params}.inspect) end