Module: Depends::Util

Defined in:
lib/depends/util.rb

Class Method Summary collapse

Class Method Details

.depends_source(source) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/depends/util.rb', line 24

def self.depends_source(source)
  source = source.downcase.to_sym if source.is_a? String
  case source
    when :local
      "http://localhost:8080"
    when :depends
      "https://depends.cloudfoundry.com/"
    else
      source
  end
end

.un_zip(source, destination, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/depends/util.rb', line 6

def self.un_zip(source,destination, options = {})
  options.reverse_merge!({:overwrite => true})
  Log.debug "Opening #{source}"
  Zip::ZipFile.open(source) do |zip|
    zip.each do |entry|
      Log.debug (":entry => #{entry.name}")
      path = ::File.join(destination, entry.name)
      FileUtils.mkdir_p(::File.dirname(path))
      if options[:overwrite] && ::File.exists?(path) && !::File.directory?(path)
        Log.debug("Removing #{path}")
        FileUtils.rm(path)
      end
      zip.extract(entry, path)
    end
  end

end