Sha256: 64ba8e9bc3a9907eea6d61089be24f0fdb2edd792655771a69be44301dce875a

Contents?: true

Size: 1.15 KB

Versions: 18

Compression:

Stored size: 1.15 KB

Contents

puts_debug "read " + __FILE__.foreground(:green)

module Dev

class Environment
   def self.replace_text_in_glob(glob,search,replace)
     Dir.glob(glob).each{ |f| replace_text_in_file(f,search,replace) }
   end
   
   def self.replace_text_in_file(filename,search,replace)
     text1 = File.read(filename)
     text2 = text1.gsub(search) { |str| str=replace }
     unless text1==text2
       File.open(filename,"w") { |f| f.puts text2 }
       puts "  replaced text in #{filename}"
     end
   end
   
   def self.dev_root
     dir="~"
     dir=ENV["HOME"] unless ENV["HOME"].nil?
     dir=ENV["USERPROFILE"].gsub('\\','/') unless ENV["USERPROFILE"].nil?
     dir=ENV["DEV_ROOT"].gsub('\\','/') unless ENV["DEV_ROOT"].nil?
     return dir
   end
   
   def self.expand_string_variables(str)
     eval("\"#{str.gsub('"','\"')}\"")
   end
   
   def self.s_to_hash(str)
      # check for hash
      hash=nil
      if(str.strip.index('{')==0 && str.strip.index('}')==str.strip.length-1)
        begin
          eval("hash=#{str.strip}")
        rescue
          hash=nil
        end
      end
      hash
   end
end

end # module Dev

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
dev-1.0.41 lib/dev/Environment.rb
dev-1.0.40 lib/dev/Environment.rb
dev-1.0.39 lib/dev/Environment.rb
dev-1.0.38 lib/dev/Environment.rb
dev-1.0.37 lib/dev/Environment.rb
dev-1.0.36 lib/dev/Environment.rb
dev-1.0.35 lib/dev/Environment.rb
dev-1.0.34 lib/dev/Environment.rb
dev-1.0.33 lib/dev/Environment.rb
dev-1.0.32 lib/dev/Environment.rb
dev-1.0.31 lib/dev/Environment.rb
dev-1.0.30 lib/dev/Environment.rb
dev-1.0.29 lib/dev/Environment.rb
dev-1.0.27 lib/dev/Environment.rb
dev-1.0.26 lib/dev/Environment.rb
dev-1.0.25 lib/dev/Environment.rb
dev-1.0.24 lib/dev/Environment.rb
dev-1.0.23 lib/dev/Environment.rb