I wrote tutorials for some Ruby gems I wrote. It is in markdown (Kramdown) text document. To ensure the integrity of the source code in the tutorials as the development of the gems continue I want to extract the source code from the tutorial document and run test to ensure the code is correct and working. Before reinventing the wheel I searched but found nothing on this kind of problem. Is there any software that can help me solve my problem? Ruby software would be cool but I'm not particular about the language. I'm sure I can't be the first person to encounter this problem.
The other option is to only have place holders in the tutorial documents and have all the files externally en then populate the document prior to publishing. This would mean a lot more loose files but would be significantly easier to implement.
Org mode in emacs can do that, but it means you can't write in Markdown.
Are you after something like Ruby DocTest?
Related
This is a really basic question. I've been watching Ruby Tapas and really like how Avdi can run his Ruby code and have it recorded directly in the source file. Googling "executing and documenting Ruby code" obviously returns a bunch of stuff about the RDocs for the language itself. Anyone know more specifically what I should look into?
You need to use the t9md / vim-ruby-xmpfilter. Look also the README section.
You need to have rcodetools gem mandatory.
After that go though the issue, I logged.
All,
I have been working with vim for some time now, and love everything about it - there is only one thing I really miss from IDEs like RubyMine, and that is advanced autocompletion.
For reference, here is my standard VIM setup: https://github.com/wrwright/.vim
I have tried ctags with omnicomplete + supertab, and the one major element I miss is the ability to bring up a context sensitive list of attributes/constants/methods. For example, as I learn RubyMotion, I'd love to have some help remembering iOS SDK constants/attributes/methods, but my VIM autocomplete stops with suggesting class names..or if it does suggest methods/attributes, it lists a ton of methods/attributes that don't even apply to the class I'm working with.
I'd like to (simple example) be able to type UIColor.bl and have it autocomplete with UIColor.blueColor (or suggest if there are multiple options that start with "bl" that are properties of UIColor.
RubyMine does this very well, and if I can get VIM to be similarly smart with autocomplete it would be heavenly (and a great boon while learning RubyMotion/iOS Development.
I have also tried SnipMate (and even a RubyMotion tailored variation at https://github.com/rcyrus/snipmate-snippets-rubymotion), but that doesn't seem to offer the features I'm looking for either.
Relatively satisfied with stock Vim's omnicomplete + vim-ruby and vim-rails having completion abilities on par with NetBeans but with all the bells&whistles of Vim and much lower resource requirements, of course.
From my .vimrc concerning completion options :
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
One thing that I have had a bit of luck with Rubymotion is YouCompleteMe and enabling tag Support. you will need a lot of ram(YCM uses ~2GB when indexing a large tag file) because the tags that rubymotion uses are about 40k tags.
The downside is that the rubymotion people don't seem to want to review pull requests and provide any feedback so I am not sure if they will add the needed things to the rake task that creates the tag files for ycm to work correctly out of the box.
To get it to work you need to set the tags files correct
set tags=./tags;,tags;
and then you need to setup ycm to complete off tags.
let g:ycm_collect_identifiers_from_tags_files = 1
you need to make the ctags file compatible with ycm as well. This pull request does that. You need to add a language field to the ctags creation and then change bridgesupport to ruby.
pull request for that
after that you need to run rake ctags in the root of your project.
If you don't want to modify the project.rb file you could probably create your own rake task that does pretty much the same thing.
Yes, Vim is an awesome... text editor.
As such, it can't be expected to match any IDE's "code awareness". Furthermore, it completely relies on the community for providing more than default support for a given language. If google or the rubymotion site didn't help you to find a serious "autocompletion" solution I doubt you'll find it here.
The process explained in the blog post below sounds ok, if not very precise on the vim configuration front.
http://rayhightower.com/blog/2013/02/12/automatic-ctags-with-rubymotion-and-vim/
I've been searching google for a while to determine the most coder-friendly example boxes.
I'm wanting to share varying forms of ECMA script (JS for example) etc that provides the user with color coding and a simple way of copying the code. I know there are several out there, but I wanted to get some opinions from SOF since you guys probably have good experience with code.
so- What's the code-sharing tool you [would] use?
the solution
I ended up using Gist for complete snippets and am using Syntax Highlighter for *incomplete * code samples. There's a Drupal plugin for the Syntax Highlighter, but I dare say it's more of a pain to figure out the plugin than it is to just do things the old fashioned way (old fashioned being like 5 years ago..)
I use http://jsfiddle.net/
Color coding — check
HTML, CSS, JS — check
Live demo — check
gist has syntax highlighting and users can download the files separately, as a zip archive or using git. You can embed the files easily on other sites.
Additionally, the site tracks changes and other users can add comments or fork a gist to change it themselves.
I write articles about ROR with a lot of Ruby code inside.
I need an online service such as tohtml.com to make my code insertions beatiful. This resource fine, but it is quite simple and not allow to show numbers of line. Of course output should be in HTML format.
Could you help me?
it called http://pygments.appspot.com/
Ryan Bates made a railscast to shouw howto highlight a ruby code anysc with Redis. background processing is really useful for such kind of tasks.
I'm writing Ruby app and I want to use some top-secret algorithms. So how would be the best to protect them from unauthorized access.
I have 2 ideas:
write them in C and load using FFI (I wonder if It's possible this way)
Marshal ruby code, encode it and then store in file
Maybe someone know better idea or can show me that these ideas are stupid or wrong. Thanks in advice.
You cannot protect the algorithm you are writing by changing it to C .. May be you can encrypt the source files. Try truecrypt
Edit
After some googling i found these articles related to ruby code obfuscation
protecting-your-ruby-source-code-for-end-user-applications/
Ruby Encoder Protects Source Code for US Department of Defense Project
http://rubyencoder.com/
You can try some code obfuscation techniques. For example RubyEncoder compiles Ruby source code into a encrypted bytecode format. And here is another thread related to your question Ruby obfuscator
If you are willing to craft your own solution instead of buying and already made one like RubyEncoder, as stated on other answer here, there is an article that try to describe a method to protect your source code, and you can also implement all sort of protection you think is feasible, as you are going to do all by hand:
http://mountcastle.posterous.com/protecting-your-ruby-source-code-for-end-user