Sha256: 11b0fe04512e20cbe22a500fc3fb346c495cb2f9fa60c802e8624d6769987b0c

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

require 'awesome_print'
require 'arli/errors'

require_relative 'installer'
require_relative 'multi_version'

module Arli
  module Library
    # Represents a wrapper around Arduino::Library::Model instance
    # and decorates with a few additional helpers.
    class SingleVersion
      attr_accessor :lib,
                    :lib_dir,
                    :canonical_dir,
                    :config

      def initialize(lib, config: Arli.config)
        self.lib     = lib
        self.config  = config
        self.lib_dir = lib.name.gsub(/ /, '_')
      end

      def install
        installer.install
      end

      def installer
        @installer ||= Installer.new(self)
      end

      def libraries_home
        config.libraries.path
      end

      def temp_dir
        config.libraries.temp_dir
      end

      def dir
        canonical_dir || lib_dir
      end

      def path
        libraries_home + '/' + dir
      end

      def temp_path
        temp_dir + '/' + dir
      end

      def exists?
        Dir.exist?(path)
      end

      def method_missing(method, *args, &block)
        if lib && lib.respond_to?(method)
          lib.send(method, *args, &block)
        else
          super(method, *args, &block)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arli-1.0.0 lib/arli/library/single_version.rb
arli-0.9.0 lib/arli/library/single_version.rb