transmission-rss 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -2
- data/bin/transmission-rss +92 -88
- data/lib/transmission-rss.rb +4 -4
- data/lib/transmission-rss/aggregator.rb +111 -109
- data/lib/transmission-rss/client.rb +70 -70
- data/lib/transmission-rss/config-editor.rb +6 -6
- data/lib/transmission-rss/config-editor/listbox.rb +67 -67
- data/lib/transmission-rss/config-editor/main.rb +316 -316
- data/lib/transmission-rss/config.rb +24 -24
- data/lib/transmission-rss/hash.rb +10 -10
- data/lib/transmission-rss/log.rb +21 -41
- metadata +9 -9
@@ -1,32 +1,32 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'singleton'
|
2
|
+
require 'yaml'
|
3
3
|
|
4
4
|
# Class handles configuration parameters.
|
5
5
|
class TransmissionRSS::Config < Hash
|
6
|
-
|
7
|
-
|
6
|
+
# This is a singleton class.
|
7
|
+
include Singleton
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
# Merges a Hash or YAML file (containing a Hash) with itself.
|
10
|
+
def load(config)
|
11
|
+
if(config.class == Hash)
|
12
|
+
self.merge!(config)
|
13
|
+
return
|
14
|
+
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
if(not config.nil?)
|
17
|
+
self.merge_yaml!(config)
|
18
|
+
end
|
19
|
+
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
# Merge Config Hash with Hash in YAML file.
|
22
|
+
def merge_yaml!(path)
|
23
|
+
self.merge!(load_file(path))
|
24
|
+
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
# Load YAML file and work around tabs not working for identation.
|
27
|
+
def load_file(path)
|
28
|
+
YAML.load_stream(
|
29
|
+
File.new(path).read.gsub(/\t/, ' ')
|
30
|
+
).documents.first
|
31
|
+
end
|
32
32
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class Hash
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
# If a method is missing it is interpreted as the key of the hash. If the
|
3
|
+
# method has an argument (for example by "method="), the key called "method"
|
4
|
+
# is set to the respective argument.
|
5
|
+
def method_missing(symbol, *args)
|
6
|
+
if(args.size == 0)
|
7
|
+
self[symbol.to_s]
|
8
|
+
else
|
9
|
+
self[symbol.to_s.slice(0..-2)] = args.first
|
10
|
+
end
|
11
|
+
end
|
12
12
|
end
|
data/lib/transmission-rss/log.rb
CHANGED
@@ -1,44 +1,24 @@
|
|
1
|
-
require
|
1
|
+
require 'logger'
|
2
|
+
require 'singleton'
|
2
3
|
|
4
|
+
# Encapsulates Logger as a singleton class.
|
3
5
|
class TransmissionRSS::Log
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@verbose = (@verbose rescue nil)
|
23
|
-
|
24
|
-
# If +@target+ seems to be a file path, open the file and tranform
|
25
|
-
# +@target+ into an IO for the file.
|
26
|
-
if( @target.class != IO and @target.match( /(\/.*)+/ ) )
|
27
|
-
@target = File.open( @target, 'a' )
|
28
|
-
@target.sync = true
|
29
|
-
|
30
|
-
@verbose = true
|
31
|
-
end
|
32
|
-
|
33
|
-
# Loop, pop buffer and puts.
|
34
|
-
while( true )
|
35
|
-
line = @buffer.shift
|
36
|
-
|
37
|
-
if( @verbose and line )
|
38
|
-
@target.puts( line )
|
39
|
-
end
|
40
|
-
|
41
|
-
sleep( 0.1 )
|
42
|
-
end
|
43
|
-
end
|
6
|
+
include Singleton
|
7
|
+
|
8
|
+
# Change log target (IO or path to a file as String).
|
9
|
+
def target=(target)
|
10
|
+
old_logger = @logger
|
11
|
+
@logger = Logger.new(target)
|
12
|
+
|
13
|
+
if(old_logger)
|
14
|
+
@logger.level = old_logger.level
|
15
|
+
@logger.formatter = old_logger.formatter
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# If this class misses a method, call it on the encapsulated Logger class.
|
20
|
+
def method_missing(sym, *args)
|
21
|
+
@logger ||= Logger.new($stderr)
|
22
|
+
@logger.send(sym, *args)
|
23
|
+
end
|
44
24
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 5
|
9
|
+
version: 0.1.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- henning mueller
|
@@ -14,14 +14,14 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2011-01-06 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description: |-
|
22
22
|
transmission-rss is basically a workaround for
|
23
|
-
|
24
|
-
|
23
|
+
transmission's lack of the ability to monitor RSS feeds and
|
24
|
+
automatically add enclosed torrent links. Devoted to Ann.
|
25
25
|
email: henning@orgizm.net
|
26
26
|
executables:
|
27
27
|
- transmission-rss
|
@@ -31,15 +31,15 @@ extra_rdoc_files: []
|
|
31
31
|
|
32
32
|
files:
|
33
33
|
- bin/transmission-rss
|
34
|
+
- lib/transmission-rss/config-editor/main.glade
|
35
|
+
- lib/transmission-rss/config-editor/listbox.rb
|
36
|
+
- lib/transmission-rss/config-editor/main.rb
|
37
|
+
- lib/transmission-rss/config-editor/listbox-original.rb
|
34
38
|
- lib/transmission-rss/client.rb
|
35
39
|
- lib/transmission-rss/log.rb
|
36
40
|
- lib/transmission-rss/aggregator.rb
|
37
41
|
- lib/transmission-rss/hash.rb
|
38
42
|
- lib/transmission-rss/config.rb
|
39
|
-
- lib/transmission-rss/config-editor/main.glade
|
40
|
-
- lib/transmission-rss/config-editor/listbox.rb
|
41
|
-
- lib/transmission-rss/config-editor/main.rb
|
42
|
-
- lib/transmission-rss/config-editor/listbox-original.rb
|
43
43
|
- lib/transmission-rss/config-editor.rb
|
44
44
|
- lib/transmission-rss.rb
|
45
45
|
- README.rdoc
|