class R2OAS::Schema::Monitor
Attributes
unit_paths_file_path[RW]
Public Class Methods
new(before_schema_data, options)
click to toggle source
Calls superclass method
R2OAS::Base::new
# File lib/r2-oas/schema/monitor.rb, line 9 def initialize(before_schema_data, options) super(options) @before_schema_data = before_schema_data end
Public Instance Methods
start()
click to toggle source
# File lib/r2-oas/schema/monitor.rb, line 14 def start EM.run do ensure_save_tmp_schema_file signal_trap('INT') signal_trap('TERM') end end
Private Instance Methods
ensure_save_tmp_schema_file()
click to toggle source
# File lib/r2-oas/schema/monitor.rb, line 40 def ensure_save_tmp_schema_file EM.add_periodic_timer(interval_to_save_edited_tmp_schema) do @after_schema_data = fetch_after_schema_data puts "\nwait for signal trap ..." end end
fetch_after_schema_data()
click to toggle source
# File lib/r2-oas/schema/monitor.rb, line 47 def fetch_after_schema_data YAML.load_file(doc_save_file_path) || @after_schema_data end
process_after_close_monitor()
click to toggle source
# File lib/r2-oas/schema/monitor.rb, line 33 def process_after_close_monitor options = { type: :edited } @after_schema_data = fetch_after_schema_data analyzer = Analyzer.new(@before_schema_data, @after_schema_data, options) analyzer.analyze_docs end
signal_trap(command)
click to toggle source
# File lib/r2-oas/schema/monitor.rb, line 26 def signal_trap(command) Signal.trap(command) do process_after_close_monitor EM.stop end end