Module: Decko::ScriptDeckoLoader

Defined in:
decko/lib/decko/script_decko_loader.rb

Constant Summary collapse

RUBY =
File.join(*RbConfig::CONFIG.values_at("bindir", "ruby_install_name")) +
RbConfig::CONFIG["EXEEXT"]
SCRIPT_DECKO =
File.join("script", "decko")

Class Method Summary collapse

Class Method Details

.continue?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'decko/lib/decko/script_decko_loader.rb', line 32

def continue?
  in_application? || in_application_subdirectory?
end

.exec!Object



10
11
12
13
14
15
16
17
18
# File 'decko/lib/decko/script_decko_loader.rb', line 10

def exec!
  cwd = Dir.pwd
  return unless continue?

  exec_decko_script
  recurse cwd
rescue SystemCallError
  # could not chdir, no problem just return
end

.exec_decko_scriptObject



28
29
30
# File 'decko/lib/decko/script_decko_loader.rb', line 28

def exec_decko_script
  exec RUBY, SCRIPT_DECKO, *ARGV if in_application?
end

.in_application?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'decko/lib/decko/script_decko_loader.rb', line 36

def in_application?
  File.exist?(SCRIPT_DECKO)
end

.in_application_subdirectory?(path = Pathname.new(Dir.pwd)) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
# File 'decko/lib/decko/script_decko_loader.rb', line 40

def in_application_subdirectory? path=Pathname.new(Dir.pwd)
  File.exist?(File.join(path, SCRIPT_DECKO)) ||
    !path.root? && in_application_subdirectory?(path.parent)
end

.recurse(cwd) ⇒ Object



20
21
22
23
24
25
26
# File 'decko/lib/decko/script_decko_loader.rb', line 20

def recurse cwd
  Dir.chdir("..") do
    # Recurse in a chdir block: if the search fails we want to be sure
    # the application is generated in the original working directory.
    exec! unless cwd == Dir.pwd
  end
end