Class: Gitdocs::Synchronizer
- Inherits:
-
Object
- Object
- Gitdocs::Synchronizer
- Includes:
- Celluloid
- Defined in:
- lib/gitdocs/synchronizer.rb
Instance Method Summary collapse
-
#initialize(share) ⇒ Synchronizer
constructor
A new instance of Synchronizer.
- #stop_timers ⇒ void
- #synchronize ⇒ void
Constructor Details
#initialize(share) ⇒ Synchronizer
Returns a new instance of Synchronizer.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/gitdocs/synchronizer.rb', line 9 def initialize(share) @git_notifier = GitNotifier.new(share.path, share.notification) @repository = Repository.new(share) @sync_type = share.sync_type # Always to an initial synchronization when beginning. synchronize @timer = every(share.polling_interval) { synchronize } end |
Instance Method Details
#stop_timers ⇒ void
This method returns an undefined value.
21 22 23 24 |
# File 'lib/gitdocs/synchronizer.rb', line 21 def stop_timers return unless @timer @timer.cancel end |
#synchronize ⇒ void
This method returns an undefined value.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/gitdocs/synchronizer.rb', line 27 def synchronize return unless @repository.valid? result = @repository.synchronize(@sync_type) @git_notifier.for_merge(result[:merge]) @git_notifier.for_push(result[:push]) rescue => e # Rescue any standard exceptions which come from the push related # commands. This will prevent problems on a single share from killing # the entire daemon. @git_notifier.on_error(e) end |