Sha256: eff4e25a7179e5640c6b82f830f7301d51eee9c07efd900e6247bb1c9a5b0161
Contents?: true
Size: 1.8 KB
Versions: 1
Compression:
Stored size: 1.8 KB
Contents
class Environment < Hash def initialize self[:home]=Environment.home self[:machine]=Environment.machine self[:user]=Environment.user end def self.home ["USERPROFILE","HOME"].each {|v| return ENV[v].gsub('\\','/') unless ENV[v].nil? } dir="~" dir=ENV["HOME"] unless ENV["HOME"].nil? dir=ENV["USERPROFILE"].gsub('\\','/') unless ENV["USERPROFILE"].nil? return dir end def self.machine if !ENV['COMPUTERNAME'].nil? return ENV['COMPUTERNAME'] end machine = `hostname` machine = machine.split('.')[0] if machine.include?('.') return machine.strip end def self.user return ENV['USER'] if !ENV['USER'].nil? #on Unix ENV['USERNAME'] end def self.dev_root ["DEV_HOME","DEV_ROOT"].each {|v| return ENV[v].gsub('\\','/') unless ENV[v].nil? } dir=home return dir end end 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='**/*' output = "\n" # directory FileUtils.mkdir_p destination if !File.exists? destination files=nil Dir.chdir(source_dir) do files=FileList.new(source_glob).to_a 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 } end output end end class File def self.amalgamate filename,source File.open(filename,'w'){|file| source.each{|source_file| file.puts IO.read(source_file) } } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dev-2.0.96 | lib/dev_environment.rb |