Class: CORL::Build

Inherits:
Core
  • Object
show all
Includes:
Parallel
Defined in:
lib/core/build.rb

Constant Summary collapse

@@build_lock =

Build lock

Mutex.new

Instance Method Summary collapse

Constructor Details

#initializeBuild


Constructor / destructor



10
11
12
13
14
15
16
# File 'lib/core/build.rb', line 10

def initialize
  @config    = Config.new
  @locations = Config.new
  
  @plurals   = {}
  @types     = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &code) ⇒ Object


Addon build types



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/core/build.rb', line 73

def method_missing(method, *args, &code)
  success = false
  result  = nil
    
  if method.to_s.match(/^set\_([a-z].*)$/)
    name = $1.to_sym
    
    if @types.has_key?(name) && args.length > 2
      @types[name].set([ args[0], args[1] ], args[2]) if args.length > 2
      success = true
    end
    
  elsif method.to_s.match(/^remove\_([a-z].*)$/)
    name = $1.to_sym
    
    if @types.has_key?(name) && args.length > 0
      @types[name].delete([ args[0], args[1] ])
      success = true
    end
    
  else
    name = @plurals[method.to_sym]
    
    if name && @types.has_key?(name)
      result  = @types[name]
      success = true
    end  
  end
  super unless success # Raise NoMethodError
  result
end

Instance Method Details

#build_lockObject




25
26
27
# File 'lib/core/build.rb', line 25

def build_lock
  @@build_lock
end

#configObject


Package configuration



47
48
49
# File 'lib/core/build.rb', line 47

def config
  @config  
end

#import(config) ⇒ Object



51
52
53
# File 'lib/core/build.rb', line 51

def import(config)
  @config.import(config)  
end

#locationsObject


Build locations



58
59
60
# File 'lib/core/build.rb', line 58

def locations
  @locations
end

#manage(plugin_type, options = {}) ⇒ Object


Builders



108
109
110
# File 'lib/core/build.rb', line 108

def manage(plugin_type, options = {})
  CORL.send(plugin_type, options)
end

#register(type, plural = nil) ⇒ Object


Type registration



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/core/build.rb', line 32

def register(type, plural = nil)
  type = type.to_sym
  
  if plural
    plural = plural.to_sym
  else
    plural = "#{type}s".to_sym
  end
  @plurals[plural] = type
  @types[type]     = Config.new
end

#remove_location(provider, name = nil) ⇒ Object



66
67
68
# File 'lib/core/build.rb', line 66

def remove_location(provider, name = nil)
  @locations.delete([ provider, name ])
end

#set_location(provider, name, directory) ⇒ Object



62
63
64
# File 'lib/core/build.rb', line 62

def set_location(provider, name, directory)
  @locations.set([ provider, name ], directory)
end