Can I ask for co-authorship if I share code and am willing to help applying code to the problem? Recently I have been asked to share some source code I have written
with another PhD student. I have developed and used the methods in
that source code for the purposes of my own research. The code will
save her approximately 2 months of development/testing. I'm prepared
also to offer additional help with data pre/post-processing &amp; writing.

Given the above, am I entitled to ask for co-authorship?
You can discuss with her and her advisor whether your help warrants authorship, but it would be rather unhelpful to refuse her even if she or her advisor declines.  I would say, if this is true, (1) Sure!  I'd love for more good research to come from my work! and (2) Since my project isn't published yet, we'll need to include a good description in the methods and it probably makes sense for me to be a coauthor.

If the target journal particularly advocates open-data and open-access, you might have to release your work in order for them to get it published.  It's important to talk through first to make sure everyone's okay with that.  In general it's a fantastic idea since it means that work is not so difficult to replicate, and if you have a valuable tool maybe others will benefit from it.  But when you're laboring to finish your own work in time and worried about its perceived novelty, it can seem a little less appealing.

Just have the discussion (in a friendly manner) now so there aren't any unpleasant surprises later.