lib/heirloom/artifact/artifact_builder.rb in heirloom-0.1.0 vs lib/heirloom/artifact/artifact_builder.rb in heirloom-0.1.1
- old
+ new
@@ -11,20 +11,38 @@
end
def build(args)
@name = args[:name]
@id = args[:id]
- @public = args[:public]
- @git_directory = GitDirectory.new :directory => args[:directory],
- :logger => @logger
-
- @commit = @git_directory.commit @id
+ @exclude = args[:exclude]
+ directory = args[:directory] ||= '.'
+
+ @directory = Directory.new :directory => directory,
+ :exclude => @exclude,
+ :logger => @logger
+
+ @local_build = @directory.build_artifact_from_directory
+
create_artifact_record
- @git_directory.build_artifact_from_directory
+
+ if args[:git]
+ git_directory = GitDirectory.new :directory => directory,
+ :logger => @logger
+ @logger.info "Adding git commit to attributes."
+ @commit = git_directory.commit @id
+ add_git_commit_to_artifact_record
+ end
+
+ @local_build
end
+ def cleanup
+ @logger.info "Cleaning up local build #{@local_build}."
+ File.delete @local_build
+ end
+
private
def create_artifact_domain
@logger.info "Verifying artifact domain #{@name} exists."
sdb.create_domain @name
@@ -32,13 +50,24 @@
def create_artifact_record
create_artifact_domain
attributes = { 'built_by' => "#{user}@#{hostname}",
'built_at' => Time.now.utc.iso8601,
- 'sha' => @id,
+ 'id' => @id }
+ @logger.info "Create artifact record #{@id}"
+ sdb.put_attributes @name, @id, attributes
+ end
+
+ def add_git_commit_to_artifact_record
+ attributes = { 'sha' => @id,
'abbreviated_sha' => @commit.id_abbrev,
'message' => @commit.message,
'author' => @commit.author.name }
+ @logger.info "Git sha: #{@id}"
+ @logger.info "Git abbreviated_sha: #{@commit.id_abbrev}"
+ @logger.info "Git message: #{@commit.message}"
+ @logger.info "Git author: #{@commit.author.name}"
+
sdb.put_attributes @name, @id, attributes
end
def sdb
@sdb ||= AWS::SimpleDB.new :config => @config