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
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
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
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 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
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
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
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
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 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
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
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