Class: Vendor::VendorFile::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/vendor/vendor_file/dsl.rb

Defined Under Namespace

Classes: UnknownLibraryType

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDSL

Returns a new instance of DSL.



12
13
14
15
# File 'lib/vendor/vendor_file/dsl.rb', line 12

def initialize
  @sources = []
  @libraries = []
end

Instance Attribute Details

#librariesObject (readonly)

Returns the value of attribute libraries.



10
11
12
# File 'lib/vendor/vendor_file/dsl.rb', line 10

def libraries
  @libraries
end

#sourcesObject (readonly)

Returns the value of attribute sources.



9
10
11
# File 'lib/vendor/vendor_file/dsl.rb', line 9

def sources
  @sources
end

Instance Method Details

#lib(name, version = nil, options = nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/vendor/vendor_file/dsl.rb', line 23

def lib(name, version = nil, options = nil)
  if options.nil? && version.kind_of?(Hash)
    options = version
    version = nil
  end

  klass = Vendor::VendorFile::Library::Remote

  if options
    if options.has_key?(:git)
      klass = Vendor::VendorFile::Library::Git
    elsif options.has_key?(:path)
      klass = Vendor::VendorFile::Library::Local
    end
  end

  opts = { :name => name }.merge(options || {})
  opts[:targets] = @with_targets if @with_targets && !opts.has_key?(:target) && !opts.has_key?(:targets)
  opts[:version] = version if version

  @libraries << klass.new(opts)
end

#source(source) ⇒ Object



17
18
19
20
21
# File 'lib/vendor/vendor_file/dsl.rb', line 17

def source(source)
  Vendor.ui.warn "Having multiple vendor sources is currently not supported. It will be in a future release."

  @sources << Vendor::VendorFile::Source.new(source)
end

#target(*targets, &block) ⇒ Object



46
47
48
49
50
# File 'lib/vendor/vendor_file/dsl.rb', line 46

def target(*targets, &block)
  @with_targets = targets
  yield
  @with_targets = nil
end