Class: File
- Inherits:
-
Object
- Object
- File
- Defined in:
- lib/base/file.rb
Class Method Summary collapse
- .amalgamate(filename, source) ⇒ Object
-
.publish(destination, source_dir, source_glob = '**/*', exclude_glob = nil) ⇒ Object
overwrite_existing=false.
Class Method Details
.amalgamate(filename, source) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/base/file.rb', line 6 def self.amalgamate filename,source File.open(filename,'w'){|file| source.each{|source_file| file.puts IO.read(source_file) } } end |
.publish(destination, source_dir, source_glob = '**/*', exclude_glob = nil) ⇒ Object
overwrite_existing=false
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/base/file.rb', line 14 def self.publish destination, source_dir, source_glob='**/*', exclude_glob=nil# overwrite_existing=false output = "\n" FileUtils.mkdir_p destination if !File.exists? destination files=nil Dir.chdir(source_dir) do files=FileList.new(source_glob).to_a if(!exclude_glob.nil?) FileList.new(exclude_glob).to_a.each{|f| files.delete(f) if(files.include?(f)) } end end output = output + "\nfiles: #{files}.to_s" Dir.chdir(source_dir) do files.each{|f| file="#{destination}/#{f}" dirname=File.dirname(file) FileUtils.mkdir_p dirname if !File.exists? dirname FileUtils.cp(f,file) if !File.exists? file# || overwrite_existing } end output end |