Class: INGM::Handler::Crep

Inherits:
Chef::Handler::JsonFile
  • Object
show all
Defined in:
lib/ingm/handler/crep.rb

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Crep

Returns a new instance of Crep.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
# File 'lib/ingm/handler/crep.rb', line 5

def initialize(config={})
  @config = config
  raise ArgumentError, 'No server to report specified' unless @config[:server]
  @config[:path] ||= '/var/chef/reports'
  super @config
end

Instance Method Details

#reportObject



12
13
14
15
16
17
18
19
# File 'lib/ingm/handler/crep.rb', line 12

def report
  super
  f = Dir.glob("#{@config[:path]}/*").sort_by { |f| File.ctime f }.last
  opt = { :headers => { 'Content-Type' => 'application/json'},
          :body => IO.read(f) 
        }
  HTTParty.post @config[:server], opt
end

#to_sObject



21
22
23
# File 'lib/ingm/handler/crep.rb', line 21

def to_s
  "path => #{@config[:path]}\nserver => #{@config[:server]}"
end