Sha256: ab66c03be09e143555d9da4895f69ad824ab6489704d6d3c3db9f05887ff44c8
Contents?: true
Size: 1.63 KB
Versions: 12
Compression:
Stored size: 1.63 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
Version data entries
12 entries across 12 versions & 1 rubygems