Class: Avo::Plugin

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Plugin

Returns a new instance of Plugin.



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

def initialize(*, **, &block)
end

Class Method Details

.engineObject



17
18
19
# File 'lib/avo/plugin.rb', line 17

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

.gemspecObject



27
28
29
30
31
32
33
# File 'lib/avo/plugin.rb', line 27

def gemspec
  return if engine.blank?

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

  Gem::Specification::load(gemspec_path)
end

.nameObject



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

def name
  return gemspec.name if gemspec.present?

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

.namespaceObject



21
22
23
24
25
# File 'lib/avo/plugin.rb', line 21

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

.versionObject



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

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