Sha256: 220ab8ed344bc67122054b26a320be469f007ef2b4752c09ce0f81af9b249816

Contents?: true

Size: 871 Bytes

Versions: 26

Compression:

Stored size: 871 Bytes

Contents

module Avo
  class Plugin
    attr_reader :name
    attr_reader :priority

    delegate :version, :namespace, :engine, to: :class

    def initialize(*, name:, priority:, **, &block)
      @name = name
      @priority = priority
    end

    def to_s
      "#{name}-#{version}"
    end

    class << self
      def name
        return gemspec.name if gemspec.present?

        self.to_s.split("::").first
      end

      def version
        "#{namespace}::VERSION".safe_constantize
      end

      def engine
        "#{namespace}::Engine".safe_constantize
      end

      def namespace
        modules = to_s.split("::")
        modules.pop
        modules.join("::")
      end

      def gemspec
        return if engine.blank?

        gemspec_path = Dir["#{engine.root}/*.gemspec"].first

        Gem::Specification::load(gemspec_path)
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
avo-3.16.4 lib/avo/plugin.rb
avo-3.16.3 lib/avo/plugin.rb
avo-3.16.2 lib/avo/plugin.rb
avo-3.16.1 lib/avo/plugin.rb
avo-3.16.0 lib/avo/plugin.rb
avo-3.15.7 lib/avo/plugin.rb
avo-3.15.6 lib/avo/plugin.rb
avo-3.15.5 lib/avo/plugin.rb
avo-3.15.4 lib/avo/plugin.rb
avo-3.15.3 lib/avo/plugin.rb
avo-3.15.2 lib/avo/plugin.rb
avo-3.15.1 lib/avo/plugin.rb
avo-3.15.0 lib/avo/plugin.rb
avo-3.14.5 lib/avo/plugin.rb
avo-3.14.4 lib/avo/plugin.rb
avo-3.14.3 lib/avo/plugin.rb
avo-3.14.2 lib/avo/plugin.rb
avo-3.14.1 lib/avo/plugin.rb
avo-3.14.0 lib/avo/plugin.rb
avo-3.13.7 lib/avo/plugin.rb