junkie 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
data/junkie.gemspec CHANGED
@@ -30,5 +30,5 @@ Gem::Specification.new do |gem|
30
30
  gem.add_runtime_dependency('twitter', ["~> 4.4.0"])
31
31
  gem.add_runtime_dependency('thin')
32
32
  gem.add_runtime_dependency('sinatra')
33
- gem.add_runtime_dependency('sinatra-websocket')
33
+ gem.add_runtime_dependency('sinatra-websocket', ["~> 0.2.1"])
34
34
  end
@@ -1,5 +1,3 @@
1
- require 'em-http'
2
- require 'fiber'
3
1
  require 'junkie/log'
4
2
  require 'sjunkieex'
5
3
 
@@ -81,22 +79,5 @@ module Junkie
81
79
  return []
82
80
  end
83
81
 
84
- private
85
-
86
- def get_page_data(link)
87
- f = Fiber.current
88
- http = EventMachine::HttpRequest.new(link).get :timeout => 10
89
-
90
- http.callback { f.resume(http) }
91
- http.errback { f.resume(http) }
92
-
93
- Fiber.yield
94
-
95
- if http.error
96
- raise IOError, http.error
97
- end
98
-
99
- http.response
100
- end
101
82
  end
102
83
  end
@@ -39,33 +39,6 @@ module Junkie
39
39
  build_procs # has to be called here
40
40
  end
41
41
 
42
- def build_procs
43
-
44
- # Proc that looks for new episodes on Seriesjunkies.org and adds them to
45
- # the episode_queue if they are new
46
- @look_for_new_episodes = Proc.new {
47
- in_fiber {
48
-
49
- log.debug "Reload Sindex from file"
50
- # TODO refactor this so that we can detect if we have to reload the
51
- # index (by MD5sum)
52
- sindex = Sindex::SeriesIndex.new(index_file: @config[:series_index_file])
53
- sjunkieex = Sjunkieex::Interface.new(sindex)
54
-
55
- log.info "Looking for new episodes"
56
- sjunkieex.get_links_for_downloads.each do |episode|
57
- identifier = "%s@%s" % [episode.id, episode.series]
58
-
59
- if not @found_episodes.has_key? identifier
60
- log.info("Found new episode '#{episode}'")
61
-
62
- @channels[:episodes].push(episode)
63
- @found_episodes[identifier] = episode
64
- end
65
- end
66
- }
67
- }
68
- end
69
42
 
70
43
  ###########################################################################
71
44
  #################### The Reactor ##########################################
@@ -97,5 +70,48 @@ module Junkie
97
70
  Junkie::Webinterface::Interface.setup(@channels)
98
71
  end
99
72
  end
73
+
74
+ private
75
+
76
+ def build_procs
77
+
78
+ # Proc that looks for new episodes on Seriesjunkies.org and adds them to
79
+ # the episode_queue if they are new
80
+ @look_for_new_episodes = proc {
81
+
82
+ operation = proc {
83
+ log.debug "Reload Sindex from file"
84
+ sindex = Sindex::SeriesIndex.new(index_file: @config[:series_index_file])
85
+
86
+ sjunkieex = Sjunkieex::Interface.new(sindex)
87
+
88
+ log.info "Looking for new episodes"
89
+ sjunkieex.get_links_for_downloads
90
+ }
91
+
92
+ callback = proc { |episodes|
93
+
94
+ episodes.each do |episode|
95
+ identifier = "%s@%s" % [episode.id, episode.series]
96
+
97
+ if not @found_episodes.has_key? identifier
98
+ log.info("Found new episode '#{episode}'")
99
+
100
+ @channels[:episodes].push(episode)
101
+ @found_episodes[identifier] = episode
102
+ end
103
+ end
104
+
105
+ # send out the current time out of the websocket
106
+ @channels[:info].push({
107
+ key: "Last Episode Search",
108
+ desc: "The last time <strong>junkie</strong> has searched for new episodes",
109
+ value: Time.new.strftime("%d.%m.%Y %H:%M:%S")
110
+ })
111
+ }
112
+
113
+ EM.defer(operation, callback)
114
+ }
115
+ end
100
116
  end
101
117
  end
@@ -1,3 +1,3 @@
1
1
  module Junkie
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: junkie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-28 00:00:00.000000000 Z
12
+ date: 2013-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
@@ -208,17 +208,17 @@ dependencies:
208
208
  requirement: !ruby/object:Gem::Requirement
209
209
  none: false
210
210
  requirements:
211
- - - ! '>='
211
+ - - ~>
212
212
  - !ruby/object:Gem::Version
213
- version: '0'
213
+ version: 0.2.1
214
214
  type: :runtime
215
215
  prerelease: false
216
216
  version_requirements: !ruby/object:Gem::Requirement
217
217
  none: false
218
218
  requirements:
219
- - - ! '>='
219
+ - - ~>
220
220
  - !ruby/object:Gem::Version
221
- version: '0'
221
+ version: 0.2.1
222
222
  description: TV series management application
223
223
  email:
224
224
  - philipp-boehm@live.de
@@ -277,7 +277,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
277
277
  version: '0'
278
278
  requirements: []
279
279
  rubyforge_project:
280
- rubygems_version: 1.8.24
280
+ rubygems_version: 1.8.23
281
281
  signing_key:
282
282
  specification_version: 3
283
283
  summary: TV series managament tool that does all the work you have with your series.
@@ -288,4 +288,3 @@ test_files:
288
288
  - spec/pyload_api_spec.rb
289
289
  - spec/pyload_observer_spec.rb
290
290
  - spec/spec_helper.rb
291
- has_rdoc: