Sha256: d877b556632e6d97b911121703a802402552ef5a5c35a7bd313d5e36b6143c01
Contents?: true
Size: 1.53 KB
Versions: 4
Compression:
Stored size: 1.53 KB
Contents
=begin = mockbucket.rb *Copyright*:: (C) 2013 by Novu, LLC *Author(s)*:: Tamara Temple <tamara.temple@novu.com> *Since*:: 2013-05-14 *License*:: GPLv3 *Version*:: 0.0.1 == Description =end class MockFile attr_accessor :name, :last_modified, :key, :directory def initialize(n,d,dir) self.name = n.dup self.key = self.name self.last_modified = d.dup self.directory = dir end def destroy self.name = nil self.key = nil self.last_modified = nil end end class MockBucket attr_accessor :bucket_contents, :name, :key def initialize(n=1, name) self.bucket_contents = (1..n).to_a.map{|i| MockFile.new("file-#{i}", Time.new(2012, 6, (i+1), 0, 0, 0), self) } self.name = name.dup self.key = self.name end def files self end def create(options={}) self.bucket_contents << MockFile.new(options[:key], Time.now, self) end def all(options={}) @bucket_contents.reject {|f| f.name.nil?} end end class MockConnection attr_accessor :bucket_list, :name, :key def initialize(n=1, name) self.name = name.dup self.key = self.name if n > 0 self.bucket_list = (1..n).to_a.map{|i| MockBucket.new(10, "bucket-#{i}")} else self.bucket_list = [] end end def directories @bucket_list end def get(name) @bucket_list.select {|bucket| bucket.name == name}.first end def create(name) @bucket_list << MockBucket.new(10, name) end def destroy(name) @bucket_list.reject! {|bucket| bucket.name == name} end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
new_backup-1.0.4 | spec/mockbucket.rb |
new_backup-1.0.3 | spec/mockbucket.rb |
new_backup-1.0.2 | spec/mockbucket.rb |
new_backup-1.0.1 | spec/mockbucket.rb |