Class: Depends::DSL::Depend
- Inherits:
-
Object
- Object
- Depends::DSL::Depend
- Defined in:
- lib/depends/dsl/depend.rb
Class Method Summary collapse
Instance Method Summary collapse
- #default ⇒ Object
- #depend(name, options = {}) ⇒ Object
-
#initialize ⇒ Depend
constructor
A new instance of Depend.
- #key(api_key) ⇒ Object
- #source(source, options = {}) ⇒ Object
- #to_definition ⇒ Object
Constructor Details
#initialize ⇒ Depend
Returns a new instance of Depend.
15 16 17 18 |
# File 'lib/depends/dsl/depend.rb', line 15 def initialize @sources = [] @dependencies = [] end |
Class Method Details
.evaluate(dependsfile) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/depends/dsl/depend.rb', line 4 def self.evaluate(dependsfile) depends = new unless File.exist? dependsfile.to_s raise IOError, "Depends files does not exist #{dependsfile}" end depends.instance_eval(File.read(dependsfile.to_s), dependsfile.to_s, 1) depends.to_definition end |
Instance Method Details
#default ⇒ Object
39 40 41 |
# File 'lib/depends/dsl/depend.rb', line 39 def default @default ||= @sources.last end |
#depend(name, options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/depends/dsl/depend.rb', line 20 def depend(name, = {}) version = [:version] || :latest unless [:destination] raise Exceptions::DslError, "Destination is a required attribute" end destination = [:destination] @dependencies.push( HashWithIndifferentAccess.new ({ :name => name.downcase, :version => version, :destination => destination })) end |
#key(api_key) ⇒ Object
43 44 45 |
# File 'lib/depends/dsl/depend.rb', line 43 def key(api_key) @sources.last.api_key = api_key end |
#source(source, options = {}) ⇒ Object
35 36 37 |
# File 'lib/depends/dsl/depend.rb', line 35 def source(source, = {}) depends_source Depends::Util.depends_source(source) end |
#to_definition ⇒ Object
47 48 49 50 51 |
# File 'lib/depends/dsl/depend.rb', line 47 def to_definition @sources.uniq! raise DslError, "No source specified! Try source :depends" unless @sources.length > 0 Depends::Definition.new(@sources, @dependencies) end |