Jump to content

buddylreno

Member
  • Posts

    3
  • Joined

  • Last visited

Reputation Activity

  1. Like
    buddylreno reacted to deanishe in Creating a Basic Workflow with Ruby   
    Cool intro.
     
    FWIW, I generally discourage people from pasting more than a couple of lines in the Script box.
     
    It makes both coding and debugging far more difficult. There's no syntax highlighting or any of the other benefits you get from a real programmer's editor, and it's difficult to track down exceptions. Ruby, Python etc. will tell you the line number where the error occurred. This is super helpful, but not if your code is in the Script box where there are no line numbers.
     
    A much better idea is to put the code in a file in your workflow's directory and call it via the Script box (and bash):
    /usr/bin/ruby myscript.rb "{query}" It's also a good idea to use the full path to the interpreter. If you distribute your workflow, this insulates your code somewhat from a user messing about with their environment. For example, if someone has buggered about with their environment sufficiently that python resolves to some version of Python 3, your workflow will very likely not work (the system Python is version 2, and they're not particularly compatible).
     
    If a user has replaced the system Python at /usr/bin/python, that's their own stupid fault.
     
    So, will you be writing some more tutorials using the Ruby template? That's an awesome library. I stole a lot of its ideas for my Python library.
×
×
  • Create New...