Class: Ploy::Package

Inherits:
Object
  • Object
show all
Defined in:
lib/ploy/package.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bucket, deploy, branch, version, variant = nil, deployvia = nil) ⇒ Package

Returns a new instance of Package.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ploy/package.rb', line 12

def initialize(bucket, deploy, branch, version, variant = nil, deployvia = nil)
  @bucket = bucket
  @deploy_name = deploy
  @branch = branch
  @version = version
  @variant = variant
  @deployvia = 'ploy-install'
  unless deployvia.nil?
    @deployvia = deployvia
  end

  @store = Ploy::S3Storage.new(bucket)
end

Instance Attribute Details

#branchObject

Returns the value of attribute branch.



7
8
9
# File 'lib/ploy/package.rb', line 7

def branch
  @branch
end

#deploy_nameObject

Returns the value of attribute deploy_name.



6
7
8
# File 'lib/ploy/package.rb', line 6

def deploy_name
  @deploy_name
end

#deployviaObject

Returns the value of attribute deployvia.



10
11
12
# File 'lib/ploy/package.rb', line 10

def deployvia
  @deployvia
end

#variantObject

Returns the value of attribute variant.



9
10
11
# File 'lib/ploy/package.rb', line 9

def variant
  @variant
end

#versionObject

Returns the value of attribute version.



8
9
10
# File 'lib/ploy/package.rb', line 8

def version
  @version
end

Class Method Details

.from_metadata(bucket, meta) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/ploy/package.rb', line 73

def self.(bucket, meta)
  out = []
  meta.each do |k,v|
    out.push(self.new(bucket, v['name'], v['branch'], v['sha'], v['variant']))
  end
  return out
end

Instance Method Details

#blessObject



49
50
51
52
53
54
55
56
# File 'lib/ploy/package.rb', line 49

def bless
  b = self.blessed
  @store.copy(
    location,
    b.location
  )
  return b
end

#blessedObject



45
46
47
# File 'lib/ploy/package.rb', line 45

def blessed
  return Ploy::Package.new(@bucket, @deploy_name, @branch, @version, "blessed")
end

#check_new_versionObject



26
27
28
# File 'lib/ploy/package.rb', line 26

def check_new_version
  return (installed_version != remote_version)
end

#installObject



38
39
40
41
42
43
# File 'lib/ploy/package.rb', line 38

def install
  Tempfile.open(['ploy', '.deb']) do |f|
    @store.get(location, f)
    system("dpkg -i #{f.path}")
  end
end

#installed_versionObject



30
31
32
# File 'lib/ploy/package.rb', line 30

def installed_version
  return `dpkg-query -W -f '${gitrev}' #{@deploy_name}`.chomp
end

#locationObject



58
59
60
# File 'lib/ploy/package.rb', line 58

def location
  return Ploy::Util.remote_name(@deploy_name, @branch, @version, @variant)
end

#location_currentObject



61
62
63
# File 'lib/ploy/package.rb', line 61

def location_current
  return Ploy::Util.remote_name(@deploy_name, @branch, 'current', @variant)
end

#make_currentObject



69
70
71
# File 'lib/ploy/package.rb', line 69

def make_current
  @store.copy(location, location_current)
end

#remote_versionObject



34
35
36
# File 'lib/ploy/package.rb', line 34

def remote_version
  return @store.(location)['git_revision']
end

#upload(path) ⇒ Object



65
66
67
# File 'lib/ploy/package.rb', line 65

def upload(path)
  @store.put(path, location, {'git_revision' => @version})
end