Class: Blocktrain::Lookups
- Inherits:
-
Object
- Object
- Blocktrain::Lookups
- Includes:
- Singleton
- Defined in:
- lib/blocktrain/lookups.rb
Instance Method Summary collapse
- #aliases ⇒ Object
-
#init! ⇒ Object
Separate out initialization for testing purposes.
- #lookups ⇒ Object
- #reset! ⇒ Object
Instance Method Details
#aliases ⇒ Object
10 11 12 13 |
# File 'lib/blocktrain/lookups.rb', line 10 def aliases init! if @aliases.nil? @aliases end |
#init! ⇒ Object
Separate out initialization for testing purposes
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/blocktrain/lookups.rb', line 20 def init! @lookups ||= {} @aliases ||= {} # Get unique list of keys from ES r = Aggregations::TermsAggregation.new(from: '2015-09-01 00:00:00Z', to: '2015-09-02 00:00:00Z', term: "memoryAddress").results addresses = r.map {|x| x["key"]} # Get a memory location for each key addresses.each do |address| r = Query.new(from: '2015-09-01 10:00:00Z', to: '2015-09-30 11:00:00Z', memory_addresses: address, limit: 1).results signal_name = remove_cruft(r.first["_source"]["signalName"].to_s) @lookups[signal_name] = address end # Read aliases from file aliases = OpenStruct.new fetch_yaml 'signal_aliases' aliases.each_pair do |key, value| @aliases[key.to_s] = @lookups[value] @lookups[key.to_s] = @lookups[value] end end |
#lookups ⇒ Object
5 6 7 8 |
# File 'lib/blocktrain/lookups.rb', line 5 def lookups init! if @lookups.nil? @lookups end |
#reset! ⇒ Object
15 16 17 |
# File 'lib/blocktrain/lookups.rb', line 15 def reset! @lookups = nil end |