Sha256: b210313667a8b1d08c91b75c238443513c6bc8992c0b1cd5c5b8a1dbd4a645de

Contents?: true

Size: 957 Bytes

Versions: 13

Compression:

Stored size: 957 Bytes

Contents

puts __FILE__ if defined?(DEBUG)

require 'fileutils'

class File
	def self.amalgamate filename,source
		File.open(filename,'w'){|file|
			source.each{|source_file|
				file.puts IO.read(source_file)
			}
		}
	end

	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
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
dev-2.1.153 lib/base/file.rb
dev-2.1.152 lib/base/file.rb
dev-2.1.151 lib/base/file.rb
dev-2.1.150 lib/base/file.rb
dev-2.1.149 lib/base/file.rb
dev-2.1.148 lib/base/file.rb
dev-2.1.147 lib/base/file.rb
dev-2.1.146 lib/base/file.rb
dev-2.1.145 lib/base/file.rb
dev-2.1.144 lib/base/file.rb
dev-2.1.143 lib/base/file.rb
dev-2.1.142 lib/base/file.rb
dev-2.1.141 lib/base/file.rb