expansions 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,18 +21,26 @@ module Expansions
21
21
  end
22
22
 
23
23
  def run
24
- original_contents = File.read_all_text(@output_file)
24
+ copy_name = File.join(File.dirname(@output_file),"copy_of_#{File.basename(@output_file)}")
25
+ FileUtils.cp @output_file, copy_name if File.exist?(@output_file)
25
26
  FileUtils.rm_f @output_file
26
27
  File.open_for_write(@output_file) do |file|
27
28
  merge_files(@before_files,file)
28
- file.write original_contents if @read_original_contents
29
+ write_contents(file,copy_name) if @read_original_contents && File.exist?(copy_name)
29
30
  merge_files(@after_files,file)
30
31
  end
32
+ FileUtils.rm_f copy_name if File.exist?(copy_name)
33
+ end
34
+
35
+ def write_contents(target_file_stream,file_to_read)
36
+ File.open_for_read(file_to_read) do|line|
37
+ target_file_stream << line
38
+ end
31
39
  end
32
40
 
33
41
  def merge_files(source_files,target)
34
42
  source_files.each do|source|
35
- target.write File.read_all_text(source)
43
+ write_contents(target,source)
36
44
  end
37
45
  end
38
46
 
data/lib/core/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Expansions
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expansions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-10 00:00:00.000000000 Z
12
+ date: 2012-05-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: guard