Create ruby file with ruby GUI

Hi community,

let us say i have a ruby script. This ruby script is a GUI with input
fields created with qt creator. Depending on how the fields are filled
my script has to create a new ruby file without GUI.
The ulterior motive is that I will create a Testfile with the inputs in
the GUI. I select the function that should be tested and the arguments
of the funtion etc...
Now, my questions is how would you would implement this?
I think it is not a good idea to open a File with IO library and fill
this with strings and arguments. It is not so flexible.
Any suggestions?

Thanks :smiley:

···

--
Posted via http://www.ruby-forum.com/.

You could use a Template if you're going to be writing the same basic
code with different minor variations.

Alternatively you could just use a single file containing all the
options, and use arguments to make it perform different tasks.

···

--
Posted via http://www.ruby-forum.com/.

Instead of generating a script, generate a configuration file that a
script can use to run.

I do have to ask why you're doing this, though; are these sorts of tests
going to be repeatable without re-entering the same data over and over?
If not, I'd suggest using the GUI app to generate reusable test samples
(or perhaps features if you're using cucumber).

Full disclosure: I really hate using GUI apps when I can do it with a
command line app/script, especially if it's something that's
repetitious.

···

stefan heinrich <lists@ruby-forum.com> wrote:

let us say i have a ruby script. This ruby script is a GUI with input
fields created with qt creator. Depending on how the fields are filled
my script has to create a new ruby file without GUI.
The ulterior motive is that I will create a Testfile with the inputs in
the GUI. I select the function that should be tested and the arguments
of the funtion etc...
Now, my questions is how would you would implement this?
I think it is not a good idea to open a File with IO library and fill
this with strings and arguments. It is not so flexible.
Any suggestions?

Not sure what you mean, perhaps this one:

···

==================================
require 'Ruiby'

FILE="text.rb"

TEMPLATE=<<EEND
require 'rspec'
# the command...
%s

EEND
Ruiby.app :height=> 30 do
  flow do
    label "Your script : "
    w=entry("")
    button("Go") do
      File.open(FILE,"w") { |f| f.puts(TEMPLATE % [w.text.strip]) }
      log system("ruby",FILE)
    end
  end
end

==================================

--
Posted via http://www.ruby-forum.com/.