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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/tabcast +13 -2
  3. data/lib/tabcast.rb +66 -17
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06994bca6d392f56050381ab2fdedb8e3309f904
4
- data.tar.gz: d68b8570130a816b8757fa3fbf9cf8956862255e
3
+ metadata.gz: 1417633738b1222860c7c2bbd2c75e4bf1bf174c
4
+ data.tar.gz: b2a04b83e54adb2e43f2577e31b2e008f48399a9
5
5
  SHA512:
6
- metadata.gz: 95bfb2c144b7b4bc6aa19295a5f0c6deb737c66f098c4ec9577206b77b7d49ceb9cd1d08121fbabcdb383580c7cb18dcabe39f35ee1cac38792d0daca8ef5e71
7
- data.tar.gz: 5e4eeecaf841a2ed65aaf0443924bebc7840a6a2f7351a5423f33aeb76152f34536cad798c25d26b8a638d905ee3b9c4363b919f8940ec12fcc00608223bf9b0
6
+ metadata.gz: ecdfd422b61a449fbbeabf2dace5afb984fafaf5cc60f2d6c646edd1230190cf8f85a954af4975e5d827eb342b3843016a05d9dada6cce95a5bb3d777a1c0674
7
+ data.tar.gz: 41d0163916e63e66522ff5e8f8dc6105a28458a729ca087589349f04d649a35336582388ee693b1d069f3874b9e6fae2876a239447248956e6e1c9a973f6745d
@@ -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', '--suffixi SUFFIX', 'Print this string once, after the list of items') do |suffix|
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
- puts feed.formatted
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
@@ -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
- attr_accessor :prefix, :suffix
24
+ attr_reader :url, :feed, :template, :prefix, :suffix
25
+
25
26
 
26
27
  def initialize(url, format)
27
28
  @url = url
28
- @items = RSS::Parser.parse(url, false).items
29
+ @feed = RSS::Parser.parse(url, false)
29
30
  @template = Liquid::Template.parse(unescape(format))
30
- #@prefix = "" unless @prefix
31
- #@suffix = "" unless @suffix
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
- string = unescape(@prefix)
36
- @items.each do |i|
37
- vars = Hash.new
38
- vars['utime'] = i.pubDate.strftime('%s') if i.pubDate
39
- vars['title'] = i.title.chomp if i.title
40
- vars['enclosure_url'] = i.enclosure.url if i.enclosure && i.enclosure.url
41
- vars['itunes_author'] = i.itunes_author if i.itunes_author
42
- vars['author'] = i.author if i.author
43
- vars['guid'] = i.guid if i.guid
44
-
45
- string += @template.render(vars)
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 += unescape(@suffix)
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: '0.3'
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-20 00:00:00.000000000 Z
11
+ date: 2014-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: liquid