Module: SC::Buildfile::Commands
- Included in:
- SC::Buildfile
- Defined in:
- lib/sproutcore/buildfile/buildfile_dsl.rb
Overview
Describe the domain-specific-language helpers supported by buildfiles. This is included as a mixin for the buildfile.
Instance Method Summary collapse
-
#build_task(*args, &block) ⇒ Object
Define a build task.
-
#config(config_name, opts = {}) {|opts| ... } ⇒ Object
Register the passed configuration settings scoped to a target.
-
#desc(description) ⇒ Object
Describe the next rake task.
-
#import(*args) ⇒ Object
Import the partial Rakefiles
fn
. -
#mode(build_mode, &block) ⇒ Object
Scope any config statements inside the passed block to the named mode.
-
#namespace(name = nil, &block) ⇒ Object
Create a new rake namespace and use it for evaluating the given block.
-
#project(name = nil, type = nil) ⇒ Object
Register info about this buildfile as a project.
-
#proxy(proxy_path, opts = {}) ⇒ Object
Register a proxy setting.
-
#replace_task(*args, &block) ⇒ Object
Replace an existing task instead of enhancing it.
-
#task(*args, &block) ⇒ Object
Declare a basic task.
-
#task_options(opts) ⇒ Object
Describe options on the next rake task.
Instance Method Details
#build_task(*args, &block) ⇒ Object
Define a build task. A build task will not run if the destination file is newer than the source files.
54 55 56 |
# 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| ... } ⇒ Object
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
141 142 143 144 145 146 |
# 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) ⇒ Object
Describe the next rake task.
Example:
desc "Run the Unit Tests"
task :test => [:build]
runtests
end
100 101 102 |
# File 'lib/sproutcore/buildfile/buildfile_dsl.rb', line 100 def desc(description) last_description = description end |
#import(*args) ⇒ Object
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"
69 70 71 72 73 74 75 |
# 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.(fn, base_path) add_import(fn) end end |
#mode(build_mode, &block) ⇒ Object
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
124 125 126 127 128 129 130 |
# 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) ⇒ Object
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.
88 89 90 |
# File 'lib/sproutcore/buildfile/buildfile_dsl.rb', line 88 def namespace(name=nil, &block) in_namespace(name, &block) end |
#project(name = nil, type = nil) ⇒ Object
Register info about this buildfile as a project
158 159 160 161 162 |
# 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 = {}) ⇒ Object
Register a proxy setting
Example:
proxy '/url', :to => 'localhost:3000'
153 154 155 |
# File 'lib/sproutcore/buildfile/buildfile_dsl.rb', line 153 def proxy(proxy_path, opts={}) add_proxy proxy_path, opts end |
#replace_task(*args, &block) ⇒ Object
Replace an existing task instead of enhancing it.
Example:
replace_task :clobber => :clean do
rm_rf 'javascript'
end
41 42 43 44 45 46 47 48 49 |
# 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) ⇒ Object
Declare a basic task.
Example:
task :clobber => [:clean] do
rm_rf "html"
end
30 31 32 |
# File 'lib/sproutcore/buildfile/buildfile_dsl.rb', line 30 def task(*args, &block) define_task(::SC::Buildfile::Task, *args, &block) end |
#task_options(opts) ⇒ Object
Describe options on the next rake task.
Example:
options :log => :env|:name|:none
task :test => [:build]
runtests
end
112 113 114 |
# File 'lib/sproutcore/buildfile/buildfile_dsl.rb', line 112 def (opts) = opts end |