expansions 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/core/file_merge.rb +5 -17
- data/lib/core/version.rb +1 -1
- metadata +1 -1
data/lib/core/file_merge.rb
CHANGED
@@ -21,30 +21,18 @@ module Expansions
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def run
|
24
|
-
|
25
|
-
FileUtils.cp @output_file,copy_name if File.exist?(@output_file)
|
24
|
+
original_contents = File.read_all_text(@output_file)
|
26
25
|
FileUtils.rm_f @output_file
|
27
26
|
File.open_for_write(@output_file) do |file|
|
28
|
-
|
27
|
+
merge_files(@before_files,file)
|
28
|
+
file.write original_contents if @read_original_contents
|
29
|
+
merge_files(@after_files,file)
|
29
30
|
end
|
30
|
-
FileUtils.rm copy_name
|
31
|
-
end
|
32
|
-
|
33
|
-
def do_merge(temp_file,target_file)
|
34
|
-
merge_files(@before_files,target_file)
|
35
|
-
if @read_original_contents && File.exist?(temp_file)
|
36
|
-
File.open_for_read temp_file do|line|
|
37
|
-
target_file << line
|
38
|
-
end
|
39
|
-
end
|
40
|
-
merge_files(@after_files,target_file)
|
41
31
|
end
|
42
32
|
|
43
33
|
def merge_files(source_files,target)
|
44
34
|
source_files.each do|source|
|
45
|
-
File.
|
46
|
-
target << line
|
47
|
-
end
|
35
|
+
target.write File.read_all_text(source)
|
48
36
|
end
|
49
37
|
end
|
50
38
|
|
data/lib/core/version.rb
CHANGED