module Susanoo::CLI

Constants

EXEC_FILES

Public Class Methods

execute() click to toggle source
# File lib/susanoo/cli.rb, line 19
def self.execute
  cwd = Dir.pwd

  loop do
    # Find an executable in bin/susanoo
    # In other word are we in an susanoo project or not?
    # Note: Single equalsign is on purpose
    if exec_file = find_executable

      # Inject path
      inject_dev_path
      exec Gem.ruby, exec_file, *ARGV
      break
    end

    Dir.chdir(cwd) and return false if Pathname.new(Dir.pwd).root?
    Dir.chdir('../')
  end
end
find_executable() click to toggle source
# File lib/susanoo/cli.rb, line 45
def self.find_executable
  EXEC_FILES.find { |exe| File.file?(exe) }
end
inject_dev_path() click to toggle source
# File lib/susanoo/cli.rb, line 39
def self.inject_dev_path
  if File.exist? File.expand_path('../../../.git', __FILE__)
    ENV['SUSANOO_HOME'] = File.expand_path('../../', __FILE__)
  end
end
run() click to toggle source
# File lib/susanoo/cli.rb, line 13
def self.run
  unless execute
    Susanoo::CLI::GlobalInterface.start
  end
end