Class: MongoTestServer::RamDiskStorage
- Inherits:
-
Object
- Object
- MongoTestServer::RamDiskStorage
- Defined in:
- lib/mongo_test_server/ram_disk_storage.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
-
#initialize(name) ⇒ RamDiskStorage
constructor
A new instance of RamDiskStorage.
- #path ⇒ Object
Constructor Details
#initialize(name) ⇒ RamDiskStorage
Returns a new instance of RamDiskStorage.
13 14 15 16 |
# File 'lib/mongo_test_server/ram_disk_storage.rb', line 13 def initialize(name) @name = "#{name}-mongo-ram-disk" @path = "/Volumes/#{@name}" end |
Class Method Details
.supported? ⇒ Boolean
8 9 10 |
# File 'lib/mongo_test_server/ram_disk_storage.rb', line 8 def supported? `which hdiutil`!='' end |
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/mongo_test_server/ram_disk_storage.rb', line 18 def create @ram_disk_device ||= lambda { device = `hdiutil attach -nomount ram://1000000`.chomp `diskutil erasevolume HFS+ #{@name} #{device}` device }.call path end |
#delete ⇒ Object
31 32 33 34 |
# File 'lib/mongo_test_server/ram_disk_storage.rb', line 31 def delete `umount #{path} 2> /dev/null` `hdiutil detach #{@ram_disk_device} 2> /dev/null` end |
#path ⇒ Object
27 28 29 |
# File 'lib/mongo_test_server/ram_disk_storage.rb', line 27 def path @path end |