From inside the directory, run ruby test_database.rb
Two options:
-
Straight from command line (does not work)
- Navigate to directory
- Run
sh setup.sh
- type database commands like:
- SET Hello World
- GET Hello
- DELETE Hello
- WARNING: I was attempting, with this maneuver, to replicate exactly the input and output mechanism delineated in the prompt. However, the database does not hold state by this method. I messed with it for about 20 minutes, then decided that you're probably more interested in my database implementation than the exact input mechanism, and I moved on.
-
Via irb
- Navigate to directory
- Type
irb
- Type
load 'database.rb'
- Instantiate database via, for example
db = Database.instance
- Call methods on the
db
instance - All method names are the lower case version of what is described in the prompt. For example,
db.begin
,db.commit
,db.end
- I attempted to name these methods exactly as described in the prompt (removing the database object and having a file full of methods named things like BEGIN, DELETE, COMMIT), but it turns out a few of these are keywords in ruby. I'm not in the business of bogarting ruby keywords to make my databases, so I left it as an object.
Here is a screenshot of my irb console demonstrating the database at work:
Here is a screenshot of deletion inside a transaction: