Sha256: 510ef362b3126159eb91725eb7cd318fd41fe575fa4ba9530479a623650232ed

Contents?: true

Size: 1.92 KB

Versions: 19

Compression:

Stored size: 1.92 KB

Contents

#
# Copyright 2012 Mortar Data Inc.
#
# 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.
#

require "mortar/local/installutil"
require "mortar/helpers"

class Mortar::Local::Jython
  include Mortar::Local::InstallUtil
  include Mortar::Helpers

  JYTHON_VERSION = '2.5.2'
  JYTHON_JAR_NAME = 'jython_installer-' + JYTHON_VERSION + '.jar'
  JYTHON_JAR_DEFAULT_URL_PATH = "resource/jython"

  def install_or_update
    if should_install
      action("Installing jython to #{local_install_directory_name}") do
        install
      end
    elsif should_update
      action("Updating jython in #{local_install_directory_name}") do
        update
      end
    end
  end

  def should_install
    not File.exists?(jython_directory)
  end

  def install
    jython_file = File.join(local_install_directory, JYTHON_JAR_NAME)
    unless File.exists?(jython_file)
        download_file(jython_jar_url, jython_file)
    end

    `$JAVA_HOME/bin/java -jar #{local_install_directory + '/' + JYTHON_JAR_NAME} -s -d #{jython_directory}`
    FileUtils.mkdir_p jython_cache_directory
    FileUtils.chmod_R 0777, jython_cache_directory

    FileUtils.rm(jython_file)
    note_install('jython')
  end

  def should_update
    return is_newer_version('jython', jython_jar_url)
  end

  def update
    FileUtils.rm_r(jython_directory)
    install
  end

  def jython_jar_url
    default_url = full_host + "/" + JYTHON_JAR_DEFAULT_URL_PATH
    ENV.fetch('JYTHON_JAR_URL', default_url)
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
mortar-0.15.53 lib/mortar/local/jython.rb
mortar-0.15.52 lib/mortar/local/jython.rb
mortar-0.15.51 lib/mortar/local/jython.rb
mortar-0.15.50 lib/mortar/local/jython.rb
mortar-0.15.49 lib/mortar/local/jython.rb
mortar-0.15.48 lib/mortar/local/jython.rb
mortar-0.15.47 lib/mortar/local/jython.rb
mortar-0.15.46 lib/mortar/local/jython.rb
mortar-0.15.45 lib/mortar/local/jython.rb
mortar-0.15.44 lib/mortar/local/jython.rb
mortar-0.15.43 lib/mortar/local/jython.rb
mortar-0.15.42 lib/mortar/local/jython.rb
mortar-0.15.41 lib/mortar/local/jython.rb
mortar-0.15.40 lib/mortar/local/jython.rb
mortar-0.15.39 lib/mortar/local/jython.rb
mortar-0.15.38 lib/mortar/local/jython.rb
mortar-0.15.37 lib/mortar/local/jython.rb
mortar-0.15.36 lib/mortar/local/jython.rb
mortar-0.15.35 lib/mortar/local/jython.rb