Class: INGM::Handler::Crep
- Inherits:
-
Chef::Handler::JsonFile
- Object
- Chef::Handler::JsonFile
- INGM::Handler::Crep
- Defined in:
- lib/ingm/handler/crep.rb
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ Crep
constructor
A new instance of Crep.
- #report ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Crep
Returns a new instance of Crep.
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
#report ⇒ Object
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_s ⇒ Object
21 22 23 |
# File 'lib/ingm/handler/crep.rb', line 21 def to_s "path => #{@config[:path]}\nserver => #{@config[:server]}" end |