Class: Jets::Commands::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/jets/commands/runner.rb

Class Method Summary collapse

Class Method Details

.run(code) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/jets/commands/runner.rb', line 2

def self.run(code)
  if code =~ %r{^file://}
    path = code.sub('file://', '')
    full_path = "#{Jets.root}/#{path}"
    if File.exist?(full_path)
      code = IO.read(full_path)
    else
      puts "ERROR: file not found at #{full_path}".color(:red)
      exit 1
    end
  end

  eval(code) # inline script
end