paradiso 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -41,6 +41,7 @@ It's also possible to tell where mplayer is located or specify another name
41
41
  of mplayer by adding this to the config file:
42
42
 
43
43
  player: /usr/local/bin/mplayer
44
+ player: mplayer32
44
45
 
45
46
  Same goes for unrar:
46
47
 
@@ -51,6 +52,10 @@ Ignore file endings:
51
52
  ignore_endings: ["nfo", "sfv", "txt"] # default
52
53
  ignore_endings: ["avi"]
53
54
 
55
+ Show a timestamp for each started item:
56
+
57
+ timestamp: true # defaults to false
58
+
54
59
  == TODO
55
60
 
56
61
  * Better playlist support
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
data/lib/paradiso/base.rb CHANGED
@@ -32,6 +32,7 @@ module Paradiso
32
32
  end
33
33
  end
34
34
  else
35
+ raise ArgumentError.new "the playlist '#{@options[:path]}' does already exists" if File.exists? @options[:path]
35
36
  @playlist << Playlist.new(args, @options[:path], @options[:ignore_endings])
36
37
  end
37
38
  end
@@ -81,7 +82,7 @@ module Paradiso
81
82
  @amount_played += 1
82
83
  end
83
84
 
84
- puts "Playing #{item}"
85
+ puts "#{timestamp}Playing #{item}"
85
86
 
86
87
  play_command = player item
87
88
  item = "-" if item =~ /(rar|r\d{2})$/
@@ -99,6 +100,11 @@ module Paradiso
99
100
  return @options[:player] unless file =~ /(rar|r\d{2})$/
100
101
  return "#{@options[:unrar]} p -inul #{file} | #{@options[:player]}"
101
102
  end
103
+
104
+ def timestamp
105
+ return "" unless @options[:timestamp]
106
+ Time.now.strftime("%Y-%m-%d %H:%M - ")
107
+ end
102
108
  end
103
109
  end
104
110
 
@@ -22,7 +22,7 @@ module Paradiso
22
22
  raise ArgumentError, "no files in playlist #{file}"
23
23
  end
24
24
 
25
- new items, file, ignore_endings=[]
25
+ new items, file, ignore_endings
26
26
  end
27
27
  end
28
28
 
@@ -30,6 +30,7 @@ module Paradiso
30
30
  @files = []
31
31
  @path = path
32
32
  @current_idx = -1
33
+ @done = false
33
34
 
34
35
  files.each do |file|
35
36
  begin
@@ -45,13 +46,11 @@ module Paradiso
45
46
  rar.gsub! /r\d{2}$/i, "rar"
46
47
  rar.gsub! /part\d{2}/i, ""
47
48
 
48
- unless rars.include? rar
49
- rars << rar
50
- tmp << File.expand_path(f)
51
- end
52
- else
53
- tmp << File.expand_path(f)
49
+ next if rars.include? rar
50
+ rars << rar
54
51
  end
52
+
53
+ tmp << File.expand_path(f)
55
54
  end
56
55
 
57
56
  @files += tmp.sort
@@ -86,14 +85,16 @@ module Paradiso
86
85
  end
87
86
 
88
87
  def each
89
- @files.each_index do |idx|
88
+ @files.each_with_index do |file, idx|
90
89
  @current_idx = idx
91
- yield @files[idx]
90
+ yield file
92
91
  end
92
+
93
+ @done = true
93
94
  end
94
95
 
95
96
  def empty?
96
- @current_idx >= @files.size
97
+ @done
97
98
  end
98
99
 
99
100
  def started?
data/lib/paradiso.rb CHANGED
@@ -24,7 +24,8 @@ module Paradiso
24
24
  :player => 'mplayer',
25
25
  :unrar => 'unrar',
26
26
  :archive => false,
27
- :ignore_endings => ['nfo', 'sfv', 'txt']
27
+ :ignore_endings => ['nfo', 'sfv', 'txt'],
28
+ :timestamp => false,
28
29
  }
29
30
 
30
31
  class << self
@@ -34,6 +35,9 @@ module Paradiso
34
35
 
35
36
  para = Paradiso.new options, args
36
37
  para.run
38
+ rescue ArgumentError => e
39
+ puts "Error: #{e}"
40
+ exit 1
37
41
  end
38
42
 
39
43
  def config_file
@@ -42,9 +46,7 @@ module Paradiso
42
46
  config_file = File.expand_path('~/.paradiso')
43
47
  if File.exist? config_file
44
48
  yaml = YAML::load(File.open(config_file, 'r').read())
45
- yaml.each_pair do |key, value|
46
- options[key.to_sym] = value
47
- end
49
+ yaml.inject(options) { |memo, o| memo[o.first.to_sym] = o.last; memo }
48
50
  end
49
51
 
50
52
  return options
data/paradiso.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{paradiso}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Victor Bergoo"]
12
- s.date = %q{2010-10-31}
12
+ s.date = %q{2011-02-26}
13
13
  s.default_executable = %q{paradiso}
14
14
  s.description = %q{A simplified mplayer command line interface}
15
15
  s.email = %q{victor.bergoo@gmail.com}
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 0
9
- version: 0.4.0
8
+ - 1
9
+ version: 0.4.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Victor Bergoo
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-31 00:00:00 +02:00
17
+ date: 2011-02-26 00:00:00 +01:00
18
18
  default_executable: paradiso
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency