Class: CORL::Build
- Inherits:
-
Object
- Object
- CORL::Build
- Defined in:
- lib/core/build.rb
Constant Summary collapse
- @@build_lock =
Build lock
Mutex.new
Instance Method Summary collapse
-
#build_lock ⇒ Object
—.
-
#config ⇒ Object
—————————————————————————– Package configuration.
- #import(config) ⇒ Object
-
#initialize ⇒ Build
constructor
—————————————————————————– Constructor / destructor.
-
#locations ⇒ Object
—————————————————————————– Build locations.
-
#manage(plugin_type, options = {}) ⇒ Object
—————————————————————————– Builders.
-
#method_missing(method, *args, &code) ⇒ Object
—————————————————————————– Addon build types.
-
#register(type, plural = nil) ⇒ Object
—————————————————————————– Type registration.
- #remove_location(provider, name = nil) ⇒ Object
- #set_location(provider, name, directory) ⇒ Object
Constructor Details
#initialize ⇒ Build
Constructor / destructor
8 9 10 11 12 13 14 |
# File 'lib/core/build.rb', line 8 def initialize @config = Config.new({}, {}, true, false) @locations = Config.new({}, {}, true, false) @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
71 72 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 |
# File 'lib/core/build.rb', line 71 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_lock ⇒ Object
23 24 25 |
# File 'lib/core/build.rb', line 23 def build_lock @@build_lock end |
#config ⇒ Object
Package configuration
45 46 47 |
# File 'lib/core/build.rb', line 45 def config @config end |
#import(config) ⇒ Object
49 50 51 |
# File 'lib/core/build.rb', line 49 def import(config) @config.import(config) end |
#locations ⇒ Object
Build locations
56 57 58 |
# File 'lib/core/build.rb', line 56 def locations @locations end |
#manage(plugin_type, options = {}) ⇒ Object
Builders
106 107 108 |
# File 'lib/core/build.rb', line 106 def manage(plugin_type, = {}) CORL.send(plugin_type, ) end |
#register(type, plural = nil) ⇒ Object
Type registration
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/core/build.rb', line 30 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
64 65 66 |
# File 'lib/core/build.rb', line 64 def remove_location(provider, name = nil) @locations.delete([ provider, name ]) end |
#set_location(provider, name, directory) ⇒ Object
60 61 62 |
# File 'lib/core/build.rb', line 60 def set_location(provider, name, directory) @locations.set([ provider, name ], directory) end |