Sha256: fab6d104814c2aec83c45b546cd1375cd7c9659538b2b71cf6e24b3cfab589cf

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 KB

Contents

module Transcriptic
  class SBT
    class << self
      include Transcriptic::UI

      def compile
        ensure_installed
        sbt("package")
      end

      def stage
        ensure_installed
        sbt("stage")
      end

      def update
        ensure_installed
        sbt("update")
      end

      private
      def ensure_installed
        stat = `which sbt`
        if stat.empty?
          output_with_arrow "Downloading sbt..."
          Transcriptic::SBT::Installer.new(["/usr/local"], {}).invoke_all
        end
      end

      def sbt(action)
        base = Transcriptic.find_labfile.dirname
        output_with_arrow "Detected Scala sources in app..."
        output_with_arrow "Compiling..."
        display

        code = IO.popen("sbt #{action}") do |stream|
          stream.each do |line|
            output_with_indent line
          end
        end

        display

        if 0 == $?
          output_with_arrow "Compilation succeeded."
          true
        else
          output_with_arrow "Errors occurred!"
          false
        end
      end
    end
    
    class Installer < BaseGenerator
      def install
        get "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.12.3/sbt-launch.jar",
          target.join("sbt/sbt-launch.jar")
        copy_file 'sbt', target.join('bin/sbt')
        chmod target.join('bin/sbt'), 0755
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
transcriptic-0.2.5 lib/transcriptic/sbt.rb
transcriptic-0.2.4 lib/transcriptic/sbt.rb
transcriptic-0.2.3 lib/transcriptic/sbt.rb