lib/heirloom/artifact/artifact_reader.rb in heirloom-0.1.3 vs lib/heirloom/artifact/artifact_reader.rb in heirloom-0.1.4

- old
+ new

@@ -1,41 +1,38 @@ module Heirloom class ArtifactReader + attr_accessor :config, :id, :name + def initialize(args) - @config = args[:config] + self.config = args[:config] + self.name = args[:name] + self.id = args[:id] end - def show(args) - domain = args[:name] - id = args[:id] - items = sdb.select "select * from #{domain} where itemName() = '#{id}'" - items[id] + def show + items = sdb.select "select * from #{name} where itemName() = '#{id}'" + items[@id] end - def exists?(args) - show(args) != nil + def exists? + show != nil end def get_bucket(args) - artifact = show :name => args[:name], - :id => args[:id] - - url = artifact["#{args[:region]}-s3-url"].first - - bucket = url.gsub('s3://', '').split('/').first + get_url(args).gsub('s3://', '').split('/').first end def get_key(args) - artifact = show :name => args[:name], - :id => args[:id] - - url = artifact["#{args[:region]}-s3-url"].first - - bucket = url.gsub('s3://', '').gsub(get_bucket(args), '') + bucket_path = get_bucket :region => args[:region] + bucket = get_url(args).gsub('s3://', '').gsub(bucket_path, '') bucket.slice!(0) bucket + end + + def get_url(args) + show["#{args[:region]}-s3-url"].first end private def sdb