<commit_before>version = (node[:phantomjs] && node[:phantomjs][:version]) || '2.0.0'
if `which phantomjs && phantomjs --version`.chomp == version
  puts "phantomjs #{version} is already installed"
  return
end

execute 'apt-get update'

%w(build-essential g++ flex bison gperf ruby perl libsqlite3-dev
  libfontconfig1-dev libicu-dev libfreetype6 libssl-dev libpng-dev
  libjpeg-dev python libx11-dev libxext-dev ttf-mscorefonts-installer git).each do |p|
  package p
end

tmp_dir = '/tmp/phantomjs'

execute "git clone git://github.com/ariya/phantomjs.git #{tmp_dir}" do
  not_if "test -d #{tmp_dir}"
end

execute 'git fetch' do
  cwd tmp_dir
end

execute "git checkout #{version}" do
  cwd tmp_dir
end

jobs = if node[:phantomjs] && node[:phantomjs][:jobs]
         "--jobs #{node[:phantomjs][:jobs]}"
       else
         ''
       end
execute "./build.sh --confirm #{jobs}" do
  cwd tmp_dir
end<commit_msg>bugfix<commit_after>version = (node[:phantomjs] && node[:phantomjs][:version]) || '2.0.0'
if `which phantomjs && phantomjs --version`.chomp == version
  puts "phantomjs #{version} is already installed"
  return
end

execute 'apt-get update'

%w(build-essential g++ flex bison gperf ruby perl libsqlite3-dev
  libfontconfig1-dev libicu-dev libfreetype6 libssl-dev libjpeg-dev
  python libx11-dev libxext-dev ttf-mscorefonts-installer git).each do |p|
  package p
end

execute 'install libpng' do
  cwd '/tmp'
  command <<-EOC
    wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/libpng-1.6.18.tar.gz
    tar xvf libpng-1.6.18.tar.gz
    cd libpng-1.6.18
    ./configure
    make
    make install
  EOC
  not_if 'test -e /usr/local/lib/libpng16.so'
end

tmp_dir = '/tmp/phantomjs'

execute "git clone git://github.com/ariya/phantomjs.git #{tmp_dir}" do
  not_if "test -d #{tmp_dir}"
end

execute 'git fetch && git clean -xfd' do
  cwd tmp_dir
end

execute "git checkout #{version}" do
  cwd tmp_dir
end

jobs = if node[:phantomjs] && node[:phantomjs][:jobs]
         "--jobs #{node[:phantomjs][:jobs]}"
       else
         ''
       end
execute "./build.sh --confirm #{jobs}" do
  cwd tmp_dir
end
{'fraction_non_alphanumeric': 0.13982050070854984, 'fraction_numerical': 0.015115729806329713, 'mean_word_length': 3.4968152866242037, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '7049241', 'n_tokens_mistral': 821, 'n_tokens_neox': 769, 'n_words': 204}