<commit_before>cask 'dwarf-fortress' do
  version '0.43.05'
  sha256 'c9614c012c23dcef6197f83d02510d577e1257c5a0de948af5c8f76ae56c5fc8'

  url "http://www.bay12games.com/dwarves/df_#{version.minor}_#{version.patch}_osx.tar.bz2"
  name '<NAME>ress'
  homepage 'http://www.bay12games.com/dwarves/'

  # shim script (https://github.com/caskroom/homebrew-cask/issues/18809)
  shimscript = "#{staged_path}/df_osx/df.wrapper.sh"
  depends_on cask: 'sdl-framework'
  depends_on cask: 'sdl-ttf-framework'

  binary shimscript, target: 'dwarf-fortress'

  preflight do
    IO.write shimscript, <<-EOS.undent
      #!/bin/sh
      exec '#{staged_path}/df_osx/df' "$@"
    EOS
  end

  postflight do
    Dir.chdir("#{staged_path}/df_osx/libs") do
      {
        'SDL'     => 'sdl-framework',
        'SDL_ttf' => 'sdl-ttf-framework',
      }.each do |key, value|
        name = "#{key}.framework"
        File.rename(name, "#{name}.orig")
        File.symlink(Hbc.load(value).staged_path.join(name), name)
      end
    end
  end

  uninstall_preflight do
    system_command '/bin/cp', args: ['-rf', "#{staged_path}/df_osx/data/save", '/tmp/dwarf-fortress-save/']
  end

  caveats 'During uninstall, your save data will be copied to /tmp/dwarf-fortress-save'
end<commit_msg>dwarf-fortress: use Hbc::CaskLoader.load<commit_after>cask 'dwarf-fortress' do
  version '0.43.05'
  sha256 'c9614c012c23dcef6197f83d02510d577e1257c5a0de948af5c8f76ae56c5fc8'

  url "http://www.bay12games.com/dwarves/df_#{version.minor}_#{version.patch}_osx.tar.bz2"
  name '<NAME>ress'
  homepage 'http://www.bay12games.com/dwarves/'

  depends_on cask: 'sdl-framework'
  depends_on cask: 'sdl-ttf-framework'

  # shim script (https://github.com/caskroom/homebrew-cask/issues/18809)
  shimscript = "#{staged_path}/df_osx/df.wrapper.sh"
  binary shimscript, target: 'dwarf-fortress'

  preflight do
    IO.write shimscript, <<-EOS.undent
      #!/bin/sh
      exec '#{staged_path}/df_osx/df' "$@"
    EOS
  end

  postflight do
    Dir.chdir("#{staged_path}/df_osx/libs") do
      {
        'SDL'     => 'sdl-framework',
        'SDL_ttf' => 'sdl-ttf-framework',
      }.each do |key, value|
        name = "#{key}.framework"
        File.rename(name, "#{name}.orig")
        File.symlink(Hbc::CaskLoader.load(value).staged_path.join(name), name)
      end
    end
  end

  uninstall_preflight do
    FileUtils.cp_r("#{staged_path}/df_osx/data/save", '/tmp/dwarf-fortress-save/') if Dir.exist?("#{staged_path}/df_osx/data/save")
  end

  caveats 'During uninstall, your save data will be copied to /tmp/dwarf-fortress-save'
end
{'fraction_non_alphanumeric': 0.15592435353145503, 'fraction_numerical': 0.04477035893477422, 'mean_word_length': 3.4006791171477078, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6401411', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1045, 'n_words': 159}