Module: Forge::Guard
- Defined in:
- lib/forge/guard.rb
Class Attribute Summary collapse
-
.builder ⇒ Object
Returns the value of attribute builder.
-
.project ⇒ Object
Returns the value of attribute project.
-
.task ⇒ Object
Returns the value of attribute task.
Class Method Summary collapse
Class Attribute Details
.builder ⇒ Object
Returns the value of attribute builder.
8 9 10 |
# File 'lib/forge/guard.rb', line 8 def builder @builder end |
.project ⇒ Object
Returns the value of attribute project.
8 9 10 |
# File 'lib/forge/guard.rb', line 8 def project @project end |
.task ⇒ Object
Returns the value of attribute task.
8 9 10 |
# File 'lib/forge/guard.rb', line 8 def task @task end |
Class Method Details
.add_guard(&block) ⇒ Object
11 12 13 14 |
# File 'lib/forge/guard.rb', line 11 def self.add_guard(&block) @additional_guards ||= [] @additional_guards << block end |
.start(project, task, options = {}, livereload = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/forge/guard.rb', line 16 def self.start(project, task, ={}, livereload={}) @project = project @task = task @builder = Builder.new(project) = "" .each do |k,v| << ", :#{k} => '#{v}'" end assets_path = @project.assets_path.gsub(/#{@project.root}\//, '') source_path = @project.source_path.gsub(/#{@project.root}\//, '') config_file = @project.config_file.gsub(/#{@project.root}\//, '') guardfile_contents = %Q{ guard 'forgeconfig'#{} do watch("#{config_file}") end guard 'forgeassets' do watch(%r{#{assets_path}/javascripts/*}) watch(%r{#{assets_path}/stylesheets/*}) watch(%r{#{assets_path}/images/*}) end guard 'forgetemplates' do watch(%r{#{source_path}/templates/*}) watch(%r{#{source_path}/partials/*}) end guard 'forgefunctions' do watch(%r{#{source_path}/functions/*}) watch(%r{#{source_path}/includes/*}) end } if @project.config[:livereload] guardfile_contents << %Q{ guard 'livereload' do watch(%r{#{source_path}/*}) end } end (@additional_guards || []).each do |block| result = block.call(, livereload) guardfile_contents << result unless result.nil? end ::Guard.start({ :guardfile_contents => guardfile_contents }) end |