public
Description: Simplest Possible HTML Templating Framework
Homepage: http://templation.websaviour.com/
Clone URL: git://github.com/dasil003/templation.git
templation / fix_include.rb
100755 33 lines (30 sloc) 0.74 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env ruby -w
 
match = /(include(?:_once)?\(\s*(?:'|"))(Templation\/driver\.php(?:'|")\s*\);?)/
replace = '\1\2'
ignore_filenames = /\.svn/
ignore = /IGNORE_FILES_CONTAINING_THIS_REGULAR_EXPRESSION/
 
$stdin.each do |arg|
  arg.strip!
  if !(arg =~ ignore_filenames)
    if FileTest::exist? arg
      open arg do |f|
        f.gets nil
        if ~match
          if ~ignore
            print "IGNORED #{arg}\n"
          else
            gsub! match, replace
            open arg, 'w' do |fileout|
              fileout.write $_
            end
            print "REPLACED #{arg}\n"
          end
        end
      end
    else
      print "Error: #{arg} is not a file.\n"
    end
  else
    print "SKIPPED #{arg}\n"
  end
end