Class: Junkie::Reactor
- Inherits:
-
Object
- Object
- Junkie::Reactor
- Defined in:
- lib/junkie/reactor.rb
Constant Summary collapse
- DEFAULT_CONFIG =
{ :series_index_file => File.join(Dir.home, '.sindex/seriesindex.xml'), :episode_search_refresh => 15, # in minutes }
Instance Method Summary collapse
-
#initialize ⇒ Reactor
constructor
A new instance of Reactor.
-
#start ⇒ Object
The Reactor ##########################################.
Methods included from Log
Methods included from Helper
Methods included from Config
collect_default_configs, get_config, included
Constructor Details
#initialize ⇒ Reactor
Returns a new instance of Reactor.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/junkie/reactor.rb', line 24 def initialize @config = Config.get_config(self) log.info("Starting Junkie #{Junkie::VERSION}") @channels = { episodes: EM::Channel.new, notifications: EM::Channel.new, info: EM::Channel.new, } @pyload_observer = Junkie::Pyload::Observer.new(@channels) @twitter_notification = Junkie::Notification::Twitter.new(@channels) @dumper = Junkie::Notification::Dumper.new(@channels) @found_episodes = Hash.new build_procs # has to be called here end |
Instance Method Details
#start ⇒ Object
The Reactor ##########################################
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 73 |
# File 'lib/junkie/reactor.rb', line 47 def start EM.run do @channels[:episodes].subscribe do |episode| next unless episode.status == :extracted @channels[:notifications].push(episode) end # do some initialization work @pyload_observer.setup # Look for new episodes and add them to the Queue if they haven't # been found yet EM.next_tick do @look_for_new_episodes.call EM.add_periodic_timer(@config[:episode_search_refresh] * 60) do @look_for_new_episodes.call end end # start the web interface Junkie::Webinterface::Interface.setup(@channels) end end |