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, #initialize, #packer_settings, #parent, #write!

Constructor Details

This class inherits a constructor from Jake::Buildable

Instance Method Details

#code(name) ⇒ Object



16
17
18
19
20
21
# File 'lib/jake/package.rb', line 16

def code(name)
  return @code[name] if @code[name]
  settings = packer_settings(name)
  output = ERB.new(source).result(@build.helper.scope)
  @code[name] = settings ? Packr.pack(output, settings) : output
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 = "#{ directory }/#{ path }"
    File.file?(path) ? path : "#{ path }.js"
  end
end

#headerObject



23
24
25
26
# File 'lib/jake/package.rb', line 23

def header
  reqs = @config[:requires] || []
  [super, *reqs.map { |r| "// @require #{r}" }].join("\n")
end

#sourceObject



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

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