Module: Susanoo::CLI

Defined in:
lib/susanoo/cli.rb,
lib/susanoo/cli/global_interface.rb,
lib/susanoo/cli/project_interface.rb,
lib/susanoo/cli/project_interface/run.rb,
lib/susanoo/cli/project_interface/build.rb,
lib/susanoo/cli/project_interface/server.rb,
lib/susanoo/cli/project_interface/console.rb,
lib/susanoo/cli/project_interface/generate.rb

Defined Under Namespace

Modules: Commands Classes: GlobalInterface, ProjectInterface

Constant Summary collapse

EXEC_FILES =
['bin/susanoo']

Class Method Summary collapse

Class Method Details

.executeObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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_executableObject



45
46
47
# File 'lib/susanoo/cli.rb', line 45

def self.find_executable
  EXEC_FILES.find { |exe| File.file?(exe) }
end

.inject_dev_pathObject



39
40
41
42
43
# 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

.runObject



13
14
15
16
17
# File 'lib/susanoo/cli.rb', line 13

def self.run
  unless execute
    Susanoo::CLI::GlobalInterface.start
  end
end