Class: Aquatone::Collector

Inherits:
Object
  • Object
show all
Defined in:
lib/aquatone/collector.rb

Defined Under Namespace

Classes: Error, InvalidMetadataError, MetadataNotSetError, MissingKeyRequirement

Constant Summary collapse

DEFAULT_PRIORITY =
1

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain, options) ⇒ Collector

Returns a new instance of Collector.



35
36
37
38
39
40
41
# File 'lib/aquatone/collector.rb', line 35

def initialize(domain, options)
  check_key_requirements!
  @domain          = domain
  @options         = options
  @hosts           = []
  @host_dictionary = {}
end

Instance Attribute Details

#domainObject (readonly)

Returns the value of attribute domain.



8
9
10
# File 'lib/aquatone/collector.rb', line 8

def domain
  @domain
end

#hostsObject (readonly)

Returns the value of attribute hosts.



8
9
10
# File 'lib/aquatone/collector.rb', line 8

def hosts
  @hosts
end

Class Method Details

.cli_optionsObject



26
27
28
# File 'lib/aquatone/collector.rb', line 26

def self.cli_options
  meta.key?(:cli_options) ? meta[:cli_options] : {}
end

.descendantsObject



21
22
23
24
# File 'lib/aquatone/collector.rb', line 21

def self.descendants
  collectors = ObjectSpace.each_object(Class).select { |klass| klass < self }
  collectors.sort { |x, y| x.priority <=> y.priority }
end

.metaObject



12
13
14
# File 'lib/aquatone/collector.rb', line 12

def self.meta
  @meta || fail(MetadataNotSetError, "Metadata has not been set")
end

.meta=(meta) ⇒ Object



16
17
18
19
# File 'lib/aquatone/collector.rb', line 16

def self.meta=(meta)
  (meta)
  @meta = meta
end

.priorityObject



52
53
54
# File 'lib/aquatone/collector.rb', line 52

def self.priority
  meta[:priority] || DEFAULT_PRIORITY
end

.sluggified_nameObject



30
31
32
33
# File 'lib/aquatone/collector.rb', line 30

def self.sluggified_name
  return meta[:slug].downcase if meta[:slug]
  meta[:name].strip.downcase.gsub(/[^a-z0-9]+/, '-').gsub("--", "-")
end

Instance Method Details

#execute!Object



47
48
49
50
# File 'lib/aquatone/collector.rb', line 47

def execute!
  run
  hosts
end

#runObject



43
44
45
# File 'lib/aquatone/collector.rb', line 43

def run
  fail NotImplementedError
end