Method: #stack_path

Defined in:
ext/pandoc_rb/extconf.rb

#stack_pathObject



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'ext/pandoc_rb/extconf.rb', line 42

def stack_path
  @stack_path ||= begin
    Dir.chdir(__dir__) do
      temp_stack_path = `stack path`.lines.map do |line|
        /^(?<var>[^:]+): (?<val>.*)$/ =~ line.chomp
        [var, File.absolute_path(val)]
      end.to_h
      temp_stack_path['compiler-lib'] = temp_stack_path['compiler-bin'].sub(/bin$/, 'lib')
      temp_stack_path['compiler'] = temp_stack_path['compiler-bin'].sub(/^.*\/([^\/]+)\/bin$/, '\1')
      temp_stack_path
    end
  end
end