Class: Platform::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/devtools/integration/platform/matcher.rb

Overview

Match current platform variables like Ruby engine, current database.

Since:

  • 0.2.0

Defined Under Namespace

Classes: Nope

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMatcher

Returns a new instance of Matcher.

Since:

  • 0.2.0



35
36
37
# File 'lib/hanami/devtools/integration/platform/matcher.rb', line 35

def initialize
  freeze
end

Class Method Details

.match(&blk) ⇒ Object

Since:

  • 0.2.0



23
24
25
26
27
# File 'lib/hanami/devtools/integration/platform/matcher.rb', line 23

def self.match(&blk)
  catch :match do
    new.__send__(:match, &blk)
  end
end

.match?(os: Os.current, engine: Engine.current) ⇒ Boolean

Returns:

Since:

  • 0.2.0



29
30
31
32
33
# File 'lib/hanami/devtools/integration/platform/matcher.rb', line 29

def self.match?(os: Os.current, engine: Engine.current)
  catch :match do
    new.os(os).engine(engine) { true }.or(false)
  end
end

Instance Method Details

#default(&blk) ⇒ Object

Since:

  • 0.2.0



49
50
51
# File 'lib/hanami/devtools/integration/platform/matcher.rb', line 49

def default(&blk)
  resolve(&blk)
end

#engine(name, &blk) ⇒ Object

Since:

  • 0.2.0



44
45
46
47
# File 'lib/hanami/devtools/integration/platform/matcher.rb', line 44

def engine(name, &blk)
  return nope unless engine?(name)
  block_given? ? resolve(&blk) : yep
end

#os(name, &blk) ⇒ Object

Since:

  • 0.2.0



39
40
41
42
# File 'lib/hanami/devtools/integration/platform/matcher.rb', line 39

def os(name, &blk)
  return nope unless os?(name)
  block_given? ? resolve(&blk) : yep
end