Class: Speck

Inherits:
Object
  • Object
show all
Defined in:
lib/speck.rb,
lib/speck/check.rb,
lib/speck/core_ext/check_mixins.rb

Overview

All library files are required at the bottom, because in this unique case we need ‘Speck` defined before we can use it to `Speck` anything.

Defined Under Namespace

Modules: Mixins Classes: Check, Exception

Constant Summary collapse

Version =
0

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*targets, &speck) ⇒ Speck

Creates a new ‘Speck`.



51
52
53
54
55
56
57
# File 'lib/speck.rb', line 51

def initialize *targets, &speck
  @speck = speck
  @parent = Speck.current
  
  @parent.children << self if @parent
  Speck.specks << self
end

Class Attribute Details

.specksObject

All defined Specks.



11
12
13
# File 'lib/speck.rb', line 11

def specks
  @specks
end

.stackObject

The current stack of nested ‘Speck`s.

See Also:

  • #current


18
19
20
# File 'lib/speck.rb', line 18

def stack
  @stack
end

Instance Attribute Details

#checksObject

The checks involved in the current ‘Speck`.



46
47
48
# File 'lib/speck.rb', line 46

def checks
  @checks
end

#childrenObject

Child ‘Speck`s



37
38
39
# File 'lib/speck.rb', line 37

def children
  @children
end

#parentObject

Parent ‘Speck`



42
43
44
# File 'lib/speck.rb', line 42

def parent
  @parent
end

#speckObject

The block to be executed



33
34
35
# File 'lib/speck.rb', line 33

def speck
  @speck
end

Class Method Details

.currentObject

Returns the currently active ‘Speck`.

When your ‘Speck`s are being run, there is a `stack` of `Speck` objects, consisting of the current nesting list of `Speck`s being run.



26
27
28
# File 'lib/speck.rb', line 26

def current
  stack.last
end

Instance Method Details

#executeObject

Executes the ‘Speck`.



61
62
63
64
65
66
67
# File 'lib/speck.rb', line 61

def execute
  Speck::Mixins::mixin!
  
  Speck.stack << self
  speck.call
  Speck.stack.pop
end