# I want to associate a file type with my Ruby script

**URL:** <https://www.ruby-forum.com/t/i-want-to-associate-a-file-type-with-my-ruby-script/216017>\
**Category:** Ruby-Gnome 2\
**Created:** [January 22, 2012, 10:16pm UTC](https://www.ruby-forum.com/t/i-want-to-associate-a-file-type-with-my-ruby-script/216017 "2012-01-22T22:16:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [January 22, 2012, 10:16pm UTC](https://www.ruby-forum.com/t/i-want-to-associate-a-file-type-with-my-ruby-script/216017/1 "2012-01-22T22:16:11Z")

</div>

Hi:

I’m writing a Ruby IDE. It opens a directory as a “project” and  
displays all the .rb files so you can edit them. I want to save all the  
settings for my IDE in a yaml file. It would be called  
MyProjectName.vr\_settings. This yaml file will hold all the info for  
this project:

path to project  
main program to run  
etc.

I want to make it so when the user clicks on the  
MyProjectName.vr\_settings file, my IDE opens and loads that project.  
How do you do this?

I would like to make a unique extension like “.vr\_settings” so I can be  
sure that I’m not interfering with other file types.

Also, I want the program to edit the operating systems files when the  
IDE runs for the first time. Many programs establish a file association  
when they install. I want to create that same set-up.

I would also welcome opinions on the best way to handle projects. Right  
now my IDE has one big settings file with all the projects in it. I  
think opening a single project is a better solution because Ubuntu has  
its own tabbing system: When you open a second project, a second  
instance of my IDE would appear in Ubuntu’s tabs.

For example, I’m writing my IDE and a supporting library right now. Its  
a big hassle to switch back and forth between the projects because it  
swaps the whole project each time.

Thanks!

---

<div class="post-metadata">

**Author:** ![ericrchr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/8baadc/32.png) [@ericrchr](https://www.ruby-forum.com/u/ericrchr)\
**Post date:** [January 23, 2012, 11:19am UTC](https://www.ruby-forum.com/t/i-want-to-associate-a-file-type-with-my-ruby-script/216017/2 "2012-01-23T11:19:42Z")

</div>

Eric C. wrote in post #1042074:

> Hi:  
> I want to make it so when the user clicks on the  
> MyProjectName.vr\_settings file, my IDE opens and loads that project.  
> How do you do this?

That’s totally unrelated to ruby.  
However, take a look at fdo specification :

> **[shared-mime-info-spec](https://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec/)**

> **[desktop-entry-spec](https://www.freedesktop.org/wiki/Specifications/desktop-entry-spec/)**

Under windows, I have no idea.

> I would also welcome opinions on the best way to handle projects. Right  
> now my IDE has one big settings file with all the projects in it. I  
> think opening a single project is a better solution because Ubuntu has  
> its own tabbing system: When you open a second project, a second  
> instance of my IDE would appear in Ubuntu’s tabs.

AFAIK, it’s not ubuntu, but Unity which does this. And I have no idea  
how Unity manages programs tabs.

Simon

---

<div class="post-metadata">

**Author:** ![ericrchr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/8baadc/32.png) [@ericrchr](https://www.ruby-forum.com/u/ericrchr)\
**Post date:** [January 24, 2012, 6:16am UTC](https://www.ruby-forum.com/t/i-want-to-associate-a-file-type-with-my-ruby-script/216017/3 "2012-01-24T06:16:39Z")

</div>

Thnaks Simon!

You led to to the right place. The solution I found was that you don’t  
need to create a mime type to make a file “double-clickable” I settled  
on the solution of creating launchers from my ruby script, and putting  
them on the desktop.

My most current scheme:

My IDE uses a top folder as the name of the project, so to run my IDE,  
you use the command line with the path to the root folder as the  
parameter:

$vr /home/eric/myproject

This would be annoying to type each time, so I’m going to make my  
program export “launchers” to the desktop. So when the user clicks on  
the launcher, the above statement would execute.

As the user opens multiple projects, tabs appear at the bottom of  
ubuntu’s desktop. So to switch between projects, the user would click  
on a tab.

This will save me a lot of work integrating multiple projects into my  
IDE.

Thanks.
