tabcast 0.3 → 0.4.1
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.
- checksums.yaml +4 -4
- data/bin/tabcast +13 -2
- data/lib/tabcast.rb +66 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1417633738b1222860c7c2bbd2c75e4bf1bf174c
|
4
|
+
data.tar.gz: b2a04b83e54adb2e43f2577e31b2e008f48399a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecdfd422b61a449fbbeabf2dace5afb984fafaf5cc60f2d6c646edd1230190cf8f85a954af4975e5d827eb342b3843016a05d9dada6cce95a5bb3d777a1c0674
|
7
|
+
data.tar.gz: 41d0163916e63e66522ff5e8f8dc6105a28458a729ca087589349f04d649a35336582388ee693b1d069f3874b9e6fae2876a239447248956e6e1c9a973f6745d
|
data/bin/tabcast
CHANGED
@@ -51,10 +51,18 @@ In addition, the following sequences are escaped to the equivalent literal chara
|
|
51
51
|
options[:prefix] = prefix
|
52
52
|
end
|
53
53
|
|
54
|
-
opts.on( '-s', '--
|
54
|
+
opts.on( '-s', '--suffix SUFFIX', 'Print this string once, after the list of items') do |suffix|
|
55
55
|
options[:suffix] = suffix
|
56
56
|
end
|
57
57
|
|
58
|
+
opts.on( '-k', '--killfile KILLFILE', 'Path to a file containing killed enclosure URLs.') do |killfile|
|
59
|
+
options[:killfile] = killfile
|
60
|
+
end
|
61
|
+
|
62
|
+
opts.on( '-g', '--guidkillfile GUIDKILLFILE', 'Path to a file containing killed guids.') do |guidkillfile|
|
63
|
+
options[:guidkillfile] = guidkillfile
|
64
|
+
end
|
65
|
+
|
58
66
|
opts.on( '-h', '--help', 'Show usage.' ) do
|
59
67
|
puts opts
|
60
68
|
exit
|
@@ -69,5 +77,8 @@ ARGV.each do |url|
|
|
69
77
|
feed = Tabcast::TabCastFeed.new(url, options[:format])
|
70
78
|
feed.prefix = options[:prefix]
|
71
79
|
feed.suffix = options[:suffix]
|
72
|
-
|
80
|
+
feed.killfile = options[:killfile] if options[:killfile]
|
81
|
+
feed.guidkillfile = options[:guidkillfile] if options[:guidkillfile]
|
82
|
+
print feed.formatted
|
83
|
+
#print feed.feed.channel.methods
|
73
84
|
end
|
data/lib/tabcast.rb
CHANGED
@@ -17,37 +17,86 @@
|
|
17
17
|
end
|
18
18
|
|
19
19
|
module Tabcast
|
20
|
+
require 'open-uri'
|
20
21
|
Liquid::Template.register_filter(TextFilter)
|
21
22
|
|
22
23
|
class TabCastFeed
|
23
|
-
attr_reader :url, :feed, :template
|
24
|
-
|
24
|
+
attr_reader :url, :feed, :template, :prefix, :suffix
|
25
|
+
|
25
26
|
|
26
27
|
def initialize(url, format)
|
27
28
|
@url = url
|
28
|
-
@
|
29
|
+
@feed = RSS::Parser.parse(url, false)
|
29
30
|
@template = Liquid::Template.parse(unescape(format))
|
30
|
-
|
31
|
-
|
31
|
+
@killlist = []
|
32
|
+
@guidkilllist = []
|
33
|
+
end
|
34
|
+
|
35
|
+
def prefix=(prefixstring)
|
36
|
+
@prefix = Liquid::Template.parse(unescape(prefixstring))
|
37
|
+
end
|
38
|
+
|
39
|
+
def suffix= (suffixstring)
|
40
|
+
@suffix = Liquid::Template.parse(unescape(suffixstring))
|
32
41
|
end
|
33
42
|
|
34
43
|
def formatted
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
vars = {}
|
45
|
+
|
46
|
+
vars['channel_title'] = @feed.channel.title if @feed.channel.title
|
47
|
+
vars['channel_description'] = @feed.channel.description if @feed.channel.description
|
48
|
+
vars['channel_link'] = @feed.channel.link if @feed.channel.link
|
49
|
+
vars['channel_language'] = @feed.channel.language if @feed.channel.language
|
50
|
+
|
51
|
+
string = ""
|
52
|
+
string += @prefix.render(vars)
|
53
|
+
@feed.items.each do |i|
|
54
|
+
unless ( @killlist.include? i.enclosure.url ) or ( @guidkilllist.include? i.guid.to_s )
|
55
|
+
if i.pubDate
|
56
|
+
vars['utime'] = i.pubDate.strftime('%s')
|
57
|
+
else
|
58
|
+
vars['utime'] = nil
|
59
|
+
end
|
60
|
+
|
61
|
+
if i.title
|
62
|
+
vars['title'] = i.title.chomp
|
63
|
+
else
|
64
|
+
vars['title'] = nil
|
65
|
+
end
|
66
|
+
|
67
|
+
if i.enclosure && i.enclosure.url
|
68
|
+
vars['enclosure_url'] = i.enclosure.url
|
69
|
+
else
|
70
|
+
vars['enclosure_url'] = nil
|
71
|
+
end
|
72
|
+
|
73
|
+
if i.itunes_author
|
74
|
+
vars['itunes_author'] = i.itunes_author if i.itunes_author
|
75
|
+
else
|
76
|
+
vars['itunes_author'] = nil
|
77
|
+
end
|
78
|
+
|
79
|
+
if i.author
|
80
|
+
vars['author'] = i.author
|
81
|
+
else
|
82
|
+
vars['guid'] = nil
|
83
|
+
end
|
84
|
+
|
85
|
+
string += @template.render(vars)
|
86
|
+
end
|
46
87
|
end
|
47
|
-
string +=
|
88
|
+
string += @suffix.render(vars)
|
48
89
|
string
|
49
90
|
end
|
50
91
|
|
92
|
+
def killfile=(filename)
|
93
|
+
@killlist = File.read(File.expand_path(filename)).split("\n")
|
94
|
+
end
|
95
|
+
|
96
|
+
def guidkillfile=(filename)
|
97
|
+
@guidkilllist = File.read(File.expand_path(filename)).split("\n")
|
98
|
+
end
|
99
|
+
|
51
100
|
private
|
52
101
|
|
53
102
|
def unescape(string)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tabcast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Tindall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|