regenerate 0.2.1 → 0.2.2

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.
@@ -63,6 +63,8 @@ module Regenerate
63
63
  # Extensions for types of files to be generated/regenerated
64
64
  REGENERATE_EXTENSIONS = [".htm", ".html", ".xml"]
65
65
 
66
+ SOURCE_EXTENSIONS = {".css" => [".scss", ".sass"]}
67
+
66
68
  # Copy a source file directly to an output file
67
69
  def copySrcToOutputFile(srcFile, outFile)
68
70
  makeBackupFile(outFile)
@@ -98,7 +100,21 @@ module Regenerate
98
100
  if REGENERATE_EXTENSIONS.include? extension
99
101
  raise "Regeneration from output not yet implemented."
100
102
  else
101
- copySrcToOutputFile(outFile, srcFile)
103
+ okToCopyBack = true
104
+ if SOURCE_EXTENSIONS.has_key? extension
105
+ srcExtensions = SOURCE_EXTENSIONS[extension]
106
+ srcNameWithoutExtension = srcFile.chomp(extension)
107
+ possibleSrcFiles = srcExtensions.map{|srcExtension| srcNameWithoutExtension + srcExtension}
108
+ for possibleSrcFile in possibleSrcFiles
109
+ if File.exist? possibleSrcFile
110
+ puts "NOT COPYING #{outFile} back to source because source file #{possibleSrcFile} exists"
111
+ okToCopyBack = false
112
+ end
113
+ end
114
+ end
115
+ if okToCopyBack
116
+ copySrcToOutputFile(outFile, srcFile)
117
+ end
102
118
  end
103
119
  end
104
120
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regenerate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
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: 2013-06-11 00:00:00.000000000 Z
12
+ date: 2013-07-01 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Use to regenerate to write a web page with embedded instance variable
15
15
  definitions and embedded ruby code which executes to regenerate the same web page