sprout 0.7.203 → 0.7.204

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sprout might be problematic. Click here for more details.

@@ -38,6 +38,10 @@ module Sprout #:nodoc:
38
38
  @alive = update_status
39
39
  end
40
40
 
41
+ def kill
42
+ Process.kill(9, pid)
43
+ end
44
+
41
45
  def close
42
46
  update_status
43
47
  end
@@ -29,6 +29,19 @@ module Sprout
29
29
  # that is implemented on this class.
30
30
  #
31
31
  class ToolTask < Rake::FileTask
32
+ @@preprocessed_tasks = Hash.new
33
+
34
+ def self.add_preprocessed_task(name)
35
+ @@preprocessed_tasks[name] = true
36
+ end
37
+
38
+ def self.has_preprocessed_task?(name)
39
+ !@@preprocessed_tasks[name].nil?
40
+ end
41
+
42
+ def self.clear_preprocessed_tasks
43
+ @@preprocessed_tasks.clear
44
+ end
32
45
 
33
46
  def initialize(name, app) # :nodoc:
34
47
  super
@@ -558,37 +571,54 @@ module Sprout
558
571
  return if(File.directory?(input_file))
559
572
  CLEAN.add(belongs_to.preprocessed_path) if(!CLEAN.index(belongs_to.preprocessed_path))
560
573
 
561
- file input_file
562
- file output_file => input_file do
563
- dir = File.dirname(output_file)
564
- if(!File.exists?(dir))
565
- FileUtils.mkdir_p(dir)
566
- end
567
- File.open(input_file, 'r') do |readable|
574
+ # Only create the preprocessed action if one does not
575
+ # already exist. There were many being created before...
576
+ if(!ToolTask::has_preprocessed_task?(input_file))
577
+ ToolTask::add_preprocessed_task(input_file)
578
+
579
+ file input_file
580
+ file output_file => input_file do
581
+ dir = File.dirname(output_file)
582
+ if(!File.exists?(dir))
583
+ FileUtils.mkdir_p(dir)
584
+ end
585
+
586
+ content = nil
587
+ # Open the input file and read its content:
588
+ File.open(input_file, 'r') do |readable|
589
+ content = readable.read
590
+ end
591
+
592
+ # Preprocess the content if it's a known text file type:
593
+ if(text_file?(input_file))
594
+ content = preprocess_content(content, belongs_to.preprocessor, input_file)
595
+ end
596
+
597
+ # Write the content to the output file:
568
598
  File.open(output_file, 'w+') do |writable|
569
- if(text_file?(input_file))
570
- preprocess_content(readable, writable, belongs_to.preprocessor, input_file)
571
- else
572
- writable.write(readable.read)
573
- end
599
+ writable.write(content)
574
600
  end
601
+
575
602
  end
603
+
604
+ belongs_to.prerequisites << output_file
576
605
  end
577
- belongs_to.prerequisites << output_file
578
606
  end
579
607
 
580
- def preprocess_content(readable, writable, processor, file)
581
- process = ProcessRunner.new(processor)
582
- process.puts(readable.read)
608
+ def preprocess_content(content, statement, file_name)
609
+ process = ProcessRunner.new(statement)
610
+ process.puts(content)
583
611
  process.close_write
584
612
  result = process.read
585
613
  error = process.read_err
586
614
  if(error.size > 0)
587
615
  belongs_to.display_preprocess_message
588
616
  FileUtils.rm_rf(belongs_to.preprocessed_path)
589
- raise ExecutionError.new("[ERROR] Preprocessor failed on file #{file} #{error}")
617
+ raise ExecutionError.new("[ERROR] Preprocessor failed on file #{file_name} #{error}")
590
618
  end
591
- writable.write(result)
619
+ process.kill
620
+ Log.puts ">> Preprocessed and created: #{belongs_to.preprocessed_path}/#{file_name}"
621
+ return result
592
622
  end
593
623
 
594
624
  end
@@ -2,7 +2,7 @@ module Sprout
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 7
5
- TINY = 203
5
+ TINY = 204
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  MAJOR_MINOR = [MAJOR, MINOR].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.203
4
+ version: 0.7.204
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Bayes
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-14 00:00:00 -08:00
12
+ date: 2009-01-26 00:00:00 -08:00
13
13
  default_executable: sprout
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency