Class: Mumukit::Sync::Store::Github::Operation
- Inherits:
-
Object
- Object
- Mumukit::Sync::Store::Github::Operation
- Defined in:
- lib/mumukit/sync/store/github/operation.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#bot ⇒ Object
Returns the value of attribute bot.
Instance Method Summary collapse
- #before_run_in_local_repo ⇒ Object
- #can_run? ⇒ Boolean
- #ensure_post_commit_hook! ⇒ Object
-
#initialize(options) ⇒ Operation
constructor
A new instance of Operation.
- #run! ⇒ Object
- #run_in_local_repo(dir, local_repo) ⇒ Object
- #with_local_repo(&block) ⇒ Object
Constructor Details
#initialize(options) ⇒ Operation
Returns a new instance of Operation.
5 6 7 8 |
# File 'lib/mumukit/sync/store/github/operation.rb', line 5 def initialize() @bot = [:bot] @web_hook_base_url = [:web_hook_base_url] end |
Instance Attribute Details
#bot ⇒ Object
Returns the value of attribute bot.
3 4 5 |
# File 'lib/mumukit/sync/store/github/operation.rb', line 3 def bot @bot end |
Instance Method Details
#before_run_in_local_repo ⇒ Object
41 42 |
# File 'lib/mumukit/sync/store/github/operation.rb', line 41 def before_run_in_local_repo end |
#can_run? ⇒ Boolean
16 17 18 |
# File 'lib/mumukit/sync/store/github/operation.rb', line 16 def can_run? true end |
#ensure_post_commit_hook! ⇒ Object
37 38 39 |
# File 'lib/mumukit/sync/store/github/operation.rb', line 37 def ensure_post_commit_hook! bot.register_post_commit_hook!(repo, @web_hook_base_url) if bot.authenticated? && @web_hook_base_url end |
#run! ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mumukit/sync/store/github/operation.rb', line 20 def run! return unless can_run? puts "#{self.class.name} : running before run hook for repository #{repo}" before_run_in_local_repo result = nil with_local_repo do |dir, local_repo| puts "#{self.class.name} : running run hook for repository #{repo}" result = run_in_local_repo dir, local_repo end puts "#{self.class.name} : running after run hook repository #{repo}" ensure_post_commit_hook! result end |
#run_in_local_repo(dir, local_repo) ⇒ Object
44 45 |
# File 'lib/mumukit/sync/store/github/operation.rb', line 44 def run_in_local_repo(dir, local_repo) end |
#with_local_repo(&block) ⇒ Object
10 11 12 13 14 |
# File 'lib/mumukit/sync/store/github/operation.rb', line 10 def with_local_repo(&block) Dir.mktmpdir("mumuki.#{self.class.name}") do |dir| bot.clone_into repo, dir, &block end end |