Is there a way to make emacs pull autocompletions of ruby methods the way Eclipse and NetBeans do? That is if I type File. and press CTRL-space in Eclipse I will get a list of File methods. Same with variables. I have installed autocomplete plugin, ruby-mode, rinari and cedet, but so far it will complete local variable and method names, but will not native ones.
I think you need something like RSense. You might also like the more general auto complete mode.
I'm not familiar with ruby, but if by "native methods" you mean stuff in some system library, there are a couple options for extending CEDET to do the work.
If there are ruby files somewhere that have all that code in them, and if ruby supports some sort of "include" or "import" statement, then you need to add that location to the include path for ruby. This probably requires a change the the ruby source code to add a new system include path. You can see examples in semantic-c.el. You may also need to override the function semantic-tag-include-filename to convert the include into a findable filename.
If there are no includes, and there is just some ruby interpreter that knows all this stuff, then you will instead need to code up a full ruby "omniscient" database, similar to semanticdb-el.el. It will need a way to query ruby for various things and return them as answers.
Any such enhancements would be welcome back in the ruby support in CEDET's contrib area.
Ruby is an interpreted language, making it difficult to do certain things, such as autocompletion. How would you know what the object type is, if it's not defined? Therefore, premade solutions are limited or nonexistent. Even the autocompletion in Netbean/Eclipse will only work on class methods (if I'm not mistaken).
Related
I want to have google-style like code style checker that would automatically run within Clion.
However, what I found as solutions (predeclared code style for google and others, direct Editor settings and EditorConfig support in Clion help) are all rather primitive. For example, I want to use snake case with final underscore for class member fileds (e.g. my_class_member_) and usual snake case for function arguments (e.g. some_argument), and none of the suggested options would do the trick as far as I am concerned. Furthermore, some politics associated with endless loops and so are to be added, which is even more context-specific.
I consider creating cpplint.py-like script for this, but it is going to be very time-consuming and is likely to be run outside Clion. Are there any elegant ways to solve my problem?
Yeah, you able to do this! Look into Clion plug-in Clion-cpplint and use with cpplint.py script, provided by Google. You will get highlights on the fly when you are editing C++ source code.
You able to install add-on through Plugins tab in settings. In the end you will get something like:
Using Java big IDEs compile my code while it is written so that errors are detected before runtime.
Is that possible with Ruby too? Actually I code in a Text editor. Errors are detetected at runtime only.
Is that possible with Ruby too?
If by that you mean "compiling", then no. If you mean "edit-time error detection", then also no.
Smart IDEs, like RubyMine, can guess/detect some errors, but only simple cases. And they are often confused by ruby's dynamic nature. (can't find location for a method, even though it's defined within the project. Or the opposite, find too many false positives).
In ruby, you simply can't know what does a piece of code do without running it.
I'm using ripper tags (https://github.com/tmm1/ripper-tags) to generate ctags files for a ruby project.
My goals is, in vim, to be able to jump from a line such as:
::Api::Contracts::Creator.new(
To the relevant file which defines that module.
This configuration works fine if there is only one module called Creator. But in practice there will be many Creators in different namespaces, e.g there will also be an ::Api::Users::Creator.
The above configuration will just jump to the first definition of Creator rather than the specific Creator in question.
Is there anyway to configure ctags so that it will jump to the specific definition?
ripper-tags needs to be run with the option
--extra=1
So that tags will be generated which include the full module paths. This still leaves the problem that ctrl+] uses the current word so using it on Module::Class will only search for Class.
But this isn't really a ctags issue so I'll open a separate question on how best to write a custom command in vim to do this.
Using visual select to select the full definition and then ctrl+] will go to the correct definition.
I've written a little library that uses implicits to add functionality that one only needs when using the REPL in Scala. Ruby has libraries like this - for things like pretty printing, firing up text editors (like the interactive_editor gem which invokes Vim from irb - see this post), debuggers and the like. The library I am trying to write adds some methods to java.lang.Class and java.lang.reflect classes using the 'pimp my library' implicit conversion process to help you go and find documentation (initially, with Google, then later possibly with a JavaDoc/ScalaDoc viewer, and maybe the StackOverflow API eventually!). It's an itch-scratching library: I spend so much time copying and pasting classnames into Google that I figured I may as well automate the process.
It is the sort of functionality that developers will want to add to their system for use only in the REPL - they shouldn't really be adding it to projects (partly because it may not be something that their fellow developers want, but also because if you are doing some exploratory development, it may be with just a Scala REPL that's not being invoked by an IDE or build tool).
In my case, I want to include a few classes and set up some implicits - include a .jar on the CLASSPATH and import it, basically.
In Ruby, this is the sort of thing that you'd add to your .irbrc file. Other REPLs have similar ways of setting options and importing libraries.
Is there a similar file or way of doing this for the Scala REPL?
On the command line, you can use the -i option to load a file while starting the REPL:
scala -cp mystuff.jar -i mydefs.scala
Ofcourse you could wrap this in a shell script or batch file and run that instead of the normal scala command.
(I'm using Scala 2.8.0 RC3).
Not sure if this is what you are looking for, but if you put any jars in your SCALA_HOME\lib directory. Then those jars will be available for import in the REPL (using the import keyword).
EDIT: The most convenient option as of now is by setting the CLASSPATH environment variable. Any jars referenced in the CLASSPATH variable are also available for import in the REPL.
Quick answer probably not what you are looking for, but what about typing
:load path/to/some/scala/script/file.scala
in the console?
:load will read in a scala file and execute it as a script.
Another option is to use sbt set up your dependencies and execute the console command.
The final option I can think of is to set the classpath on the command line manually and point it to the jars / class file folders that you want the jvm to know about.
Let me know if any of this interests you and I can provide more details if needed.
In Java when you compile a .java file which defines a class, it creates a .class file. If you provide these class files to your coworkers then they cannot modify your source. You can also bundle all of these class files into a jar file to package it up more neatly and distribute it as a single library.
Does Ruby have any features like these when you want to share your functionality with your coworkers but you don't want them to be able to modify the source (unless they ask you for the actual .rb source file and tell you that they want to change it)?
I believe the feature you are looking for is called "trust" (and a source code control repository). Ruby isn't compiled in the same way that Java is, so no you can't do this.
I have to say your are in a rough position, not wanting to share code with a coworker. However, given that this is an unassailable constraint perhaps you could change the nature of the problem.
If you have a coworker that needs access to some service provided by a library of yours, perhaps you could expose it by providing a web/rest service instead of as a .rb file.
This way you can hide your code behind a web server, and if there is a network architecture that allows for low latency making these service calls, you can effectively achive the same goal.
Trust is a lot easier though.
edit:
Just saw this on HN: http://blog.astrails.com/2009/5/12/ruby-http-require, allows a ruby file to include another file through http instead of the filesystem.
Ruby is
A dynamic, interpreted, open source programming language with a focus on simplicity and productivity.
So like all interpreted languages, you need to give the source code to anyone who want's to execute your program/script.
By the way searching "compiled ruby" on google returned quiet a few results.
I don't think there is one. Ruby is purely an interpreted language, which means ruby interprets your source code directly in order to run it. Java is compiled, so there's an intermediate bytecode (the .class). You can obfuscate your ruby if you really wish, but it's probably more trouble than it's worth.
Just to make sure you realize, however, upwards of 95% of Java can be decompiled back into source using various free utilities, so in reality, Java's compilation isn't much better than distributing Ruby source.
This is not a language specific problem and one that can be managed more effectively through source control software.
There is a library called ruby2c that compiles a subset of Ruby into C code (which you can then compile into native code, if you want).
It was actually originally written as a Ruby code obfuscator (but has since been used for lots of other stuff, including Ruby Arduino development).