transmission-rss 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,32 +1,32 @@
1
- require( 'singleton' )
2
- require( 'yaml' )
1
+ require 'singleton'
2
+ require 'yaml'
3
3
 
4
4
  # Class handles configuration parameters.
5
5
  class TransmissionRSS::Config < Hash
6
- # This is a singleton class.
7
- include Singleton
6
+ # This is a singleton class.
7
+ include Singleton
8
8
 
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
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
- if( not config.nil? )
17
- self.merge_yaml!( config )
18
- end
19
- end
16
+ if(not config.nil?)
17
+ self.merge_yaml!(config)
18
+ end
19
+ end
20
20
 
21
- # Merge Config Hash with Hash in YAML file.
22
- def merge_yaml!( path )
23
- self.merge!( load_file( path ) )
24
- end
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
- # 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
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
- # 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
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
@@ -1,44 +1,24 @@
1
- require( 'singleton' )
1
+ require 'logger'
2
+ require 'singleton'
2
3
 
4
+ # Encapsulates Logger as a singleton class.
3
5
  class TransmissionRSS::Log
4
- include Singleton
5
-
6
- attr_accessor :target, :verbose
7
-
8
- def add( *args )
9
- @buffer ||= []
10
-
11
- # Add every arg to buffer.
12
- args.each do |arg|
13
- @buffer.push( arg.to_s )
14
- end
15
- end
16
-
17
- def run
18
- @target ||= $stderr
19
- @buffer ||= []
20
-
21
- # If verbose is not defined, it will be nil.
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
- - 3
9
- version: 0.1.3
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: 2010-11-09 00:00:00 +01:00
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
- transmission's lack of the ability to monitor RSS feeds and
24
- automatically add enclosed torrent links. Devoted to Ann.
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