Sha256: f11ff2c8ebbc95367baeda13a5608364854d1798855705ce27daf517fa41f287

Contents?: true

Size: 668 Bytes

Versions: 2

Compression:

Stored size: 668 Bytes

Contents

require 'json'

module Heartcheck
  module Checks
    class WatchFile < Base
      def add_service(options)
        services << options.merge(runtime: installed(options[:file]))
      end

      def validate
        services.each do |service|
          if not service[:runtime].eql? installed(service[:file])
            @errors << "App outdated, check info for the diff"
          end
        end
      end

      def info
        services.collect do |service|
          { runtime: service[:runtime], installed: installed(service[:file]) }
        end
      end

      private

      def installed(file)
        JSON.parse open(file).read
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
heartcheck-1.0.5 lib/heartcheck/checks/watch_file.rb
heartcheck-1.0.4 lib/heartcheck/checks/watch_file.rb