Class: Cloud::Deploy::Artifact

Inherits:
Object
  • Object
show all
Defined in:
lib/cloud/deploy/artifact.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeArtifact

Returns a new instance of Artifact.



31
32
33
# File 'lib/cloud/deploy/artifact.rb', line 31

def initialize
  @use_etags = true
end

Instance Attribute Details

#forceObject

Returns the value of attribute force.



29
30
31
# File 'lib/cloud/deploy/artifact.rb', line 29

def force
  @force
end

#local_pathsObject

Returns the value of attribute local_paths.



29
30
31
# File 'lib/cloud/deploy/artifact.rb', line 29

def local_paths
  @local_paths
end

#nameObject

Returns the value of attribute name.



29
30
31
# File 'lib/cloud/deploy/artifact.rb', line 29

def name
  @name
end

#unzipObject

Returns the value of attribute unzip.



29
30
31
# File 'lib/cloud/deploy/artifact.rb', line 29

def unzip
  @unzip
end

#uriObject

Returns the value of attribute uri.



28
29
30
# File 'lib/cloud/deploy/artifact.rb', line 28

def uri
  @uri
end

#use_etagsObject

Returns the value of attribute use_etags.



29
30
31
# File 'lib/cloud/deploy/artifact.rb', line 29

def use_etags
  @use_etags
end

Instance Method Details

#deploy!Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/cloud/deploy/artifact.rb', line 44

def deploy!
  load_md5sums do |md5sums|
    hash = md5sums[@name]
    if !@force and !hash.nil? and hash == @hash
      $log.info(@name) { "MD5 sums match. No need to deploy." }
    else
      @local_paths.each do |path|
        FileUtils.mkdir_p(path)
        if @unzip
          $log.info(@name) { "Unzipping #{@name} to #{path}" }
          if @uri.request_uri[-6..-1] == "tar.gz"
            `tar -zxf #{@temp_file} -C #{path}`
          else
            `unzip -o -d #{path} #{@temp_file}`
          end
        else
          $log.info(@name) { "Copying #{@name} to #{path}" }
          FileUtils.cp(@temp_file, path)
        end
      end
      md5sums[@name] = @hash
      save_md5sums(md5sums)
    end
    # Clean up temp file
    if !@temp_file.nil?
      FileUtils.rm(@temp_file)
    end
    # We did a deployment
    return true
  end
  # Default return
  return false
end

#outdated?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/cloud/deploy/artifact.rb', line 40

def outdated?
  download
end