Class: BuildTool::Feature

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/build-tool/model/feature.rb

Overview

A feature bundles modules and makes it possible to enable/disable them together.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#default_activeObject

The default state of the feature



19
20
21
# File 'lib/build-tool/model/feature.rb', line 19

def default_active
  @default_active
end

#descriptionObject

A short description for the feature



13
14
15
# File 'lib/build-tool/model/feature.rb', line 13

def description
  @description
end

#environmentsObject (readonly)

The environments associated with this feature



25
26
27
# File 'lib/build-tool/model/feature.rb', line 25

def environments
  @environments
end

#long_descriptionObject

A long description for the feature



16
17
18
# File 'lib/build-tool/model/feature.rb', line 16

def long_description
  @long_description
end

#modulesObject (readonly)

The modules associated with this feature



22
23
24
# File 'lib/build-tool/model/feature.rb', line 22

def modules
  @modules
end

Instance Method Details

#active?Boolean

Is the feature active?

Returns:

  • (Boolean)


38
39
40
41
42
43
44
45
# File 'lib/build-tool/model/feature.rb', line 38

def active?
    state = active.nil? ? default_active : active
    if parent_id.nil?
        state
    else
        parent.active? && state
    end
end

#active_charObject

Return a character showing the features active state.



48
49
50
51
52
53
54
# File 'lib/build-tool/model/feature.rb', line 48

def active_char
    if active?
        ANSI::Code.green { "A" }
    else
        "I"
    end
end

#default_active?Boolean

Is the feature active by default?

Returns:

  • (Boolean)


57
58
59
# File 'lib/build-tool/model/feature.rb', line 57

def default_active?
    default_active
end

#my_initializeObject



29
30
31
32
33
34
35
# File 'lib/build-tool/model/feature.rb', line 29

def my_initialize
    @description = nil
    @long_description = nil
    @modules = []
    @environments = []
    @default_active = true
end

#pathObject

Return a unique name for the feature.

The name is scoped with the parents name.



64
65
66
67
68
69
70
# File 'lib/build-tool/model/feature.rb', line 64

def path
    if parent.nil?
        name
    else
        "%s/%s" % [ parent.name, name ]
    end
end

#to_sObject



72
73
74
# File 'lib/build-tool/model/feature.rb', line 72

def to_s
    "Feature #{name} ( #{self.active} / #{self.default_active} )"
end