Class: Diakonos::ExtensionSet

Inherits:
Object
  • Object
show all
Defined in:
lib/diakonos/extension-set.rb

Instance Method Summary collapse

Constructor Details

#initialize(root_dir) ⇒ ExtensionSet

Returns a new instance of ExtensionSet


5
6
7
8
# File 'lib/diakonos/extension-set.rb', line 5

def initialize( root_dir )
  @extensions = Hash.new
  @root_dir = File.expand_path( root_dir )
end

Instance Method Details

#load(dir) ⇒ Object

Returns an Array of configuration filenames to parse

Returns:

  • an Array of configuration filenames to parse


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/diakonos/extension-set.rb', line 15

def load( dir )
  @extensions[ dir ] = false

  confs_to_parse = []
  ext_dir = File.join( @root_dir, dir )
  info = YAML.load_file( File.join( ext_dir, 'info.yaml' ) )

  if info[ 'requirements' ] && info[ 'requirements' ][ 'diakonos' ]
    this_version = ::Diakonos.parse_version( ::Diakonos::VERSION )
    min_version = ::Diakonos.parse_version( info[ 'requirements' ][ 'diakonos' ][ 'minimum' ] )
    if min_version && this_version >= min_version
      extension = Extension.new( ext_dir )
      @extensions[ dir ] = extension
      confs_to_parse += extension.confs
    end
  end

  confs_to_parse
end

#loaded?(ext_dir) ⇒ Boolean

Returns:

  • (Boolean)

35
36
37
# File 'lib/diakonos/extension-set.rb', line 35

def loaded?( ext_dir )
  @extensions[ ext_dir ]
end

#loaded_extensionsObject


39
40
41
# File 'lib/diakonos/extension-set.rb', line 39

def loaded_extensions
  @extensions.values.find_all { |e| e }
end

#not_loaded_extensionsObject


43
44
45
# File 'lib/diakonos/extension-set.rb', line 43

def not_loaded_extensions
  @extensions.keys.find_all { |e| ! loaded?( e ) }
end

#scriptsObject


10
11
12
# File 'lib/diakonos/extension-set.rb', line 10

def scripts
  @extensions.values.find_all { |e| e }.map { |e| e.scripts }.flatten
end