<commit_before>#
# Author::        <NAME>
# Copyright:: Copyright (c) 2012 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# -*- coding: utf-8 -*-
#

include_recipe "build-essential"

# ensure ruby1.9 builds with openssl gem
case node[:platform]
when "ubuntu", "debian"
  package "libssl-dev"
end

# Download the ruby source for 1.9.2. Skip the download if:
# * the source file already exists
# * ruby 1.9.2 has been installed at the specified patch-level
#
remote_file "/tmp/ruby-1.9.3-p320.tar.gz" do
  source "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p320.tar.gz"
  not_if do
    ::File.exists?("/tmp/ruby-1.9.3-p320.tar.gz") ||
      (::File.exists?("/opt/ruby1.9/bin/ruby") &&
       system("/opt/ruby1.9/bin/ruby --version | grep -q '1.9.3p320'"))
  end
end

# Install ruby from source unless it already exists at the correct
# version
#
bash "install ruby-1.9.2" do
  cwd "/tmp"
  code <<-EOH
tar zxf ruby-1.9.3-p320.tar.gz
cd ruby-1.9.3-p320
./configure --prefix=/opt/ruby1.9
make
make install
EOH
  not_if do
    ::File.exists?("/opt/ruby1.9/bin/ruby") &&
      system("/opt/ruby1.9/bin/ruby --version | grep -q '1.9.2p180'")
  end
end

# Download the source for Rubygems 1.8.5 unless:
# * the source file already exists
# * rubygems 1.8.5 is installed to ruby 1.9.2
#

rubygems_version = "1.8.12"

remote_file "/tmp/rubygems-#{rubygems_version}.tgz" do
  source "http://production.cf.rubygems.org/rubygems/rubygems-#{rubygems_version}.tgz"
  not_if do
    ::File.exists?("/tmp/rubygems-#{rubygems_version}.tgz") ||
      (::File.exists?("/opt/ruby1.9/bin/gem") &&
       system("/opt/ruby1.9/bin/gem --version | grep -q '#{rubygems_version}'"))
  end
end

# Install rubygems from source only if we need to
#
bash "install rubygems-#{rubygems_version} on ruby-1.9.2" do
  cwd "/tmp"
  code <<-EOH
tar zxf rubygems-#{rubygems_version}.tgz
cd rubygems-#{rubygems_version}
/opt/ruby1.9/bin/ruby setup.rb --no-rdoc --no-ri
EOH
  not_if do
    ::File.exists?("/opt/ruby1.9/bin/gem") &&
      system("/opt/ruby1.9/bin/gem --version | grep -q '#{rubygems_version}'")
  end
end

gem_package "1.9-bundler" do
  package_name "bundler"
  version "1.0.18"
  gem_binary "/opt/ruby1.9/bin/gem"
end<commit_msg>More complete fix for 1.9.3<commit_after>#
# Author::        <NAME>
# Copyright:: Copyright (c) 2012 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# -*- coding: utf-8 -*-
#

include_recipe "build-essential"

# ensure ruby1.9 builds with openssl gem
case node[:platform]
when "ubuntu", "debian"
  package "libssl-dev"
end

# Download the ruby source for 1.9.3. Skip the download if:
# * the source file already exists
# * ruby 1.9.3 has been installed at the specified patch-level
#
remote_file "/tmp/ruby-1.9.3-p320.tar.gz" do
  source "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p320.tar.gz"
  not_if do
    ::File.exists?("/tmp/ruby-1.9.3-p320.tar.gz") ||
      (::File.exists?("/opt/ruby1.9/bin/ruby") &&
       system("/opt/ruby1.9/bin/ruby --version | grep -q '1.9.3p320'"))
  end
end

# Install ruby from source unless it already exists at the correct
# version
#
bash "install ruby-1.9.3" do
  cwd "/tmp"
  code <<-EOH
tar zxf ruby-1.9.3-p320.tar.gz
cd ruby-1.9.3-p320
./configure --prefix=/opt/ruby1.9
make
make install
EOH
  not_if do
    ::File.exists?("/opt/ruby1.9/bin/ruby") &&
      system("/opt/ruby1.9/bin/ruby --version | grep -q '1.9.3p320'")
  end
end

gem_package "1.9-bundler" do
  package_name "bundler"
  version "1.0.18"
  gem_binary "/opt/ruby1.9/bin/gem"
end
{'fraction_non_alphanumeric': 0.14839688041594454, 'fraction_numerical': 0.042677642980935876, 'mean_word_length': 3.3189897100093546, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '394183', 'n_tokens_mistral': 1794, 'n_tokens_neox': 1671, 'n_words': 481}