Class: Gitdocs::GitNotifier
- Inherits:
-
Object
- Object
- Gitdocs::GitNotifier
- Defined in:
- lib/gitdocs/git_notifier.rb
Instance Method Summary collapse
- #for_merge(result) ⇒ void
- #for_push(result) ⇒ void
-
#initialize(root, show_notifications) ⇒ GitNotifier
constructor
A new instance of GitNotifier.
- #on_error(exception) ⇒ void
Constructor Details
#initialize(root, show_notifications) ⇒ GitNotifier
Returns a new instance of GitNotifier.
8 9 10 11 |
# File 'lib/gitdocs/git_notifier.rb', line 8 def initialize(root, show_notifications) @root = root @show_notifications = show_notifications end |
Instance Method Details
#for_merge(result) ⇒ void
This method returns an undefined value.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/gitdocs/git_notifier.rb', line 16 def for_merge(result) return if result.nil? return if result == :no_remote return if result == :ok return if result == {} if result.is_a?(Array) Notifier.warn( 'There were some conflicts', result.map { |f| "* #{f}" }.join("\n"), @show_notifications ) elsif result.is_a?(Hash) Notifier.info( "Updated with #{change_to_s(result)}", "In #{@root}:\n#{(result)}", @show_notifications ) else Notifier.error( 'There was a problem synchronizing this gitdoc', "A problem occurred in #{@root}:\n#{result}", @show_notifications ) end nil end |
#for_push(result) ⇒ void
This method returns an undefined value.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/gitdocs/git_notifier.rb', line 47 def for_push(result) return if result.nil? return if result == :no_remote return if result == :nothing if result == :conflict Notifier.warn( "There was a conflict in #{@root}, retrying", '', @show_notifications ) elsif result.is_a?(Hash) Notifier.info( "Pushed #{change_to_s(result)}", "#{@root} has been pushed", @show_notifications ) else Notifier.error( "BAD Could not push changes in #{@root}", result.to_s, @show_notifications ) end nil end |