lib/glitter.rb in glitter-0.0.4 vs lib/glitter.rb in glitter-0.0.5
- old
+ new
@@ -101,27 +101,26 @@
def appcast
@appcast ||= Appcast.new(self)
end
- def head
- releases[version]
+ def latest
+ assets[version]
end
- def releases
- @releases ||= Hash.new do |hash,key|
- hash[key] = Release.new do |r|
+ def assets
+ @assets ||= Hash.new do |hash,key|
+ hash[key] = Asset.new do |r|
r.version = key
r.app = self
end
end
end
end
- class Release
- attr_accessor :app, :version, :notes, :published_at
- attr_reader :object
+ class Asset
+ attr_accessor :app, :version, :notes, :published_at, :object
def initialize
@published_at = Time.now
yield self if block_given?
end
@@ -143,12 +142,23 @@
end
def push
object.content = file
object.save
+ self
end
+ # Sets this asset as the head on the S3 bucket
+ def head
+ @head ||= self.class.new do |a|
+ a.app = app
+ a.version = "head"
+ a.published_at = published_at
+ a.object = object.copy(:key => a.object_name)
+ end
+ end
+
def file
File.new(app.archive)
end
end
@@ -165,14 +175,18 @@
end
desc "push", "pushes a build to S3 with release notes."
method_option :release_notes, :type => :string, :aliases => "-m"
def push
- puts "Pushing app #{app.head.object_name}"
- app.head.notes = options[:release_notes]
- app.head.push
- app.appcast.push
- puts "App pushed to #{app.head.url}"
+ puts "Pushing app #{app.latest.object_name}"
+
+ app.latest.notes = options[:release_notes]
+ app.latest.push
+ puts "Asset pushed to #{app.latest.url}"
+
+ app.latest.head
+ puts "Updated head #{app.latest.head.url} to #{app.latest.url}"
+
puts "Updated #{app.appcast.url}"
end
private
def app
\ No newline at end of file