Sha256: ee2cc7d623e55ce2406a08e8d331669579e7e8d6d98b7e5ddf7a88b9288cb1f1

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

require 'larrow/runner/manifest/base_loader'
require 'larrow/runner/manifest/configuration'

module Larrow
  module Runner
    # support multiple manifest style, such as travis, larrow, etc...
    module Manifest
      # Adapters is a set of class to adapt different manifest style.
      # There isn't Adapter module, these classes are under Manifest module.
      autoload :Travis, 'larrow/runner/manifest/adapter/travis'
      autoload :Larrow, 'larrow/runner/manifest/adapter/larrow'
      autoload :Blank,  'larrow/runner/manifest/adapter/blank'

      extend self

      def configuration source_accessor
        [ Larrow, Travis, Blank ].each do |clazz|
          configuration = clazz.new(source_accessor).load
          return configuration if configuration
        end
      end

      def add_base_scripts configuration,source_accessor
        configuration.add_source_sync source_accessor
        unless configuration.image
          lines = <<-EOF
#{package_update}
#{bashrc_cleanup}
          EOF
          scripts = lines.split(/\n/).map{|s| Script.new s}
          configuration.insert_to_step :init, scripts
        end
      end

      def package_update
        <<-EOF
apt-get update -qq
apt-get install git libssl-dev build-essential curl libncurses5-dev -y -qq
        EOF
      end

      # remove PS1 check, for user to make ssh connection without tty
      def bashrc_cleanup
        "sed '/$PS1/ d' -i /root/.bashrc"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
larrow-runner-0.0.1 lib/larrow/runner/manifest.rb