Sha256: 6c2aa4f9c3fb00f4b18b71d780697a7b9131864d773763a1b0defd47c8433a8e

Contents?: true

Size: 991 Bytes

Versions: 8

Compression:

Stored size: 991 Bytes

Contents

require 'json'
require 'fileutils'
require 'open3'
require 'arli'
require 'arli/version'
require 'arli/errors'
require 'arli/helpers/output'

module Arli
  module Commands
    class Base
      include Arli::Helpers::Output

      attr_accessor :config, :name

      def initialize(config: Arli.config)
        self.config = config
        setup
      end

      def runtime
        config.runtime
      end

      def name
        @name ||= self.class.name.gsub(/.*::/, '').downcase.to_sym
      end

      def library_path
        config.libraries.path
      end

      def temp_path
        config.libraries.temp_dir
      end

      def setup
        FileUtils.mkdir_p(library_path) unless Dir.exist?(library_path)
        FileUtils.mkdir_p(temp_path) unless Dir.exist?(temp_path)
      end

      def run(*args)
        raise Arli::Errors::AbstractMethodCalled,
          'This method must be implemented in subclasses'
      end

      def params
        ''
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
arli-1.4.0 lib/arli/commands/base.rb
arli-1.3.0 lib/arli/commands/base.rb
arli-1.2.1 lib/arli/commands/base.rb
arli-1.1.0 lib/arli/commands/base.rb
arli-1.0.2 lib/arli/commands/base.rb
arli-1.0.1 lib/arli/commands/base.rb
arli-1.0.0 lib/arli/commands/base.rb
arli-0.9.0 lib/arli/commands/base.rb