|
View:
New views
10 Messages
—
Rating Filter:
Alert me
|
|
|
How to get the FileObject of the root directory of an opened Ruby on Rails project?Hi,
I`m developing a Netbeans module for Ruby on Rails development. My module is implemented as a RubyAstRule. In order to work correctly, my module needs to open the YAML file of the Ruby on Rails project. I thought of using org.netbeans.modules.ruby.platform.execution.DirectoryFileLocator in my module to find the YAML file that contains the database connection information. The constructor of the DirectoryFileLocator claims for a FileObject that points to the root directory. How do I get that FileObject pointer that points to the root directory of the opened Ruby on Rails Project? Thanks, Philipp Marcus --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: How to get the FileObject of the root directory of an opened Ruby on Rails project?Philipp Marcus wrote:
> Hi, > > I`m developing a Netbeans module for Ruby on Rails development. My > module is implemented as a RubyAstRule. In order to work correctly, my > module needs to open the YAML file of the Ruby on Rails project. I > thought of using > org.netbeans.modules.ruby.platform.execution.DirectoryFileLocator in my > module to find the YAML file that contains the database connection > information. The constructor of the DirectoryFileLocator claims for a > FileObject that points to the root directory. How do I get that > FileObject pointer that points to the root directory of the opened Ruby > on Rails Project? Hi, the right way is to use FileOwnerQuery: Project project = FileOwnerQuery.getOwner(someFileObject); FileObject rootDir = project.getProjectDirectory(); m. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: How to get the FileObject of the root directory of an opened Ruby on Rails project?Martin Krauskopf wrote:
> Philipp Marcus wrote: >> Hi, >> >> I`m developing a Netbeans module for Ruby on Rails development. My >> module is implemented as a RubyAstRule. In order to work correctly, my >> module needs to open the YAML file of the Ruby on Rails project. I >> thought of using >> org.netbeans.modules.ruby.platform.execution.DirectoryFileLocator in >> my module to find the YAML file that contains the database connection >> information. The constructor of the DirectoryFileLocator claims for a >> FileObject that points to the root directory. How do I get that >> FileObject pointer that points to the root directory of the opened >> Ruby on Rails Project? > > Hi, > > the right way is to use FileOwnerQuery: > > Project project = FileOwnerQuery.getOwner(someFileObject); > FileObject rootDir = project.getProjectDirectory(); PS: then rootDir.getFileObject("config/database.yml") You might also want to search ruby.railsproject: $ cd $NB_SRC/ruby.railsprojects/src $ grep -rl database.yml * | xargs gvim # or other editor m. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: How to get the FileObject of the root directory of an opened Ruby on Rails project?I might not be understanding the question, but doesn't RAILS_ROOT
contain the path to the root directory? such as DATA_FILE = RAILS_ROOT + "/data.yml" YAML.load_file(DATA_FILE)..... Martin Krauskopf wrote: > Martin Krauskopf wrote: >> Philipp Marcus wrote: >>> Hi, >>> >>> I`m developing a Netbeans module for Ruby on Rails development. My >>> module is implemented as a RubyAstRule. In order to work correctly, >>> my module needs to open the YAML file of the Ruby on Rails project. >>> I thought of using >>> org.netbeans.modules.ruby.platform.execution.DirectoryFileLocator in >>> my module to find the YAML file that contains the database >>> connection information. The constructor of the DirectoryFileLocator >>> claims for a FileObject that points to the root directory. How do I >>> get that FileObject pointer that points to the root directory of the >>> opened Ruby on Rails Project? >> >> Hi, >> >> the right way is to use FileOwnerQuery: >> >> Project project = FileOwnerQuery.getOwner(someFileObject); >> FileObject rootDir = project.getProjectDirectory(); > > PS: then > > rootDir.getFileObject("config/database.yml") > > You might also want to search ruby.railsproject: > > $ cd $NB_SRC/ruby.railsprojects/src > $ grep -rl database.yml * | xargs gvim # or other editor > > m. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@... > For additional commands, e-mail: dev-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: How to get the FileObject of the root directory of an opened Ruby on Rails project?Hi,
thanks for your help! My problem is now that I don`t know what to insert into getOwner. How do I get a FileObject pointer to the currently opened file - you called it someFileObject? What is the best method to get a reference to the currently opened project? Project project = FileOwnerQuery.getOwner(someFileObject); FileObject rootDir = project.getProjectDirectory(); Best Regards, Philipp Marcus Martin Krauskopf wrote: > Martin Krauskopf wrote: >> Philipp Marcus wrote: >>> Hi, >>> >>> I`m developing a Netbeans module for Ruby on Rails development. My >>> module is implemented as a RubyAstRule. In order to work correctly, >>> my module needs to open the YAML file of the Ruby on Rails project. >>> I thought of using >>> org.netbeans.modules.ruby.platform.execution.DirectoryFileLocator in >>> my module to find the YAML file that contains the database >>> connection information. The constructor of the DirectoryFileLocator >>> claims for a FileObject that points to the root directory. How do I >>> get that FileObject pointer that points to the root directory of the >>> opened Ruby on Rails Project? >> >> Hi, >> >> the right way is to use FileOwnerQuery: >> >> Project project = FileOwnerQuery.getOwner(someFileObject); >> FileObject rootDir = project.getProjectDirectory(); > > PS: then > > rootDir.getFileObject("config/database.yml") > > You might also want to search ruby.railsproject: > > $ cd $NB_SRC/ruby.railsprojects/src > $ grep -rl database.yml * | xargs gvim # or other editor > > m. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@... > For additional commands, e-mail: dev-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: How to get the FileObject of the root directory of an opened Ruby on Rails project?Philipp Marcus wrote:
> Hi, > > thanks for your help! My problem is now that I don`t know what to insert > into getOwner. How do I get a FileObject pointer to the currently opened > file - you called it someFileObject? What is the best method to get a > reference to the currently opened project? > > Project project = FileOwnerQuery.getOwner(someFileObject); > FileObject rootDir = project.getProjectDirectory(); Do you have a reference to java.io.File? If yes, then: File someFile = .... FileObject someFileObject = FileUtil.toFile(someFile); If you have nothing at hand and you want to 'infer' the best suitable Ruby-based project depending on the current context I suggest to use method: org.netbeans.modules.ruby.rubyproject.Util#inferRubyProject Location of Util.java: ruby.project/src/org/netbeans/modules/ruby/rubyproject/Util.java Let me know if it does not help. m. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: How to get the FileObject of the root directory of an opened Ruby on Rails project?Martin Krauskopf wrote:
> Philipp Marcus wrote: >> Hi, >> >> thanks for your help! My problem is now that I don`t know what to >> insert into getOwner. How do I get a FileObject pointer to the >> currently opened file - you called it someFileObject? What is the best >> method to get a reference to the currently opened project? >> >> Project project = FileOwnerQuery.getOwner(someFileObject); >> FileObject rootDir = project.getProjectDirectory(); > > Do you have a reference to java.io.File? If yes, then: > > File someFile = .... > FileObject someFileObject = FileUtil.toFile(someFile); > > If you have nothing at hand and you want to 'infer' the best suitable > Ruby-based project depending on the current context I suggest to use > method: > > org.netbeans.modules.ruby.rubyproject.Util#inferRubyProject > > Location of Util.java: > > ruby.project/src/org/netbeans/modules/ruby/rubyproject/Util.java PS: it seems that also this might help you, depending on your needs: http://wiki.netbeans.org/NetBeansDeveloperFAQ#section-NetBeansDeveloperFAQ-EditorAndEditedFiles m. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: How to get the FileObject of the root directory of an opened Ruby on Rails project?Martin Krauskopf wrote:
> Philipp Marcus wrote: >> Hi, >> >> thanks for your help! My problem is now that I don`t know what to >> insert into getOwner. How do I get a FileObject pointer to the >> currently opened file - you called it someFileObject? What is the best >> method to get a reference to the currently opened project? >> >> Project project = FileOwnerQuery.getOwner(someFileObject); >> FileObject rootDir = project.getProjectDirectory(); > > Do you have a reference to java.io.File? If yes, then: > > File someFile = .... > FileObject someFileObject = FileUtil.toFile(someFile); Sorry, should be: FileObject someFileObject = FileUtil.toFileObject(someFile); or better: FileObject someFileObject = FileUtil.toFileObject(FileUtil.normalizeFile(someFile)); m. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: How to get the FileObject of the root directory of an opened Ruby on Rails project?On Sep 16, 2008, at 10:56 AM, Philipp Marcus wrote:
> Hi, > > thanks for your help! My problem is now that I don`t know what to > insert into getOwner. How do I get a FileObject pointer to the > currently opened file - you called it someFileObject? What is the > best method to get a reference to the currently opened project? I assume you are doing this as part of a Fix implementation for your ast rule, correct? If so, use context.fileObject (context is the RubyRuleContext passed in to your AstRule; store it in your Fix implementation object when you construct it). -- Tor --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
|
|
Re: How to get the FileObject of the root directory of an opened Ruby on Rails project?On Sep 16, 2008, at 10:56 AM, Philipp Marcus wrote:
> Hi, > > thanks for your help! My problem is now that I don`t know what to > insert into getOwner. How do I get a FileObject pointer to the > currently opened file By the way, make sure you don't use the currently opened file (which you would get using the NbUtilities.getOpenPane utility method in the Ruby module). If you are writing a quickfix rule, that would work correctly for rules that you see in the current editor - but note that rules can also be run from (and shown in) the tasklist, across multiple projects. In that case, you want the rules to be tied to the file in which the rule was applied, not the file in the editor. So, use the context.fileObject reference instead. -- Tor --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@... For additional commands, e-mail: dev-help@... |
| Free embeddable forum powered by Nabble | Forum Help |