epodder 0.0.3 → 0.0.4
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.
- data/lib/configuration/configurator.rb +4 -9
- data/lib/database/episode.rb +8 -7
- data/lib/verb/catchup.rb +6 -5
- data/lib/verb/download.rb +1 -6
- data/lib/verb/remove.rb +1 -1
- data/lib/verb/update.rb +2 -7
- data/lib/verb/verb.rb +8 -0
- metadata +2 -2
@@ -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
|
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
|
data/lib/database/episode.rb
CHANGED
@@ -12,13 +12,14 @@ module Epodder
|
|
12
12
|
belongs_to :podcast
|
13
13
|
|
14
14
|
def self.lookup episode
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
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
|
-
|
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
|
-
|
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
data/lib/verb/update.rb
CHANGED
@@ -11,12 +11,7 @@ module Epodder
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def update args
|
14
|
-
|
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
|
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
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.
|
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-
|
12
|
+
date: 2013-02-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|