<commit_before>class RDownloadStrategy < SubversionDownloadStrategy
  def stage
    cp_r File.join(cached_location, "."), Dir.pwd
  end
end

class R < Formula
  homepage "http://www.r-project.org/"
  url "http://cran.rstudio.com/src/base/R-3/R-3.2.2.tar.gz"
  mirror "http://cran.r-project.org/src/base/R-3/R-3.2.2.tar.gz"
  sha256 "9c9152e74134b68b0f3a1c7083764adc1cb56fd8336bec003fd0ca550cd2461d"

  bottle do
    revision 2
    sha256 "643ff9fb3267228d73e7bf432debfda319cbbbf9c56f037b5d5f80a25997d114" => :yosemite
    sha256 "7aafc5435d9532cd59b208c6fdfaf99c892d7dca9f7c2405988e22171862e3a7" => :mavericks
    sha256 "2885b8a98b408479c8a69788192cd6deb9c04ba504c023a58734a1f5b0952cce" => :mountain_lion
  end

  head do
    url "https://svn.r-project.org/R/trunk", :using => RDownloadStrategy
    depends_on :tex
  end

  option "without-accelerate", "Build without the Accelerate framework (use Rblas)"
  option "without-check", "Skip build-time tests (not recommended)"
  option "without-tcltk", "Build without Tcl/Tk"
  option "with-librmath-only", "Only build standalone libRmath library"

  depends_on "pkg-config" => :build
  depends_on "texinfo" => :build
  depends_on :fortran
  depends_on "readline"
  depends_on "gettext"
  depends_on "libtiff"
  depends_on "pcre"
  depends_on "jpeg"
  depends_on "libpng"
  depends_on "xz"

  depends_on "openblas" => :optional
  depends_on "valgrind" => :optional

  if OS.mac?
    depends_on "cairo"
    depends_on "pango" => :optional
    depends_on :x11 => :optional
  else
    depends_on "cairo" => :optional
    depends_on "pango" => :optional
    depends_on :x11 => :recommended
  end

  # This is the same script that Debian packages use.
  resource "completion" do
    url "https://rcompletion.googlecode.com/svn-history/r31/trunk/bash_completion/R", :using => :curl
    sha256 "2b5cac905ab5dd4889e8a356bbdf2dddff60f718a4104b169e48ca856716e705"
    version "r31"
  end

  patch :DATA

  def install
    # Fix cairo detection with Quartz-only cairo
    inreplace ["configure", "m4/cairo.m4"], "cairo-xlib.h", "cairo.h"

    args = [
      "--prefix=#{prefix}",
      "--with-libintl-prefix=#{Formula["gettext"].opt_prefix}",
      "--enable-memory-profiling",
    ]
<commit_msg>r: require cairo with-x11 if building with-x11<commit_after>class RDownloadStrategy < SubversionDownloadStrategy
  def stage
    cp_r File.join(cached_location, "."), Dir.pwd
  end
end

class R < Formula
  homepage "http://www.r-project.org/"
  url "http://cran.rstudio.com/src/base/R-3/R-3.2.2.tar.gz"
  mirror "http://cran.r-project.org/src/base/R-3/R-3.2.2.tar.gz"
  sha256 "9c9152e74134b68b0f3a1c7083764adc1cb56fd8336bec003fd0ca550cd2461d"

  bottle do
    revision 2
    sha256 "643ff9fb3267228d73e7bf432debfda319cbbbf9c56f037b5d5f80a25997d114" => :yosemite
    sha256 "7aafc5435d9532cd59b208c6fdfaf99c892d7dca9f7c2405988e22171862e3a7" => :mavericks
    sha256 "2885b8a98b408479c8a69788192cd6deb9c04ba504c023a58734a1f5b0952cce" => :mountain_lion
  end

  head do
    url "https://svn.r-project.org/R/trunk", :using => RDownloadStrategy
    depends_on :tex
  end

  option "without-accelerate", "Build without the Accelerate framework (use Rblas)"
  option "without-check", "Skip build-time tests (not recommended)"
  option "without-tcltk", "Build without Tcl/Tk"
  option "with-librmath-only", "Only build standalone libRmath library"

  depends_on "pkg-config" => :build
  depends_on "texinfo" => :build
  depends_on :fortran
  depends_on "readline"
  depends_on "gettext"
  depends_on "libtiff"
  depends_on "pcre"
  depends_on "jpeg"
  depends_on "libpng"
  depends_on "xz"

  depends_on "openblas" => :optional
  depends_on "pango" => :optional
  depends_on "valgrind" => :optional
  depends_on :x11 => (OS.mac? ? :optional : :recommended)

  cairo_opts = build.with?("x11") ? ["with-x11"] : []
  cairo_opts << :optional if OS.linux?
  depends_on "cairo" => cairo_opts

  # This is the same script that Debian packages use.
  resource "completion" do
    url "https://rcompletion.googlecode.com/svn-history/r31/trunk/bash_completion/R", :using => :curl
    sha256 "2b5cac905ab5dd4889e8a356bbdf2dddff60f718a4104b169e48ca856716e705"
    version "r31"
  end

  patch :DATA

  def install
    # Fix cairo detection with Quartz-only cairo
    inreplace ["configure", "m4/cairo.m4"], "cairo-xlib.h", "cairo.h"

    args = [
      "--prefix=#{prefix}",
      "--with-libintl-prefix=#{Formula["gettext"].opt_prefix}",
      "--enable-memory-profiling",
    ]

{'fraction_non_alphanumeric': 0.1221357063403782, 'fraction_numerical': 0.1050055617352614, 'mean_word_length': 4.120728929384966, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 29, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1897741', 'n_tokens_mistral': 2053, 'n_tokens_neox': 1816, 'n_words': 325}