<commit_before>#
# Cookbook Name:: rubygems
# Recipe:: default
#
# Copyright 2012, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#

include_recipe 'build-essential'

case node['platform']
  when 'debian', 'ubuntu'
    %w(libssl-dev zlib1g-dev libreadline6-dev libyaml-dev libffi-dev).each do |pkg|
      package pkg
    end
end

ruby = "ruby-#{node['ruby']['version']}"
rubygems = "rubygems-#{node['rubygems']['version']}"
ruby_tar = "#{ruby}.tar.gz"
rubygems_tar = "#{rubygems}.tgz"
ruby_src_url = "http://ftp.ruby-lang.org/pub/ruby/#{node['ruby']['version'].match(/[0-9]+\.[0-9]+/).to_s}/#{ruby_tar}"
rubygems_src_url = "http://production.cf.rubygems.org/rubygems/#{rubygems_tar}"

src = '/usr/local/src'
ruby_src = "#{src}/#{ruby}"
rubygems_src = "#{src}/#{rubygems}"

ruby_bin = "#{node['ruby']['prefix']}/bin/ruby"
gem_bin = "#{node['ruby']['prefix']}/bin/gem"

# ruby

remote_file "/tmp/#{ruby_tar}" do
  source ruby_src_url
  checksum node['ruby']['checksum']
  mode 0644
end

execute "tar --no-same-owner -xzf /tmp/#{ruby_tar}" do
  cwd src
  creates ruby_src
end

bash 'configure ruby' do
  cwd ruby_src
  code "./configure --prefix=#{node['ruby']['prefix']}"
  creates "#{ruby_src}/config.status"
end

bash 'make ruby' do
  cwd ruby_src
  code "make #{node['ruby']['make_opts']}"
  creates "#{ruby_src}/ruby"
end

bash 'install ruby' do
  cwd ruby_src
  code 'make install'
  not_if { File.exist?(ruby_bin) }
end

# rubygems

remote_file "/tmp/#{rubygems_tar}" do<commit_msg>Disable RDoc and API documentation, too slow<commit_after>#
# Cookbook Name:: rubygems
# Recipe:: default
#
# Copyright 2012, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#

include_recipe 'build-essential'

case node['platform']
  when 'debian', 'ubuntu'
    %w(libssl-dev zlib1g-dev libreadline6-dev libyaml-dev libffi-dev).each do |pkg|
      package pkg
    end
end

ruby = "ruby-#{node['ruby']['version']}"
rubygems = "rubygems-#{node['rubygems']['version']}"
ruby_tar = "#{ruby}.tar.gz"
rubygems_tar = "#{rubygems}.tgz"
ruby_src_url = "http://ftp.ruby-lang.org/pub/ruby/#{node['ruby']['version'].match(/[0-9]+\.[0-9]+/).to_s}/#{ruby_tar}"
rubygems_src_url = "http://production.cf.rubygems.org/rubygems/#{rubygems_tar}"

src = '/usr/local/src'
ruby_src = "#{src}/#{ruby}"
rubygems_src = "#{src}/#{rubygems}"

ruby_bin = "#{node['ruby']['prefix']}/bin/ruby"
gem_bin = "#{node['ruby']['prefix']}/bin/gem"

# ruby

remote_file "/tmp/#{ruby_tar}" do
  source ruby_src_url
  checksum node['ruby']['checksum']
  mode 0644
end

execute "tar --no-same-owner -xzf /tmp/#{ruby_tar}" do
  cwd src
  creates ruby_src
end

bash 'configure ruby' do
  cwd ruby_src
  code "./configure --prefix=#{node['ruby']['prefix']} --disable-install-doc"
  creates "#{ruby_src}/config.status"
end

bash 'make ruby' do
  cwd ruby_src
  code "make #{node['ruby']['make_opts']}"
  creates "#{ruby_src}/ruby"
end

bash 'install ruby' do
  cwd ruby_src
  code 'make install'
  not_if { File.exist?(ruby_bin) }
end

# rubygems

remote_file "/tmp/#{rubygems_tar}" do
{'fraction_non_alphanumeric': 0.19385420071918927, 'fraction_numerical': 0.009153318077803204, 'mean_word_length': 4.730337078651686, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5067085', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1189, 'n_words': 240}