class Marmottawrapper

Constants

VERSION

Public Class Methods

app_root() click to toggle source
# File lib/marmottawrapper.rb, line 12
def app_root
  return @app_root if @app_root
  @app_root = Rails.root if defined?(Rails) and defined?(Rails.root)
  @app_root ||= '.'
end
clean() click to toggle source
# File lib/marmottawrapper.rb, line 38
def clean
  File.delete(tarball) if File.exists?(tarball)
  FileUtils.rm_rf(tomcat_dir) if File.directory?(tomcat_dir)
  FileUtils.rm_rf(marmotta_dir) if File.directory?(marmotta_dir)
end
fetch() click to toggle source

Fetch the Tomcat/Marmotta distribution

# File lib/marmottawrapper.rb, line 46
def fetch
  File.delete(tarball) if File.exists?(tarball)
  FileUtils.makedirs(tmp_dir) unless File.directory?(tmp_dir)
  open(tarball, 'wb') do |tm|
    tm.write(open(url).read)
  end
end
install() click to toggle source
# File lib/marmottawrapper.rb, line 54
def install
  fetch unless File.exists?(tarball)
  FileUtils.makedirs(marmotta_dir) unless File.directory?(marmotta_dir)
  tb = Zlib::GzipReader.new(File.open(tarball, 'rb'))
  Archive::Tar::Minitar.unpack(tb, app_root.to_s)
end
marmotta_dir() click to toggle source
# File lib/marmottawrapper.rb, line 22
def marmotta_dir
  File.join(app_root, 'marmotta')
end
start() click to toggle source

Start the Tomcat server with Marmotta

# File lib/marmottawrapper.rb, line 63
def start
  system "MARMOTTA_HOME=#{marmotta_dir} #{tomcat_dir}/bin/startup.sh"
end
stop() click to toggle source

Stop Tomcat/Marmotta

# File lib/marmottawrapper.rb, line 69
def stop
  system "MARMOTTA_HOME=#{marmotta_dir} #{tomcat_dir}/bin/shutdown.sh"
end
tarball() click to toggle source
# File lib/marmottawrapper.rb, line 34
def tarball
  File.join(tmp_dir, 'tomcat-marmotta.tgz')
end
tmp_dir() click to toggle source
# File lib/marmottawrapper.rb, line 26
def tmp_dir
  File.join(app_root, 'tmp')
end
tomcat_dir() click to toggle source
# File lib/marmottawrapper.rb, line 30
def tomcat_dir
  File.join(app_root, 'tomcat')
end
url() click to toggle source
# File lib/marmottawrapper.rb, line 18
def url
  @url ||= defined?(MARMOTTA_TARBALL_URL) ? MARMOTTA_TARBALL_URL : "https://github.com/dpla/marmottawrapper/releases/download/v0.0.5/tomcat-marmotta.tgz"
end