Sha256: 931d346d9114fab6698cd4a3574d52d3cb21d6cbc87ed5fc9ad54316359a42ce

Contents?: true

Size: 1.49 KB

Versions: 17

Compression:

Stored size: 1.49 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?

     reg_exp = /(\/(wrk|dep)\/[.\w\d-]+\/[.\w\d-]+\/[.\w\d-@]+)/
     unless(Rake.original_dir().match(reg_exp).nil?)
       wrk_rel = Rake.original_dir().match(reg_exp)[1] if Rake.original_dir().match(reg_exp).length > 0
       if(!wrk_rel.nil? && wrk_rel.length > 0)
         dir = Rake.original_dir().gsub(wrk_rel,"");
       end
     end
     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

17 entries across 17 versions & 1 rubygems

Version Path
dev-1.0.61 lib/dev/Environment.rb
dev-1.0.60 lib/dev/Environment.rb
dev-1.0.59 lib/dev/Environment.rb
dev-1.0.58 lib/dev/Environment.rb
dev-1.0.57 lib/dev/Environment.rb
dev-1.0.56 lib/dev/Environment.rb
dev-1.0.55 lib/dev/Environment.rb
dev-1.0.54 lib/dev/Environment.rb
dev-1.0.53 lib/dev/Environment.rb
dev-1.0.52 lib/dev/Environment.rb
dev-1.0.51 lib/dev/Environment.rb
dev-1.0.50 lib/dev/Environment.rb
dev-1.0.49 lib/dev/Environment.rb
dev-1.0.48 lib/dev/Environment.rb
dev-1.0.47 lib/dev/Environment.rb
dev-1.0.46 lib/dev/Environment.rb
dev-1.0.45 lib/dev/Environment.rb