Module: Wagn::ScriptWagnLoader

Defined in:
lib/wagn/script_wagn_loader.rb

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.exec_script_wagn!Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/wagn/script_wagn_loader.rb', line 8

def self.exec_script_wagn!
  cwd = Dir.pwd
  return unless in_wagn_application? || in_wagn_application_subdirectory?
  exec RUBY, SCRIPT_WAGN, *ARGV if in_wagn_application?
  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_script_wagn! unless cwd == Dir.pwd
  end
rescue SystemCallError
  # could not chdir, no problem just return
end

.in_wagn_application?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/wagn/script_wagn_loader.rb', line 21

def self.in_wagn_application?
  File.exist?(SCRIPT_WAGN)
end

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

Returns:

  • (Boolean)


25
26
27
# File 'lib/wagn/script_wagn_loader.rb', line 25

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