Class: RbBCC::Invoker

Inherits:
Object
  • Object
show all
Defined in:
lib/rbbcc/invoker.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Invoker

Returns a new instance of Invoker.



6
7
8
9
10
11
12
# File 'lib/rbbcc/invoker.rb', line 6

def initialize(args)
  @command = args.shift
  raise "Invalid option. Please specify script name" unless @command

  args.shift if args[0] == '--'
  @args = args
end

Instance Method Details

#runObject

Raises:

  • (Errno::ENOENT)


14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rbbcc/invoker.rb', line 14

def run
  plugins = Gem::Specification
              .find_all
              .select{|s| s.name =~ /^rbbcc-/ }
              .map(&:name)
  plugins.each {|n| require n }

  script = RbBCC::Plugin.find_script_name(@command)
  raise Errno::ENOENT, "Script not found: #{@command}" unless script

  binpath = File.readlink "/proc/self/exe"
  Process.exec binpath, script, *@args
end