Class: PluginManager::DefinitionBuilder
- Inherits:
-
Object
- Object
- PluginManager::DefinitionBuilder
- Defined in:
- lib/plugin_manager/definition_builder.rb
Instance Method Summary collapse
- #build ⇒ Object
- #dependencies(*deps) ⇒ Object
- #file(*values) ⇒ Object
-
#initialize(&block) ⇒ DefinitionBuilder
constructor
A new instance of DefinitionBuilder.
- #install(*args) ⇒ Object
- #name(value) ⇒ Object
- #object(value) ⇒ Object
- #version(value) ⇒ Object
Constructor Details
#initialize(&block) ⇒ DefinitionBuilder
Returns a new instance of DefinitionBuilder.
4 5 6 7 |
# File 'lib/plugin_manager/definition_builder.rb', line 4 def initialize(&block) @block = block @definition = PluginDefinition.new end |
Instance Method Details
#build ⇒ Object
9 10 11 12 |
# File 'lib/plugin_manager/definition_builder.rb', line 9 def build instance_eval(&@block) @definition end |
#dependencies(*deps) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/plugin_manager/definition_builder.rb', line 48 def dependencies(*deps) @definition.dependencies ||= [] deps.each_slice(2) do |name, ver| @definition.dependencies << PluginManager::Dependency.new(PluginManager.current, name, ver) end end |
#file(*values) ⇒ Object
26 27 28 |
# File 'lib/plugin_manager/definition_builder.rb', line 26 def file(*values) @definition.file = values end |
#install(*args) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/plugin_manager/definition_builder.rb', line 30 def install(*args) if args.length == 1 if Hash === args.first hash = args.first else hash = { args.first => File.basename(args.first) } end elsif args.length == 2 prefix = args.first if Hash === args[1] hash = Hash[args[1].map {|k, v| [prefix + k, v]}] elsif Array === args[1] hash = Hash[args[1].map {|path| [prefix + path, File.basename(path) ] } ] end end @definition.resources.merge!(hash) end |
#name(value) ⇒ Object
14 15 16 |
# File 'lib/plugin_manager/definition_builder.rb', line 14 def name(value) @definition.name = value end |
#object(value) ⇒ Object
22 23 24 |
# File 'lib/plugin_manager/definition_builder.rb', line 22 def object(value) @definition.object_string = value end |
#version(value) ⇒ Object
18 19 20 |
# File 'lib/plugin_manager/definition_builder.rb', line 18 def version(value) @definition.version = value end |