Class: Zui::Runner
- Inherits:
-
Object
- Object
- Zui::Runner
- Defined in:
- lib/zui/runner.rb
Instance Method Summary collapse
-
#initialize(host: Host.new, framework_root: FRAMEWORK_ROOT, ruby: RbConfig.ruby) ⇒ Runner
constructor
A new instance of Runner.
- #run(file, name: nil, environment: ENV.to_h) ⇒ Object
Constructor Details
#initialize(host: Host.new, framework_root: FRAMEWORK_ROOT, ruby: RbConfig.ruby) ⇒ Runner
Returns a new instance of Runner.
7 8 9 10 11 |
# File 'lib/zui/runner.rb', line 7 def initialize(host: Host.new, framework_root: FRAMEWORK_ROOT, ruby: RbConfig.ruby) @host = host @framework_root = framework_root @ruby = ruby end |
Instance Method Details
#run(file, name: nil, environment: ENV.to_h) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/zui/runner.rb', line 13 def run(file, name: nil, environment: ENV.to_h) program = File.(file) raise ArgumentError, "Ruby file not found: #{program}" unless File.file?(program) executable = @host.executable project = File.dirname(program) arguments = [ executable, "--qml-root", @framework_root, "--project", project, "--program", program, "--ruby", @ruby, "--load-path", File.join(@framework_root, "lib"), "--name", name || project_name(project) ] system(@host.environment(environment), *arguments) $?&.exitstatus || 1 end |