Module: Kungfuig
- Defined in:
- lib/kungfuig.rb,
lib/kungfuig/jobber.rb,
lib/kungfuig/version.rb,
lib/kungfuig/aspector.rb,
lib/kungfuig/prepender.rb
Defined Under Namespace
Modules: Aspector, ClassMethods, InstanceMethods, I★I, Worker Classes: Jobber, JobberError, Prepender
Constant Summary collapse
- MX =
Mutex.new
- VERSION =
'0.11.4'.freeze
- LAMBDA =
lambda do |λ, e, **hash| begin Kungfuig::Prepender.error! e, **hash λ[:on_error].call(e, **hash) if λ[:on_error] rescue => e Kungfuig::Prepender.error! e, reason: :on_error end end
Class Method Summary collapse
- .extended(base) ⇒ Object
- .included(base) ⇒ Object
-
.load_stuff(hos) ⇒ Object
rubocop:enable Style/MethodName.
-
.✍(receiver: nil, method: nil, result: nil, args: nil, **params) ⇒ Object
rubocop:disable Style/MethodName.
Class Method Details
.extended(base) ⇒ Object
121 122 123 |
# File 'lib/kungfuig.rb', line 121 def self.extended base base.include ClassMethods end |
.included(base) ⇒ Object
112 113 114 115 116 117 118 119 |
# 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) ⇒ Object
rubocop:enable Style/MethodName
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# 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) ⇒ Object
rubocop:disable Style/MethodName
12 13 14 15 |
# 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 |