lib/chicanery.rb in chicanery-0.1.0 vs lib/chicanery.rb in chicanery-0.1.1

- old
+ new

@@ -3,61 +3,50 @@ require 'simplecov-gem-adapter' SimpleCov.start 'gem' end require 'chicanery/persistence' -require 'chicanery/collections' -require 'chicanery/handlers' -require 'chicanery/state_comparison' +require 'chicanery/servers' +require 'chicanery/repos' +require 'chicanery/sites' require 'chicanery/summary' module Chicanery include Persistence - include Collections - include Handlers - include StateComparison + include Servers + include Repos + include Sites - VERSION = "0.1.0" + VERSION = "0.1.1" def poll_period seconds=nil @poll_period = seconds if seconds @poll_period end def execute args - load args.shift - run_every poll_period + begin + load args.shift + run_every poll_period + rescue Interrupt + end end def run_every poll_period - begin - loop do - run - break unless poll_period - sleep poll_period - end - rescue Interrupt + loop do + run + break unless poll_period + sleep poll_period end end def run previous_state = restore - current_state = { - servers: {}, - repos: {} - } - repos.each do |repo| - repo_state = repo.state - compare_repo_state repo.name, repo_state, previous_state[:repos][repo.name] if previous_state[:repos] - current_state[:repos][repo.name] = repo_state - end - servers.each do |server| - current_jobs = server.jobs - compare_jobs current_jobs, previous_state[:servers][server.name] if previous_state[:servers] - current_state[:servers][server.name] = current_jobs - end + current_state = {} + check_servers current_state, previous_state + check_repos current_state, previous_state + check_sites current_state, previous_state current_state.extend Chicanery::Summary run_handlers.each {|handler| handler.call current_state, previous_state } persist current_state end - end \ No newline at end of file