module SC::Buildfile::Commands

Describe the domain-specific-language helpers supported by buildfiles. This is included as a mixin for the buildfile.

Public Instance Methods

build_task(*args, &block) click to toggle source

Define a build task. A build task will not run if the destination file is newer than the source files.

# File lib/sproutcore/buildfile/buildfile_dsl.rb, line 54
def build_task(*args, &block)
  define_task(::SC::Buildfile::BuildTask, *args, &block)
end
config(config_name, opts = {}) { |opts| ... } click to toggle source

Register the passed configuration settings scoped to a target. Optional pass a block to edit the config.

Example:

config :all, :url_root => "static"
config :sproutcore do |c|
   c.url_root = "static"
end
# File lib/sproutcore/buildfile/buildfile_dsl.rb, line 141
def config(config_name, opts = {}, &block)
  opts = ::SC::Buildfile::Config.new(opts)
  yield(opts) if block_given?
  add_config config_name, opts
  return self
end
desc(description) click to toggle source

Describe the next rake task.

Example:

desc "Run the Unit Tests"
task :test => [:build]
  runtests
end
# File lib/sproutcore/buildfile/buildfile_dsl.rb, line 100
def desc(description)
  last_description = description
end
import(*args) click to toggle source

Import the partial Rakefiles fn. Imported files are loaded after the current file is completely loaded. This allows the import statement to appear anywhere in the importing file, and yet allowing the imported files to depend on objects defined in the importing file.

A common use of the import statement is to include files containing dependency declarations.

Example:

import ".depend", "my_rules"
# File lib/sproutcore/buildfile/buildfile_dsl.rb, line 69
def import(*args)
  base_path = current_path.nil? ? nil : File.dirname(current_path)
  args.each do |fn|
    fn = File.expand_path(fn, base_path)
    add_import(fn)
  end
end
mode(build_mode) { || ... } click to toggle source

Scope any config statements inside the passed block to the named mode. Normally if you call a config statement outside of a mode block, it will scope to all modes.

Example: mode :debug do

config :all, :combine_javascript => NO
# File lib/sproutcore/buildfile/buildfile_dsl.rb, line 124
def mode(build_mode, &block)
  old_mode = current_mode
  self.current_mode = build_mode.to_sym
  yield if block_given?
  self.current_mode = old_mode
  return self
end
namespace(name=nil, &block) click to toggle source

Create a new rake namespace and use it for evaluating the given block. Returns a NameSpace object that can be used to lookup tasks defined in the namespace.

E.g.

ns = namespace "nested" do
  task :run
end
task_run = ns[:run] # find :run in the given namespace.
# File lib/sproutcore/buildfile/buildfile_dsl.rb, line 88
def namespace(name=nil, &block)
  in_namespace(name, &block)
end
project(name=nil, type=nil) click to toggle source

Register info about this buildfile as a project

# File lib/sproutcore/buildfile/buildfile_dsl.rb, line 158
def project(name=nil, type=nil)
  self.project_name = name.nil? ? :default : name.to_sym
  self.project_type = type.nil? ? :default : type.to_sym
  self.project!
end
proxy(proxy_path, opts={}) click to toggle source

Register a proxy setting

Example:

proxy '/url', :to => 'localhost:3000'
# File lib/sproutcore/buildfile/buildfile_dsl.rb, line 153
def proxy(proxy_path, opts={})
  add_proxy proxy_path, opts
end
replace_task(*args, &block) click to toggle source

Replace an existing task instead of enhancing it.

Example:

replace_task :clobber => :clean do
   rm_rf 'javascript'
end
# File lib/sproutcore/buildfile/buildfile_dsl.rb, line 41
def replace_task(*args, &block)
  @is_redefining = true
  begin
    define_task(::SC::Buildfile::Task, *args, &block)
  rescue Exception => e
    @is_redefining = false
    raise e
  end
end
task(*args, &block) click to toggle source

Declare a basic task.

Example:

task :clobber => [:clean] do
  rm_rf "html"
end
# File lib/sproutcore/buildfile/buildfile_dsl.rb, line 30
def task(*args, &block)
  define_task(::SC::Buildfile::Task, *args, &block)
end
task_options(opts) click to toggle source

Describe options on the next rake task.

Example:

options :log => :env|:name|:none
task :test => [:build]
  runtests
end
# File lib/sproutcore/buildfile/buildfile_dsl.rb, line 112
def task_options(opts)
  last_task_options = opts
end