sprout 0.7.203-x86-linux → 0.7.204-x86-linux
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.
- data/lib/sprout/process_runner.rb +4 -0
- data/lib/sprout/tasks/tool_task.rb +48 -18
- data/lib/sprout/version.rb +1 -1
- metadata +2 -2
@@ -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
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
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
|
-
|
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(
|
581
|
-
process = ProcessRunner.new(
|
582
|
-
process.puts(
|
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 #{
|
617
|
+
raise ExecutionError.new("[ERROR] Preprocessor failed on file #{file_name} #{error}")
|
590
618
|
end
|
591
|
-
|
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
|
data/lib/sprout/version.rb
CHANGED
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.
|
4
|
+
version: 0.7.204
|
5
5
|
platform: x86-linux
|
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-
|
12
|
+
date: 2009-01-26 00:00:00 -08:00
|
13
13
|
default_executable: sprout
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|