Class: GRI::Updater

Inherits:
Object show all
Includes:
Utils
Defined in:
lib/gri/updater.rb

Direct Known Subclasses

RRDUpdater

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils

get_prop, key_encode, load_records, parse_host_key, parse_key, search_records, update_ltsv_file, url_encode

Constructor Details

#initialize(options = {}) ⇒ Updater

Returns a new instance of Updater.



41
42
43
44
45
# File 'lib/gri/updater.rb', line 41

def initialize options={}
  @options = options
  @interval = options[:step] || options[:interval] || 300
  @config = GRI::Config
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/gri/updater.rb', line 11

def options
  @options
end

Class Method Details

.get_tag_ary(description) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/gri/updater.rb', line 13

def self.get_tag_ary description
  unless @tag_pats
    @tag_pats = (pats = GRI::Config.getvar 'tag-rule') ?
    pats.map {|patline| pat, *remain =
        patline.scan(/^\/([^\/]+)\/\s+(\S+)\s+(\S+)\s+(\S+)/)[0] #/
      [Regexp.new(pat), *remain]} : []
  end
  @tag_pats.map {|re, group, subdir, descr_v|
    if re === description
      m = $~.to_a
      if group =~ /^\$(\d+)(\.\w+)?/
        group = m[$1.to_i].dup
        group.downcase! if $2 == '.downcase'
      end
      if subdir =~ /^\$(\d+)(\.\w+)?/
        subdir = m[$1.to_i].dup
        subdir.downcase! if $2 == '.downcase'
      end
      if descr_v =~ /^\$(\d+)/
        descr_v = m[$1.to_i]
      end
      [group, subdir, descr_v]
    else
      nil
    end
  }.compact
end

Instance Method Details

#update(time, record) ⇒ Object



47
48
# File 'lib/gri/updater.rb', line 47

def update time, record
end