epodder 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ #TODO clean up nil!!
1
2
  module Epodder
2
3
  class Configurator
3
4
  @@default_path = "~/.epodder/"
@@ -48,21 +49,15 @@ module Epodder
48
49
  end
49
50
 
50
51
  def load_working_dir! path
51
- @path = File.expand_path(path.nil? ? @@default_path : path)
52
+ @path = File.expand_path(path || @@default_path)
52
53
  Dir.mkdir @path unless Dir.exists? @path
53
54
  Dir.chdir @path unless file_error
54
55
  end
55
56
 
56
57
  def file_error
57
- if !File.directory? @path
58
- puts "#{@path} is not a directory"
58
+ if !File.directory?(@path) || !File.readable?(@path) || !File.writable?(@path)
59
+ puts "#{@path} is not a directory or is not writable"
59
60
  exit
60
- elsif !File.readable? @path
61
- puts "Can not read #{@path}"
62
- exit
63
- elsif !File.writable? @path
64
- puts "Can not write to #{@path}"
65
- exit
66
61
  end
67
62
  false
68
63
  end
@@ -12,13 +12,14 @@ module Epodder
12
12
  belongs_to :podcast
13
13
 
14
14
  def self.lookup episode
15
- return if episode.enclosure.nil?
16
- @episode = Episode.first_or_create(
17
- :title => episode.title,
18
- :url => episode.enclosure.url,
19
- :pub_date => episode.pubdate,
20
- :downloaded => false
21
- )
15
+ if episode.enclosure
16
+ @episode = Episode.first_or_create(
17
+ :title => episode.title,
18
+ :url => episode.enclosure.url,
19
+ :pub_date => episode.pubdate,
20
+ :downloaded => false
21
+ )
22
+ end
22
23
  end
23
24
 
24
25
  def mark_as_downloaded
data/lib/verb/catchup.rb CHANGED
@@ -1,18 +1,19 @@
1
1
  module Epodder
2
2
  class Catchup < Verb
3
- def initialize
4
- end
5
-
6
3
  def catchup args
7
4
  if args.empty?
8
5
  podcasts = Podcast.all
9
6
  else
10
7
  podcasts = args.map {|id| Podcast.get(id)}
11
8
  end
12
- podcasts.each do |podcast|
9
+ catchup_podcasts podcasts
10
+ end
11
+
12
+ def catchup_podcasts podcasts
13
+ podcasts.each do |podcast|
13
14
  Episode.all(:downloaded => false, :podcast => podcast).update(:downloaded => true)
14
15
  end
15
- end
16
+ end
16
17
  end
17
18
 
18
19
  end
data/lib/verb/download.rb CHANGED
@@ -9,12 +9,7 @@ module Epodder
9
9
  end
10
10
 
11
11
  def download args
12
- if args.empty?
13
- podcasts = Podcast.all
14
- else
15
- podcasts = args.map {|id| Podcast.get(id)}
16
- end
17
- look_for_episodes podcasts
12
+ look_for_episodes lookup_args(args)
18
13
  end
19
14
 
20
15
  def look_for_episodes podcasts
data/lib/verb/remove.rb CHANGED
@@ -5,7 +5,7 @@ module Epodder
5
5
 
6
6
  end
7
7
 
8
- def remove *args
8
+ def remove args
9
9
  args.map{|id| Podcast.get(id)}.each do |podcast|
10
10
  input = ask("Remove #{podcast.id} : #{podcast.title}? Type \"YES\" to remove")
11
11
  if input == "YES"
data/lib/verb/update.rb CHANGED
@@ -11,12 +11,7 @@ module Epodder
11
11
  end
12
12
 
13
13
  def update args
14
- if args.empty?
15
- podcasts = Podcast.all
16
- else
17
- podcasts = args.map {|id| Podcast.get(id)}
18
- end
19
- check_for_new_episodes podcasts if podcasts.any?
14
+ check_for_new_episodes lookup_args(args)
20
15
  end
21
16
 
22
17
  def check_for_new_episodes podcasts
@@ -54,7 +49,7 @@ module Epodder
54
49
  end
55
50
 
56
51
  def add_eligable_episodes item, max_pub
57
- if !item.enclosure.nil? && item.pubdate.to_date > max_pub.to_date
52
+ if item.enclosure && item.pubdate.to_date > max_pub.to_date
58
53
  begin
59
54
  @count += 1
60
55
  ep = Episode.first_or_create(
data/lib/verb/verb.rb CHANGED
@@ -12,5 +12,13 @@ module Epodder
12
12
  cmd.add_command(command)
13
13
  end
14
14
 
15
+ def lookup_args args
16
+ if args.empty?
17
+ podcasts = Podcast.all
18
+ else
19
+ podcasts = args.map {|id| Podcast.get(id)}
20
+ end
21
+ end
22
+
15
23
  end
16
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epodder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
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: 2013-01-25 00:00:00.000000000 Z
12
+ date: 2013-02-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri