Class: Ploy::Package
- Inherits:
-
Object
- Object
- Ploy::Package
- Defined in:
- lib/ploy/package.rb
Instance Attribute Summary collapse
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#deploy_name ⇒ Object
Returns the value of attribute deploy_name.
-
#updatevia ⇒ Object
Returns the value of attribute updatevia.
-
#variant ⇒ Object
Returns the value of attribute variant.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #bless(variant = "blessed") ⇒ Object
- #blessed(variant = "blessed") ⇒ Object
- #check_new_version ⇒ Object
-
#initialize(bucket, deploy, branch, version, variant = nil, updatevia = nil) ⇒ Package
constructor
A new instance of Package.
- #install ⇒ Object
- #installed_version ⇒ Object
- #location ⇒ Object
- #location_current ⇒ Object
- #make_current ⇒ Object
- #remote_version ⇒ Object
- #upload(path) ⇒ Object
Constructor Details
#initialize(bucket, deploy, branch, version, variant = nil, updatevia = 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, updatevia = nil) @bucket = bucket @deploy_name = deploy @branch = branch @version = version @variant = variant @updatevia = 'ploy' unless updatevia.nil? @updatevia = updatevia end @store = Ploy::S3Storage.new(bucket) end |
Instance Attribute Details
#branch ⇒ Object
Returns the value of attribute branch.
7 8 9 |
# File 'lib/ploy/package.rb', line 7 def branch @branch end |
#deploy_name ⇒ Object
Returns the value of attribute deploy_name.
6 7 8 |
# File 'lib/ploy/package.rb', line 6 def deploy_name @deploy_name end |
#updatevia ⇒ Object
Returns the value of attribute updatevia.
10 11 12 |
# File 'lib/ploy/package.rb', line 10 def updatevia @updatevia end |
#variant ⇒ Object
Returns the value of attribute variant.
9 10 11 |
# File 'lib/ploy/package.rb', line 9 def variant @variant end |
#version ⇒ Object
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
77 78 79 80 81 82 83 |
# File 'lib/ploy/package.rb', line 77 def self.(bucket, ) out = [] .each do |k,v| out.push(self.new(bucket, v['name'], v['branch'], v['sha'], v['variant'])) end return out end |
Instance Method Details
#bless(variant = "blessed") ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/ploy/package.rb', line 53 def bless(variant="blessed") b = self.blessed(variant) @store.copy( location, b.location ) return b end |
#blessed(variant = "blessed") ⇒ Object
49 50 51 |
# File 'lib/ploy/package.rb', line 49 def blessed(variant="blessed") return Ploy::Package.new(@bucket, @deploy_name, @branch, @version, variant) end |
#check_new_version ⇒ Object
26 27 28 |
# File 'lib/ploy/package.rb', line 26 def check_new_version return (installed_version != remote_version) end |
#install ⇒ Object
42 43 44 45 46 47 |
# File 'lib/ploy/package.rb', line 42 def install Tempfile.open(['ploy', '.deb']) do |f| @store.get(location, f) system("dpkg -i #{f.path}") end end |
#installed_version ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/ploy/package.rb', line 30 def installed_version version = `dpkg-query -W -f '${gitrev}' #{@deploy_name}`.chomp if version =~ /no packages found/i version = '' end return version end |
#location ⇒ Object
62 63 64 |
# File 'lib/ploy/package.rb', line 62 def location return Ploy::Util.remote_name(@deploy_name, @branch, @version, @variant) end |
#location_current ⇒ Object
65 66 67 |
# File 'lib/ploy/package.rb', line 65 def location_current return Ploy::Util.remote_name(@deploy_name, @branch, 'current', @variant) end |
#make_current ⇒ Object
73 74 75 |
# File 'lib/ploy/package.rb', line 73 def make_current @store.copy(location, location_current) end |
#remote_version ⇒ Object
38 39 40 |
# File 'lib/ploy/package.rb', line 38 def remote_version return @store.(location)['git_revision'] end |
#upload(path) ⇒ Object
69 70 71 |
# File 'lib/ploy/package.rb', line 69 def upload(path) @store.put(path, location, {'git_revision' => @version}) end |