Is there a doc like perlguts/illguts for ruby? - ruby

I recently enjoied the illustrated perlguts as fun and easy way to see how things are implemented without the need to dig through sources and would love to read such documentation for ruby.
Perlguts provides some information on the workings of the Perl interpreter and describes how to use the Perl API. Illguts i an illustrated version of perlguts.
Are there similar docs for ruby?

Here is some stuff along those lines:
The Ruby Hacking Guide (old, but contains some of that nuts & bolts info)
http://dev-logger.blogspot.com/2008/06/ruby-internals-by-patrick-farley.html

Related

simple DSL in Ruby

I would like to make a DSL in Ruby, where I will can using simple commands do something. For example "GO PRINT 10 *" will print 10 stars
or "GO PRINT 5 &" will print 5 ampersand. Anyone know good tutorials ?
I heard about the gem docile It is worthy of attention?
Here are some links relevant to what you want to do:
https://robots.thoughtbot.com/writing-a-domain-specific-language-in-ruby
Tutorials for writing DSL in Ruby
https://www.leighhalliday.com/creating-ruby-dsl
If you want a very flexible DSL (i.e., one in which you can't tell that it's actually Ruby, which sounds like what you want), I'd suggest learning a language such as Racket which is very well-geared towards creating all sorts of languages, e.g., a brainf*ck clone, a stack-based calculator, these, and these.

Ctags - Find where a function is used in a project

Is there any good way to find where is a function being called in our codebase ?
There is a gem called Starscope (disclaimer: I am the author) which can list function calls in ruby code, among other things. It isn't perfect, since it can't handle crazy meta-programming, but it will find all the normal calls to a given function.
gem: https://rubygems.org/gems/starscope
github: https://github.com/eapache/starscope
user guide: https://github.com/eapache/starscope/blob/master/doc/USER_GUIDE.md
edit: Luc's answer is entirely accurate as far as it goes; I wrote Starscope specifically to be "Cscope for Ruby".
With ctags, no. It references functions declarations and definitions, not their uses.
Then it depends on the language.
cscope can help with C, but not with C++. With C++, you should have a look at clang based solutions : there is clang_indexer (and its many forks) (see vim-clang to integrate it in vim), but I did found a few quirks ; it seems YouCompleteMe does a few things related to code indexation (as it provides GotoImplementation/Declaration commands).
For other languages, you may have dedicated plugins. But for sure, there is always grep (and many plugins that integrates it)

Is there an erlang term parser written in ruby?

We have a logging system, and erlang OTP server is writing logs in erlang term.
We also have Rails interface for internal users, and I want to provide a log analysis for them.
I have tried to find an erlang term parser, not erlang parser, written in ruby. but no luck yet.
erlang terms are simple; atom, tuple, list(including string), binary, and pid/ref
atom is like a symbol
tuple is like a hash
list is like an array
binary/pid/ref are like string
Anyone knows any existing erl-to-ruby parser?
Maybe this isn't quite what you're looking for, but you could check out BERT-RPC. It has serializers, clients, and servers for various languages, including Ruby (they are listed at the bottom of the page).
BERT is new, and it seems overkill to me, and I don't see code out-there for this purpose,
I made my own.
https://github.com/bighostkim/erl_to_ruby
This module from the people at basho seems to be exactly what you need.
https://github.com/basho/erlang_template_helper

How to understand scripting language like Ruby from a C/C++/VBNET programmer perspective?

I have been C/C++/VBNET programmer for a long time. Now Ruby advanced concept is attracting me. So I decided to learn how to use it.But the "Behavior" of Ruby used to confused me. I usually feel like can't completely control my Ruby program.
Can you help me get clearly about this ?
(Maybe some of your favorite guide about "Ideas" and "Styles" in Ruby may help >:D< . Thank)
Ruby is quite an unusual programming language if you are more used to static/declarative style languages like C/C++.
I suspect it's the highly dynamic nature of the language which is causing you a problem, it can be difficult to get your head around this when you encounter it for the first time after having used only the more static languages. Ideas like Duck Typing can seem weird if you are used to declaring variables as strict types before use.
I would thoroughly recommend working your way through one of the excellent books about ruby that are out there. Don't just mess around writing code without really understanding the concepts.
Personally I really liked "The Ruby Programming Language" from O'Reilly, but I have experiance of a lot of different languages so I'm used to some of the more dynamic features in Ruby.
However you may prefer to start with something less terse such as Dave Thomas' "Programming Ruby" (make sure you get the 1.9 version).
Work through one of these books, do the examples, play around with the code. That way you will get a thorough understanding of the language.
Best of luck. Once you get your head around it, Ruby can be a very powerful language.
I think that the book Design Patterns in Ruby might help you. The first chapter describes the syntax of Ruby (which I guess that you won't need), but the rest of the book goes through the classic design patterns and shows you a Ruby way of approaching them. It's very clearly written and I learned a lot about Ruby idioms from it.
If you can talk to a Rubyist then that will probably help a lot - from experience, a code review or pairing session with someone else can get you over mental blocks better than anything else. If you don't know anyone, try writing some code then post a link to it to the Ruby Talk mailing list with questions. This is a very friendly community, and people are happy to help.
I recommend reading Why's Poignant Guide to Ruby. It will open your mind to the wonders of working in a dynamic language. Or it will piss you off with its cartoons of talking foxes. Either way it will change your thinking about Ruby :)

Standard Library Reference for Ruby

I need a good reference for how to use standard Libraries in Ruby. Current libraries do not describe or give examples like say Java's. Yet this is where examples are much more needed (in Ruby), because I am not familiar with what the called method will yield! I am left with having to look at the source files every time, which seems inefficient. What is a good standard library reference... or am I just not understanding blocks yet?
I find myself bouncing around between the ruby core API on ruby-doc.org, googling for answers on random blogs, and spending time testing ideas in the interactive interpreter (irb). I haven't seen any other core reference documentation that I liked, but I do have a copy of The Ruby Way and its pretty decent.
Betweeen these four sources I can almost always find out how to solve the problem I'm working on.
Best of luck - ruby is fun, frustrating, and powerful.
There is the Ruby Standard Library documentation and sites like apidock. The Pickaxe book has a great reference towards the end. There's even a free version online, but it's quite out of date; to find the reference there, click Standard Library in the top-left frame.
Try GotAPI You'll be able to find the Ruby standard documentation and a whole lot of api docs there
Understanding blocks is pretty important, especially if you want to understand the Enumerable module. ruby-doc.org is usually all I need, but if I need a little more explanation I grab the PickAxe. You need the PickAxe, no question.
I am sorry , but again, i have to recommend ruby cookbook. (Already two times today)

Resources