Class: Linguist::BasicInstrumenter

Inherits:
Object
  • Object
show all
Defined in:
lib/linguist/instrumenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBasicInstrumenter

Returns a new instance of BasicInstrumenter.



5
6
7
# File 'lib/linguist/instrumenter.rb', line 5

def initialize
  @detected_info = {}
end

Instance Attribute Details

#detected_infoObject (readonly)

Returns the value of attribute detected_info.



3
4
5
# File 'lib/linguist/instrumenter.rb', line 3

def detected_info
  @detected_info
end

Instance Method Details

#instrument(name, payload = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/linguist/instrumenter.rb', line 9

def instrument(name, payload = {})
  if name == "linguist.detected" && payload[:blob]
    @detected_info[payload[:blob].name] = {
      strategy: payload[:strategy].name.split("::").last,
      language: payload[:language]&.name
    }
  end
  yield if block_given?
end