Class: Glitter::Release::Base
- Inherits:
-
Object
- Object
- Glitter::Release::Base
- Defined in:
- lib/glitter/release.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#assets ⇒ Object
Registry of assets that are S3 objects.
-
#head ⇒ Object
Promote the release as the head releae.
-
#initialize(channel, version, logger = Logger.new($stdout), &block) ⇒ Base
constructor
Initialize a release and yield the block for configuration.
-
#push(opts = {}) ⇒ Object
Push assets up to the S3 bucket path ‘/:channel/:version/*`.
Constructor Details
#initialize(channel, version, logger = Logger.new($stdout), &block) ⇒ Base
Initialize a release and yield the block for configuration.
17 18 19 20 21 |
# File 'lib/glitter/release.rb', line 17 def initialize(channel, version, logger = Logger.new($stdout), &block) @channel, @version, @logger = channel, version, logger block.call self if block_given? self end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
14 15 16 |
# File 'lib/glitter/release.rb', line 14 def channel @channel end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
14 15 16 |
# File 'lib/glitter/release.rb', line 14 def logger @logger end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
14 15 16 |
# File 'lib/glitter/release.rb', line 14 def version @version end |
Instance Method Details
#assets ⇒ Object
Registry of assets that are S3 objects. The key is ‘/:channel/:version/:object-key`. The hash returns an S3 object.
53 54 55 |
# File 'lib/glitter/release.rb', line 53 def assets @assets ||= Hash.new { |h,k| h[k] = channel.server.bucket.objects.build object_key(k) } # /win-dev/1.1/appcast.xml end |
#head ⇒ Object
Promote the release as the head releae. This copies the contents of the release to ‘/:channel/*`.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/glitter/release.rb', line 41 def head logger.info "Promoting version #{version} to HEAD" assets.map do |_, object| channel, _, key = Release.object_segments(object.key) object = object.copy :key => File.join(channel, key) logger.info " Copying #{key} to #{object.url}" object.save end logger.info "Version #{version} promoted to HEAD!" end |
#push(opts = {}) ⇒ Object
Push assets up to the S3 bucket path ‘/:channel/:version/*`.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/glitter/release.rb', line 24 def push(opts={}) if !opts[:force] and version_exists? raise ExistingReleaseError.new("Existing build at version #{version}. Increment the version and push again.") end logger.warn "Forced push" if opts[:force] logger.info "Pushing version #{version} to #{channel.name}" assets.each do |key, object| logger.info " PUT #{key} to #{object.url}" object.save end logger.info "Version #{version} to #{channel.name} pushed!" self end |