title: Ruby Gems with Persistent data
body: <p>I want to create ruby application (not rails). This is a console app which will need to persist some data. I'm using pstore as the database. I want to deploy this application as a gem.</p>
  
  <p>My question is: where does my data live? </p>
  
  <p>Currently I've created a data directory as a sibling to the bin directory in a standard gem layout. I would therefore, expect that the gem would be storing its data "inside itself" after it gets deployed. But when I do a local gem install to test, I find that the data is being stored locally to the project files, not somewhere inside the gems directory.</p>
  
  <p>Of course it could be I simply mis-understand what "rake install_gem" is doing. Also, I am vaguely worried that if I need to sudo to install the gem, that it will actually be able to create the data file "inside itself" in the gem directory.</p>
  
  <p>Can someone clarify this a little bit?</p>
  
  <p>Thank you.
  John Schank </p>
  
  <p>@makevoid - thanks for the reply. Here is the entirety of my main script. In /bin directory... (I added it to the main question because I'm not familiar with how to format content in a comment - and the pasted code looked awful.</p>
  
  <pre><code>#!/usr/bin/env ruby
  
  $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
  
  require 'timesheet'
  
  begin
    command_hash = TimesheetParser.parse
    store = YAML::Store.new("data/time_entries.yaml")
    tl = TimeLog.new(store)
    ts = Timesheet.new(tl)
    ts.process(command_hash)
  rescue Exception =&gt; e
    raise if command_hash[:debug]
    puts e.message
  </code></pre>