Module: Kungfuig

Defined in:
lib/kungfuig.rb,
lib/kungfuig/color.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: Color, Jobber, JobberError, Prepender

Constant Summary collapse

MX =
Mutex.new
VERSION =
"0.8.0"
LAMBDA =
lambda do |

Class Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



125
126
127
# File 'lib/kungfuig.rb', line 125

def self.extended base
  base.include ClassMethods
end

.included(base) ⇒ Object



116
117
118
119
120
121
122
123
# File 'lib/kungfuig.rb', line 116

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



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/kungfuig.rb', line 24

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_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



13
14
15
16
17
18
19
20
# File 'lib/kungfuig.rb', line 13

def