Class: Jake::Package

Inherits:
Buildable show all
Defined in:
lib/jake/package.rb

Instance Attribute Summary

Attributes inherited from Buildable

#name

Instance Method Summary collapse

Methods inherited from Buildable

#build_needed?, #build_path, #directory, #header, #initialize, #meta, #packer_settings, #parent, #write!

Constructor Details

This class inherits a constructor from Jake::Buildable

Instance Method Details

#code(build_name, with_header = true) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/jake/package.rb', line 16

def code(build_name, with_header = true)
  if cached = @code[build_name]
    return with_header ? cached : cached.code
  end
  
  packer = packer_settings(build_name)
  
  head = header
  head = head && head.strip unless packer[:minify] == false
  
  packer = packer.merge(:header => head)
  code = code_for_packer(packer, build_name)
  
  cached = @code[build_name] = code
  with_header ? code : code.code
end

#filesObject



4
5
6
7
8
9
10
# File 'lib/jake/package.rb', line 4

def files
  base = parent ? parent.files : []
  base + @config[:files].map do |path|
    path = Jake.path( directory, path)
    File.file?(path) ? path : "#{ path }.js"
  end
end

#sourceObject



12
13
14
# File 'lib/jake/package.rb', line 12

def source
  @source ||= files.map { |path| Jake.read(path) }.join("\n")
end