Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Interactive Rails template

#2163

UPDATED

Rails template runner enhancement:

run_ruby_script merged into run method.
  Now use: run "ruby_script.rb", :ruby_script=>true

:show_response option to check command response or when interaction is needed
  run "compass --rails -f blueprint .", :show_reponse=>true

:puts option for automatized tasks
   run "compass --rails -f blueprint .", :puts=>["y","n"]

Reported by rubymood · March 7th, 2009 @ 03:11 PM

State: wontfix
Milestone: 2.x
Assigned to: Pratik Pratik
Importance: none

Activity

  1. rubymood
    rubymood

    Making Rails template interactive, so user can interaction whit the running command.

    Example for compass gem: if yes?("Do you wanna manually config compass?") run "compass --rails -f #{ask("Wich framework want to use?")} .", :interactive=>true else run "compass --rails -f blueprint .", :puts=>["y","n"] end :puts sends arguments to stdin, so it could be use for automatic configuration.

    March 7th, 2009 @ 03:13 PM

  2. rubymood
    rubymood

    Making Rails template interactive, so user can interaction whit the running command.

    Example for compass gem:

    if yes?("Do you wanna manually config compass?") 
      run "compass --rails -f #{ask("Wich framework want to use?")} .", :interactive=>true 
    else 
      run "compass --rails -f blueprint .", :puts=>["y","n"] 
    end 
    

    :puts sends arguments to stdin, so it could be use for automatic configuration.

    March 7th, 2009 @ 03:16 PM

  3. CancelProfileIsBroken
    CancelProfileIsBroken
    • Assigned user set to Pratik
    • Tag changed from template_runner to patch, template_runner

    March 7th, 2009 @ 03:47 PM

  4. Pratik
    Pratik
    • State changed from new to wontfix

    I think this is making the API more complex than needed. If more people ask for this, I'd be happy to commit. What's the alternative you are using at the moment ?

    Thanks.

    March 7th, 2009 @ 03:55 PM

  5. rubymood
    rubymood

    I'm using the approaches in the patch in my template file when is needed. But I think it's a good option to run commands only with the run method and passing params to it how to run. (so I'm think the run_ruby_script isnt needed, because when running ruby command in windows you should simply put ruby before the command, but FYI this method is not removed from my patch)

    March 7th, 2009 @ 04:28 PM

  6. rubymood
    rubymood

    Or we should maybe merge run_ruby_script with run method.

    March 7th, 2009 @ 04:31 PM

  7. rubymood
    rubymood

    Some more explanation and patch update.

    When somebody - with the current Rails version - want to generating new Rails app with template file and in this process want to config/install something that needing some interaction, the rails app generating will stop, waiting the input and don't show anything.

    new patch: * run_ruby_script merged into run * well documented

    March 7th, 2009 @ 05:49 PM

  8. rubymood
    rubymood

    sorry, my last patch works on windows just for ruby scripts.. and for now I've changed more things:

    Now for ruby script:

    run "ruby_script.rb", :ruby_script => true

    To check command response or when interaction is needed:

    run "compass --rails -f blueprint .", :show_reponse=>true

    For automatized tasks:

    run "compass --rails -f blueprint .", :puts=>["y","n"]

    March 7th, 2009 @ 09:53 PM

  9. Jeremy McAnally
    Jeremy McAnally

    In my opinion, we're getting outside of the original intent of the feature here. If you need some sort of interactive input beyond yes/no or some basic text input, then it should be a separate script or something that's run post-generation. At that point it's not a template, it's a Turing-complete application.

    I'm just thinking about the 80% (or probably more likely 95%) case here. It seems like this could live as a gem if people needed it or something, since it's a rather small-scale use case.

    March 7th, 2009 @ 10:11 PM

  10. rubymood
    rubymood

    Jeremy, thanks for your response.

    The time will answer the question, that the community is needing or not this kind of support for generating application.

    Anyway, I upload a working script, to whom it may concern.

    March 8th, 2009 @ 03:04 PM