Class: IParty::Config

Inherits:
Struct
  • Object
show all
Defined in:
lib/iparty/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#account_idObject

Returns the value of attribute account_id

Returns:

  • (Object)

    the current value of account_id



4
5
6
# File 'lib/iparty/config.rb', line 4

def 
  @account_id
end

#annotationsObject

Returns the value of attribute annotations

Returns:

  • (Object)

    the current value of annotations



4
5
6
# File 'lib/iparty/config.rb', line 4

def annotations
  @annotations
end

#directoryObject

Returns the value of attribute directory

Returns:

  • (Object)

    the current value of directory



4
5
6
# File 'lib/iparty/config.rb', line 4

def directory
  @directory
end

#eager_loadObject

Returns the value of attribute eager_load

Returns:

  • (Object)

    the current value of eager_load



4
5
6
# File 'lib/iparty/config.rb', line 4

def eager_load
  @eager_load
end

#editionsObject

Returns the value of attribute editions

Returns:

  • (Object)

    the current value of editions



4
5
6
# File 'lib/iparty/config.rb', line 4

def editions
  @editions
end

#ipv6_significantObject

Returns the value of attribute ipv6_significant

Returns:

  • (Object)

    the current value of ipv6_significant



4
5
6
# File 'lib/iparty/config.rb', line 4

def ipv6_significant
  @ipv6_significant
end

#license_keyObject

Returns the value of attribute license_key

Returns:

  • (Object)

    the current value of license_key



4
5
6
# File 'lib/iparty/config.rb', line 4

def license_key
  @license_key
end

#local_ip_aliasObject

Returns the value of attribute local_ip_alias

Returns:

  • (Object)

    the current value of local_ip_alias



4
5
6
# File 'lib/iparty/config.rb', line 4

def local_ip_alias
  @local_ip_alias
end

#mirrorObject

Returns the value of attribute mirror

Returns:

  • (Object)

    the current value of mirror



4
5
6
# File 'lib/iparty/config.rb', line 4

def mirror
  @mirror
end

#singletonsObject

Returns the value of attribute singletons

Returns:

  • (Object)

    the current value of singletons



4
5
6
# File 'lib/iparty/config.rb', line 4

def singletons
  @singletons
end

#url_to_mmdbObject

Returns the value of attribute url_to_mmdb

Returns:

  • (Object)

    the current value of url_to_mmdb



4
5
6
# File 'lib/iparty/config.rb', line 4

def url_to_mmdb
  @url_to_mmdb
end

Instance Method Details

#annotate(*args, **kw) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/iparty/config.rb', line 34

def annotate *args, **kw
  self[:annotations] ||= {}
  result = {}
  IParty.expand_hostnames(args).each do |net|
    ipp = IParty(net)
    kw[:tags] = ((result[ipp] || self[:annotations][ipp] || {})[:tags] || []) | kw[:tags] if kw.key?(:tags)
    result[ipp] = (result[ipp] || self[:annotations][ipp] || {}).merge(kw)
  end
  self[:annotations].merge!(result)
  result
end

#annotate_tag(tags, *args) ⇒ Object



46
47
48
49
50
51
52
53
54
55
# File 'lib/iparty/config.rb', line 46

def annotate_tag tags, *args
  self[:annotations] ||= {}
  IParty.expand_hostnames(args).to_h do |net|
    ipp = IParty(net)
    self[:annotations][ipp] ||= {}
    self[:annotations][ipp][:tags] ||= []
    self[:annotations][ipp][:tags] |= Array(tags)
    [net, self[:annotations][ipp][:tags]]
  end
end

#env_value(*args, **kw, &block) ⇒ Object



30
31
32
# File 'lib/iparty/config.rb', line 30

def env_value *args, **kw, &block
  IParty.env_value(*args, **kw, &block)
end

#init_singletons!Object



23
24
25
26
27
28
# File 'lib/iparty/config.rb', line 23

def init_singletons!
  self[:singletons] = {} if !self[:singletons] || self[:singletons] == true

  editions.each {|edition| IParty::MaxMind.db(edition) }
  self[:singletons]
end