Class: AIA::Tools

Inherits:
Object
  • Object
show all
Defined in:
lib/aia/tools.rb

Direct Known Subclasses

Client, Editor, Fzf, Glow, Llm, Mods, Sgpt, Subl, Vim

Constant Summary collapse

@@catalog =
[]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.catalogObject



41
42
43
# File 'lib/aia/tools.rb', line 41

def catalog
  @@catalog
end

.get_metaObject



29
30
31
# File 'lib/aia/tools.rb', line 29

def get_meta
  @_metadata
end

.inherited(subclass) ⇒ Object



11
12
13
14
15
16
# File 'lib/aia/tools.rb', line 11

def inherited(subclass)
  subclass_meta = Hashie::Mash.new(klass: subclass)
  subclass.instance_variable_set(:@_metadata, subclass_meta)

  @@catalog << subclass_meta
end

.load_toolsObject



46
47
48
49
50
# File 'lib/aia/tools.rb', line 46

def load_tools
  Dir.glob(File.join(File.dirname(__FILE__), 'tools', '*.rb')).each do |file|
    require file
  end
end

.meta(metadata = nil) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/aia/tools.rb', line 19

def meta( = nil)
  return @_metadata if .nil?

  @_metadata  = Hashie::Mash.new()
  entry       = @@catalog.detect { |item| item[:klass] == self }
  
  entry.merge!() if entry
end

.search_for(criteria = {}) ⇒ Object



34
35
36
37
38
# File 'lib/aia/tools.rb', line 34

def search_for(criteria = {})
  @@catalog.select do |meta|
    criteria.all? { |k, v| meta[k] == v }
  end
end

.setup_backendObject



58
59
60
# File 'lib/aia/tools.rb', line 58

def setup_backend
  AIA.config.tools.backend = find_and_initialize_backend
end

.validate_toolsObject



53
54
55
# File 'lib/aia/tools.rb', line 53

def validate_tools
  raise "NotImplemented"
end

Instance Method Details

#metaObject



8
# File 'lib/aia/tools.rb', line 8

def meta = self.class::meta