Unnecessary whitespace removal

This commit is contained in:
Andrew Brown 2016-05-24 13:20:17 -05:00
parent f1f8c010a6
commit 7b6e8fe6a8
1 changed files with 24 additions and 24 deletions

View File

@ -20,34 +20,34 @@ module Treat::Core::Installer
:bin => File.absolute_path(Treat.paths.bin),
:models => File.absolute_path(Treat.paths.models)
}
# Install required dependencies and optional
# dependencies for a specific language.
def self.install(language = 'english')
# Require the Rubygem dependency installer.
silence_warnings do
require 'rubygems/dependency_installer'
end
@@installer = Gem::DependencyInstaller.new
if language == 'travis'
install_travis; return
end
l = "#{language.to_s.capitalize} language"
puts "\nTreat Installer, v. #{Treat::VERSION.to_s}\n\n"
begin
title "Installing core dependencies."
install_language_dependencies('agnostic')
title "Installing dependencies for the #{l}.\n"
install_language_dependencies(language)
# If gem is installed only, download models.
begin
Gem::Specification.find_by_name('punkt-segmenter')
@ -73,7 +73,7 @@ module Treat::Core::Installer
end
end
# Minimal install for Travis CI.
def self.install_travis
install_language_dependencies(:agnostic)
@ -81,7 +81,7 @@ module Treat::Core::Installer
download_stanford(:minimal)
download_punkt_models(:english)
end
def self.install_language_dependencies(language)
dependencies = Treat.languages[language].dependencies
@ -92,31 +92,31 @@ module Treat::Core::Installer
end
def self.download_stanford(package = :minimal)
f = StanfordPackages[package]
url = "http://#{Server}/treat/#{f}"
loc = Schiphol.download(url,
loc = Schiphol.download(url,
download_folder: Treat.paths.tmp
)
puts "- Unzipping package ..."
dest = File.join(Treat.paths.tmp, 'stanford')
unzip_stanford(loc, dest)
model_dir = File.join(Paths[:models], 'stanford')
bin_dir = File.join(Paths[:bin], 'stanford')
origin = File.join(Paths[:tmp], 'stanford')
# Mac hidden files fix.
mac_remove = File.join(dest, '__MACOSX')
if File.readable?(mac_remove)
FileUtils.rm_rf(mac_remove)
end
unless File.readable?(bin_dir)
puts "- Creating directory bin/stanford ..."
FileUtils.mkdir_p(bin_dir)
end
unless File.readable?(model_dir)
puts "- Creating directory models/stanford ..."
FileUtils.mkdir_p(model_dir)
@ -127,18 +127,18 @@ module Treat::Core::Installer
Dir.glob(File.join(origin, '*')) do |f|
next if ['.', '..'].include?(f)
if f.index('jar')
FileUtils.cp(f, File.join(Paths[:bin],
FileUtils.cp(f, File.join(Paths[:bin],
'stanford', File.basename(f)))
elsif FileTest.directory?(f)
FileUtils.cp_r(f, model_dir)
end
end
puts "- Cleaning up..."
FileUtils.rm_rf(origin)
'Done.'
end
def self.download_punkt_models(language)
@ -146,7 +146,7 @@ module Treat::Core::Installer
f = "#{language}.yaml"
dest = "#{Treat.paths.models}punkt/"
url = "http://#{Server}/treat/punkt/#{f}"
loc = Schiphol.download(url,
loc = Schiphol.download(url,
download_folder: Treat.paths.tmp
)
unless File.readable?(dest)
@ -156,7 +156,7 @@ module Treat::Core::Installer
puts "- Copying model file to models/punkt ..."
FileUtils.cp(loc, File.join(Paths[:models], 'punkt', f))
puts "- Cleaning up..."
FileUtils.rm_rf(Paths[:tmp] + Server)
@ -185,7 +185,7 @@ module Treat::Core::Installer
puts "Warning: couldn't install " +
"gem '#{dependency}' (#{error.message})."
end
end
# Unzip a file to the destination path.
@ -193,7 +193,7 @@ module Treat::Core::Installer
require 'zip/zip'
f_path = ''
Zip::ZipFile.open(file) do |zip_file|
zip_file.each do |f|
f_path = File.join(destination, f.name)