Class: Jake::Build
- Inherits:
-
Object
- Object
- Jake::Build
- Includes:
- Enumerable, Eventful
- Defined in:
- lib/jake/build.rb
Constant Summary collapse
- DEFAULT_LAYOUT =
'together'
Instance Attribute Summary collapse
-
#config_files ⇒ Object
readonly
Returns the value of attribute config_files.
-
#helper ⇒ Object
readonly
Returns the value of attribute helper.
Instance Method Summary collapse
- #build_directory ⇒ Object (also: #build_dir)
- #each(&block) ⇒ Object
- #force! ⇒ Object
- #forced? ⇒ Boolean
- #header ⇒ Object
-
#initialize(dir, options = {}) ⇒ Build
constructor
A new instance of Build.
- #layout ⇒ Object
- #package(name) ⇒ Object
- #packages ⇒ Object
- #packer_settings(build_name) ⇒ Object
- #run! ⇒ Object
- #source_directory ⇒ Object (also: #source_dir)
- #use_suffix?(build_name) ⇒ Boolean
Constructor Details
#initialize(dir, options = {}) ⇒ Build
Returns a new instance of Build.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jake/build.rb', line 9 def initialize(dir, = {}) @dir = File.(dir) @helper = Helper.new() force! if [:force] path = Jake.path(dir, CONFIG_FILE) yaml = File.read(path) @config_files = [path] @config = Jake.symbolize_hash( YAML.load(Jake.erb(yaml).result(@helper.scope)) ) helpers = Jake.path(dir, HELPER_FILE) if File.file?(helpers) load helpers @config_files << helpers end @builds = @config[:builds] || {:src => false, :min => @config[:packer]} @packages = @config[:packages].inject({}) do |pkgs, (name, conf)| pkgs[name] = Package.new(self, name, conf) pkgs end @bundles = (@config[:bundles] || {}).inject({}) do |pkgs, (name, conf)| pkgs[name] = Bundle.new(self, name, conf) pkgs end end |
Instance Attribute Details
#config_files ⇒ Object (readonly)
Returns the value of attribute config_files.
5 6 7 |
# File 'lib/jake/build.rb', line 5 def config_files @config_files end |
#helper ⇒ Object (readonly)
Returns the value of attribute helper.
5 6 7 |
# File 'lib/jake/build.rb', line 5 def helper @helper end |
Instance Method Details
#build_directory ⇒ Object Also known as: build_dir
70 71 72 |
# File 'lib/jake/build.rb', line 70 def build_directory Jake.path(@dir, @config[:build_directory] || '.') end |
#each(&block) ⇒ Object
39 40 41 |
# File 'lib/jake/build.rb', line 39 def each(&block) @builds.each(&block) end |
#force! ⇒ Object
43 44 45 |
# File 'lib/jake/build.rb', line 43 def force! @forced = true end |
#forced? ⇒ Boolean
47 48 49 |
# File 'lib/jake/build.rb', line 47 def forced? defined?(@forced) end |
#header ⇒ Object
80 81 82 83 84 |
# File 'lib/jake/build.rb', line 80 def header @config[:header] ? Jake.read(Jake.path(source_directory, @config[:header])) : "" end |
#layout ⇒ Object
98 99 100 |
# File 'lib/jake/build.rb', line 98 def layout @config[:layout] || DEFAULT_LAYOUT end |
#package(name) ⇒ Object
58 59 60 |
# File 'lib/jake/build.rb', line 58 def package(name) @packages[name.to_sym] || @bundles[name.to_sym] end |
#packages ⇒ Object
51 52 53 54 55 56 |
# File 'lib/jake/build.rb', line 51 def packages list = [] @packages.each { |name, pkg| list << name } @bundles.each { |name, pkg| list << name } list end |
#packer_settings(build_name) ⇒ Object
86 87 88 89 90 |
# File 'lib/jake/build.rb', line 86 def packer_settings(build_name) build = @builds[build_name.to_sym] return false unless build build[:packer].nil? ? build : build[:packer] end |
#run! ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/jake/build.rb', line 62 def run! FileUtils.cd(@dir) do @packages.each { |name, pkg| pkg.write! } @bundles.each { |name, pkg| pkg.write! } fire(:build_complete) end end |
#source_directory ⇒ Object Also known as: source_dir
75 76 77 |
# File 'lib/jake/build.rb', line 75 def source_directory Jake.path(@dir, @config[:source_directory] || '.') end |
#use_suffix?(build_name) ⇒ Boolean
92 93 94 95 96 |
# File 'lib/jake/build.rb', line 92 def use_suffix?(build_name) build = @builds[build_name.to_sym] return true unless build build[:suffix] != false end |