Class: Avo::Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/avo/plugin.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, priority:, &block) ⇒ Plugin

Returns a new instance of Plugin.



8
9
10
11
# File 'lib/avo/plugin.rb', line 8

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/avo/plugin.rb', line 3

def name
  @name
end

#priorityObject (readonly)

Returns the value of attribute priority.



4
5
6
# File 'lib/avo/plugin.rb', line 4

def priority
  @priority
end

Class Method Details

.engineObject



28
29
30
# File 'lib/avo/plugin.rb', line 28

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

.gemspecObject



38
39
40
41
42
43
44
# File 'lib/avo/plugin.rb', line 38

def gemspec
  return if engine.blank?

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

  Gem::Specification::load(gemspec_path)
end

.nameObject



18
19
20
21
22
# File 'lib/avo/plugin.rb', line 18

def name
  return gemspec.name if gemspec.present?

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

.namespaceObject



32
33
34
35
36
# File 'lib/avo/plugin.rb', line 32

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

.versionObject



24
25
26
# File 'lib/avo/plugin.rb', line 24

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

Instance Method Details

#to_sObject



13
14
15
# File 'lib/avo/plugin.rb', line 13

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