tabcast 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/tabcast +15 -1
- data/lib/tabcast.rb +5 -1
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06994bca6d392f56050381ab2fdedb8e3309f904
|
4
|
+
data.tar.gz: d68b8570130a816b8757fa3fbf9cf8956862255e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95bfb2c144b7b4bc6aa19295a5f0c6deb737c66f098c4ec9577206b77b7d49ceb9cd1d08121fbabcdb383580c7cb18dcabe39f35ee1cac38792d0daca8ef5e71
|
7
|
+
data.tar.gz: 5e4eeecaf841a2ed65aaf0443924bebc7840a6a2f7351a5423f33aeb76152f34536cad798c25d26b8a638d905ee3b9c4363b919f8940ec12fcc00608223bf9b0
|
data/bin/tabcast
CHANGED
@@ -13,8 +13,10 @@ options = {}
|
|
13
13
|
optparse = OptionParser.new do|opts|
|
14
14
|
#set default
|
15
15
|
options[:format] = '{{utime}}\t{{title | spaces_to_underscores}}\t{{enclosure_url}}\n'
|
16
|
+
options[:prefix] = ""
|
17
|
+
options[:suffix] = ""
|
16
18
|
|
17
|
-
opts.banner = "Usage: tabcast [-f FORMATSTRING] file1 file2 ...\n(FORMATSTRING is assumed to be '#{options[:format]}' unless specified)
|
19
|
+
opts.banner = "Usage: tabcast [-f FORMATSTRING] [-p PREFIX] [-s SUFFIX] file1 file2 ...\n(FORMATSTRING is assumed to be '#{options[:format]}' unless specified)
|
18
20
|
|
19
21
|
FORMATSTRING is a Liquid template (http://liquidmarkup.org/) that will be rendered once for each feed item.
|
20
22
|
|
@@ -45,15 +47,27 @@ In addition, the following sequences are escaped to the equivalent literal chara
|
|
45
47
|
options[:format] = "{{utime}}#{delimiter}{{title | spaces_to_underscores}}#{delimiter}{{enclosure_url}}" + '\n';
|
46
48
|
end
|
47
49
|
|
50
|
+
opts.on( '-p', '--prefix PREFIX', 'Print this string once, before the list of items') do |prefix|
|
51
|
+
options[:prefix] = prefix
|
52
|
+
end
|
53
|
+
|
54
|
+
opts.on( '-s', '--suffixi SUFFIX', 'Print this string once, after the list of items') do |suffix|
|
55
|
+
options[:suffix] = suffix
|
56
|
+
end
|
57
|
+
|
48
58
|
opts.on( '-h', '--help', 'Show usage.' ) do
|
49
59
|
puts opts
|
50
60
|
exit
|
51
61
|
end
|
62
|
+
|
63
|
+
|
52
64
|
end
|
53
65
|
|
54
66
|
optparse.parse!
|
55
67
|
|
56
68
|
ARGV.each do |url|
|
57
69
|
feed = Tabcast::TabCastFeed.new(url, options[:format])
|
70
|
+
feed.prefix = options[:prefix]
|
71
|
+
feed.suffix = options[:suffix]
|
58
72
|
puts feed.formatted
|
59
73
|
end
|
data/lib/tabcast.rb
CHANGED
@@ -21,15 +21,18 @@ module Tabcast
|
|
21
21
|
|
22
22
|
class TabCastFeed
|
23
23
|
attr_reader :url, :feed, :template
|
24
|
+
attr_accessor :prefix, :suffix
|
24
25
|
|
25
26
|
def initialize(url, format)
|
26
27
|
@url = url
|
27
28
|
@items = RSS::Parser.parse(url, false).items
|
28
29
|
@template = Liquid::Template.parse(unescape(format))
|
30
|
+
#@prefix = "" unless @prefix
|
31
|
+
#@suffix = "" unless @suffix
|
29
32
|
end
|
30
33
|
|
31
34
|
def formatted
|
32
|
-
string =
|
35
|
+
string = unescape(@prefix)
|
33
36
|
@items.each do |i|
|
34
37
|
vars = Hash.new
|
35
38
|
vars['utime'] = i.pubDate.strftime('%s') if i.pubDate
|
@@ -41,6 +44,7 @@ module Tabcast
|
|
41
44
|
|
42
45
|
string += @template.render(vars)
|
43
46
|
end
|
47
|
+
string += unescape(@suffix)
|
44
48
|
string
|
45
49
|
end
|
46
50
|
|
metadata
CHANGED
@@ -1,37 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tabcast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.3'
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.6'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.6'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
14
|
+
name: liquid
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
17
|
- - ">="
|
32
18
|
- !ruby/object:Gem::Version
|
33
19
|
version: '0'
|
34
|
-
type: :
|
20
|
+
type: :runtime
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|