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.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #bless ⇒ Object
- #check_new_version ⇒ Object
-
#initialize(bucket, deploy, branch, version) ⇒ Package
constructor
A new instance of Package.
- #install ⇒ Object
- #location ⇒ Object
- #location_current ⇒ Object
- #make_current ⇒ Object
- #upload(path) ⇒ Object
Constructor Details
#initialize(bucket, deploy, branch, version) ⇒ Package
Returns a new instance of Package.
10 11 12 13 14 15 16 |
# File 'lib/ploy/package.rb', line 10 def initialize(bucket, deploy, branch, version) @deploy_name = deploy @branch = branch @version = version @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 |
#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
53 54 55 56 57 58 59 |
# File 'lib/ploy/package.rb', line 53 def self.(bucket, ) out = [] .each do |k,v| out.push(self.new(bucket, v['name'], v['branch'], v['sha'])) end return out end |
Instance Method Details
#bless ⇒ Object
31 32 33 34 35 36 |
# File 'lib/ploy/package.rb', line 31 def bless @store.copy( location, Ploy::Util.remote_name(@deploy_name, @branch, @version, true) ) end |
#check_new_version ⇒ Object
18 19 20 21 22 |
# File 'lib/ploy/package.rb', line 18 def check_new_version installed = `dpkg-query -W -f '${gitrev}' #{@deploy_name}`.chomp remote_v = @store.(location)['git_revision'] return (installed != remote_v) end |
#install ⇒ Object
24 25 26 27 28 29 |
# File 'lib/ploy/package.rb', line 24 def install Tempfile.open(['ploy', '.deb']) do |f| @store.get(location, f) system("dpkg -i #{f.path}") end end |
#location ⇒ Object
38 39 40 |
# File 'lib/ploy/package.rb', line 38 def location return Ploy::Util.remote_name(@deploy_name, @branch, @version) end |
#location_current ⇒ Object
41 42 43 |
# File 'lib/ploy/package.rb', line 41 def location_current return Ploy::Util.remote_name(@deploy_name, @branch, 'current') end |
#make_current ⇒ Object
49 50 51 |
# File 'lib/ploy/package.rb', line 49 def make_current @store.copy(location, location_current) end |
#upload(path) ⇒ Object
45 46 47 |
# File 'lib/ploy/package.rb', line 45 def upload(path) @store.put(path, location, {'git_revision' => @version}) end |