Class: Pra::App
- Inherits:
-
Object
- Object
- Pra::App
- Defined in:
- lib/pra/app.rb
Instance Method Summary collapse
- #fetch_and_refresh_pull_requests ⇒ Object
- #pull_request_fetcher_thread ⇒ Object
- #refresh_pull_requests ⇒ Object
- #run ⇒ Object
- #spawn_pull_request_fetcher ⇒ Object
Instance Method Details
#fetch_and_refresh_pull_requests ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/pra/app.rb', line 24 def fetch_and_refresh_pull_requests if @window_system.force_refresh || Time.now - @window_system.last_updated > Pra.config.refresh_interval refresh_pull_requests end Kernel.sleep(0.1) end |
#pull_request_fetcher_thread ⇒ Object
51 52 53 54 55 |
# File 'lib/pra/app.rb', line 51 def pull_request_fetcher_thread while( true ) do fetch_and_refresh_pull_requests end end |
#refresh_pull_requests ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/pra/app.rb', line 32 def refresh_pull_requests @window_system.force_refresh = false @window_system.fetching_pull_requests new_pull_requests = [] Pra::PullRequestService.fetch_pull_requests do |fetch| fetch.on_success do |pull_requests| new_pull_requests += pull_requests end fetch.on_error do |error| Pra::Log.error(error) @window_system.fetch_failed end end @window_system.refresh_pull_requests(new_pull_requests) end |
#run ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/pra/app.rb', line 11 def run @window_system = Pra::WindowSystemFactory.build('curses') @window_system.setup spawn_pull_request_fetcher @window_system.run_loop end |
#spawn_pull_request_fetcher ⇒ Object
20 21 22 |
# File 'lib/pra/app.rb', line 20 def spawn_pull_request_fetcher Thread.new { pull_request_fetcher_thread } end |