Sha256: 7d7b46e2e1b80285a2a80369c661c15f17f77a7d62cabc47bc04fde970590106

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require 'forwardable'
require 'arli'
require_relative 'actions'

module Arli
  class Installer
    include ::Arli::Output

    extend Forwardable
    def_delegators :@library, :exists?

    attr_accessor :library, :config

    def initialize(library, config: Arli.config)
      self.config  = config
      self.library = library
    end

    def install
      ___ "#{library.name.blue} "

      if library.nil? && library.library.nil?
        ___ ' (no library) '
        fuck
      elsif library.url.nil?
        ___ ' (no url) '
        fuck
      else
        ___ "(#{library.version.green}) " if library.version
        actions(library).each do |action|
          run_action(action)
        end
      end
      ___ "\n"
    end

    def run_action(action)
      klass = Arli::Actions.action(action)
      klass.new(library, config: config).act if klass
    end

    def actions(library)
      actions = []
      actions << :backup if exists?
      # First, how do we get the library?
      actions << ((library.url =~ /\.zip$/i) ? :zip_file : :git_repo)
      actions << :dir_name
      actions
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arli-0.6.1 lib/arli/installer.rb