<commit_before>require 'formula'

class Starcheat < Formula
  homepage 'https://github.com/wizzomafizzo/starcheat'
  url 'https://github.com/wizzomafizzo/starcheat.git'
  version 'beta'

  devel do
    url 'https://github.com/wizzomafizzo/starcheat.git', :branch => 'dev'
    version 'dev'
  end

  depends_on :python3
  depends_on 'pyqt5'

  option 'without-app', 'Build without the .app (started via starcheat terminal command)'
  option 'without-binary', 'Only builds the .app, no binary install to your prefix'

  skip_clean 'StarCheat.app' if build.with? 'app'

  def install
    ENV["PYTHONPATH"] = lib/"python#{/\d\.\d/.match `python3 --version 2>&1`}/site-packages"
    system 'pip3', 'install', '--upgrade', 'setuptools'
    system 'pip3', 'install', 'Pillow'
    system 'python3', 'build.py', '-v'

    cd 'build' do
      system 'pip3', 'install', 'py2app'

      mv '../mac/setup.py', '.'
      # give write access to Qt's frameworks (fixes py2app permission errors)
      system 'chmod', '-R', 'u+w', Formula.factory('qt5').lib

      system 'python3', 'setup.py', 'py2app'
      # convert dynamic links into static links and adds qt5 plugins (cocoa...)
      system "#{Formula.factory('qt5').bin}/macdeployqt", 'dist/starcheat.app', '-verbose=2'

      cp_r 'dist/starcheat.app', prefix/'StarCheat.app'
      rm_rf ['build', 'dist', 'setup.py']
    end if build.with? 'app'

    if build.with? 'binary'
      libexec.install Dir['build/*']
      bin.install_symlink libexec+'starcheat.py' => 'starcheat'
    end
  end

  test do
    system bin/'starcheat', '-v' if build.with? 'binary'
    system prefix/'StarCheat.app/Contents/MacOS/starcheat', '-v' if build.with? 'app'<commit_msg>homebrew formula: don't assume cloned git repo<commit_after>require 'formula'

class Starcheat < Formula
  homepage 'https://github.com/wizzomafizzo/starcheat'
  url 'https://github.com/wizzomafizzo/starcheat.git'
  version 'beta'

  devel do
    url 'https://github.com/wizzomafizzo/starcheat.git', :branch => 'dev'
    version 'dev'
  end

  depends_on :python3
  depends_on 'pyqt5'

  option 'without-app', 'Build without the .app (started via starcheat terminal command)'
  option 'without-binary', 'Only builds the .app, no binary install to your prefix'

  resource 'setup.py' do
    url 'https://raw.github.com/wizzomafizzo/starcheat/master/mac/setup.py'
    sha1 '1ff254b23cfea06fe3fef83a8ada5da53aaa31b6'
    version '0.2'
  end

  skip_clean 'StarCheat.app' if build.with? 'app'

  def install
    ENV["PYTHONPATH"] = lib/"python#{/\d\.\d/.match `python3 --version 2>&1`}/site-packages"
    system 'pip3', 'install', '--upgrade', 'setuptools'
    system 'pip3', 'install', 'Pillow'
    system 'python3', 'build.py', '-v'

    cd 'build' do
      system 'pip3', 'install', 'py2app'

      (buildpath/'build').install resource('setup.py')
      # give write access to Qt's frameworks (fixes py2app permission errors)
      system 'chmod', '-R', 'u+w', Formula.factory('qt5').lib

      system 'python3', 'setup.py', 'py2app'
      # convert dynamic links into static links and adds qt5 plugins (cocoa...)
      system "#{Formula.factory('qt5').bin}/macdeployqt", 'dist/starcheat.app', '-verbose=2'

      cp_r 'dist/starcheat.app', prefix/'StarCheat.app'
      rm_rf ['build', 'dist', 'setup.py']
    end if build.with? 'app'

    if build.with? 'binary'
      libexec.install Dir['build/*']
      bin.install_symlink libexec+'starcheat.py' => 'starcheat'
    end
  end

  test do
    system bin/'starcheat', '-v' if build.with? 'binary'
    system prefix/'StarCheat.app/Contents/MacOS/starcheat', '-v' if build.with? 'app'
{'fraction_non_alphanumeric': 0.1579382579933848, 'fraction_numerical': 0.01515986769570011, 'mean_word_length': 3.4473039215686274, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, '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': '5766864', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1244, 'n_words': 315}