feedalizer 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,11 @@
1
+ Noteworthy changes:
2
+
3
+ -- 2008-03-27
4
+ Improved examples/sydsvenskan-nemi.rb.
5
+
6
+ -- 2007-07-09
7
+ Feedalizer now uses RSS 2.0 instead of RSS 1.0.
8
+
9
+ -- 2006-08-23
10
+ Added optional limit parameter to scrape_items.
11
+ Thanks to Thanh Vinh Tang for the hint that it is needed.
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006 Christoffer Sawicki <christoffer.sawicki@gmail.com>
1
+ Copyright (c) 2006-2008 Christoffer Sawicki <christoffer.sawicki@gmail.com>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to
@@ -0,0 +1,13 @@
1
+ bin/feedalizer
2
+ CHANGELOG.txt
3
+ COPYING.txt
4
+ examples/pjvault.rb
5
+ examples/sydsvenskan-nemi.rb
6
+ lib/feedalizer.rb
7
+ logo.svg
8
+ Manifest.txt
9
+ Rakefile
10
+ README.txt
11
+ tests/test.html
12
+ tests/test_feedalizer.rb
13
+ TODO.txt
@@ -0,0 +1,24 @@
1
+ = Feedalizer
2
+
3
+ http://termos.vemod.net/feedalizer
4
+
5
+ == Description
6
+
7
+ Feedalizer is a *small* Ruby library that glues together Hpricot with the
8
+ standard RSS library in a way that makes it easy to transform web pages into
9
+ RSS feeds. If you ask me, it makes it *too* easy.
10
+
11
+ == Documentation
12
+
13
+ First of all, see the included examples and take a quick look at the code.
14
+
15
+ Then read some documentation for the two libraries that are used:
16
+
17
+ * Hpricot:
18
+ http://code.whytheluckystiff.net/hpricot/
19
+ * RSS::Maker:
20
+ http://www.cozmixng.org/~rwiki/?cmd=view;name=RSS+Parser%3A%3AReference.en
21
+
22
+ == License
23
+
24
+ See link:COPYING.txt.
@@ -0,0 +1,14 @@
1
+ require "hoe"
2
+
3
+ $LOAD_PATH.unshift("lib")
4
+
5
+ require "feedalizer"
6
+
7
+ Hoe.new("feedalizer", Feedalizer::VERSION) do |p|
8
+ p.summary = "Transforms web pages into RSS feeds"
9
+ p.developer "Christoffer Sawicki", "christoffer.sawicki@gmail.com"
10
+ p.extra_deps = %<hpricot>
11
+ p.changes = "" # See CHANGELOG.txt
12
+
13
+ # All other necessary information is collected from README.txt
14
+ end
@@ -3,5 +3,5 @@
3
3
  * Add note about CGI
4
4
  * Cache the retrieved HTML during script development?
5
5
  * Write unit test(s) for debug mode.
6
- * Add support for RSS 2.0
7
6
  * Add timeout control (a bit tricky to do nicely)
7
+ * Restructure CHANGELOG.txt
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # Simple wrapper around Ruby :-)
3
2
 
4
3
  require "feedalizer"
5
4
 
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), "..", "lib")
5
5
  require "feedalizer"
6
6
  require "time"
7
7
 
8
- url = "http://sydsvenskan.se/serier/nemi/article101047.ece?context=serie"
8
+ url = "http://sydsvenskan.se/serier/nemi/index.jsp?context=serie"
9
9
 
10
10
  feedalize(url) do
11
11
  feed.title = "Nemi"
@@ -13,13 +13,17 @@ feedalize(url) do
13
13
  feed.description = "Daily Nemi strip scraped from Sydsvenskan"
14
14
 
15
15
  scrape_items("option") do |rss_item, html_element|
16
- rss_item.link = html_element.attributes["value"]
17
- rss_item.date = Time.parse(html_element.inner_html)
18
- rss_item.title = rss_item.date.strftime("%Y-%m-%d")
16
+ link = html_element.attributes["value"]
17
+ date = Time.parse(html_element.inner_html)
19
18
 
20
- # This grabs the page for a particular strip and extracts the relevant img element
21
- rss_item.description = grab_page(rss_item.link).search("//img[@width=748]")
19
+ rss_item.title = [feed.title, date.strftime("%Y-%m-%d")].join(", ")
20
+ rss_item.description = grab_page(link).search("//img[@width=600]")
21
+ rss_item.date = date
22
+ rss_item.link = link
23
+
24
+ rss_item.guid.isPermaLink = true
25
+ rss_item.guid.content = link
22
26
  end
23
-
24
- output!
27
+
28
+ output!(ARGV[0] ? File.open(ARGV[0], "w") : STDOUT)
25
29
  end
@@ -3,19 +3,19 @@ require "open-uri"
3
3
  require "hpricot"
4
4
 
5
5
  class Feedalizer
6
- VERSION = "0.1.0"
6
+ VERSION = "0.1.1"
7
7
 
8
8
  attr_reader :source
9
9
 
10
10
  def initialize(url, &block)
11
11
  @source = grab_page(url)
12
- @rss = RSS::Maker::RSS10.new
12
+ @rss = RSS::Maker::RSS20.new
13
13
 
14
- feed.generator = "Feedalizer (http://termos.vemod.net/feedalizer)"
14
+ feed.generator = "Feedalizer/#{VERSION} (http://termos.vemod.net/feedalizer)"
15
15
  feed.link = url
16
16
 
17
- instance_eval(&block) if block_given?
18
-
17
+ instance_eval(&block) if block
18
+
19
19
  debug! if $DEBUG
20
20
  end
21
21
 
@@ -26,8 +26,9 @@ class Feedalizer
26
26
  def scrape_items(hpricot_query, limit = 15)
27
27
  elements = @source.search(hpricot_query)
28
28
 
29
- elements.first(limit).each do |element|
30
- yield @rss.items.new_item, element
29
+ elements.first(limit).each do |html_element|
30
+ rss_item = @rss.items.new_item
31
+ yield rss_item, html_element
31
32
  end
32
33
  end
33
34
 
@@ -55,6 +56,6 @@ class Feedalizer
55
56
  end
56
57
 
57
58
  # A handy wrapper for Feedalizer.new :-)
58
- def feedalize(url, &block)
59
- Feedalizer.new(url, &block)
59
+ def feedalize(*args, &block)
60
+ Feedalizer.new(*args, &block)
60
61
  end
@@ -0,0 +1,196 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!-- Created with Inkscape (http://www.inkscape.org/) -->
3
+ <svg
4
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
5
+ xmlns:cc="http://web.resource.org/cc/"
6
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
7
+ xmlns:svg="http://www.w3.org/2000/svg"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ xmlns:sodipodi="http://inkscape.sourceforge.net/DTD/sodipodi-0.dtd"
10
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
11
+ width="600pt"
12
+ height="200pt"
13
+ id="svg1328"
14
+ sodipodi:version="0.32"
15
+ inkscape:version="0.43"
16
+ version="1.0"
17
+ sodipodi:docbase="/home/qerub/Desktop"
18
+ sodipodi:docname="Feedalizer.svg">
19
+ <defs
20
+ id="defs1330">
21
+ <linearGradient
22
+ id="RSSg"
23
+ y2="225.94"
24
+ x2="225.94"
25
+ y1="30.059999"
26
+ x1="30.059999"
27
+ gradientUnits="userSpaceOnUse">
28
+ <stop
29
+ id="stop1355"
30
+ stop-color="#E3702D"
31
+ offset="0.0" />
32
+ <stop
33
+ id="stop1357"
34
+ stop-color="#EA7D31"
35
+ offset="0.1071" />
36
+ <stop
37
+ id="stop1359"
38
+ stop-color="#F69537"
39
+ offset="0.3503" />
40
+ <stop
41
+ id="stop1361"
42
+ stop-color="#FB9E3A"
43
+ offset="0.5" />
44
+ <stop
45
+ id="stop1363"
46
+ stop-color="#EA7C31"
47
+ offset="0.7016" />
48
+ <stop
49
+ id="stop1365"
50
+ stop-color="#DE642B"
51
+ offset="0.8866" />
52
+ <stop
53
+ id="stop1367"
54
+ stop-color="#D95B29"
55
+ offset="1.0" />
56
+ </linearGradient>
57
+ </defs>
58
+ <sodipodi:namedview
59
+ id="base"
60
+ pagecolor="#ffffff"
61
+ bordercolor="#666666"
62
+ borderopacity="1.0"
63
+ inkscape:pageopacity="0.0"
64
+ inkscape:pageshadow="2"
65
+ inkscape:zoom="0.99541312"
66
+ inkscape:cx="702.12529"
67
+ inkscape:cy="124.61561"
68
+ inkscape:document-units="px"
69
+ inkscape:current-layer="layer1"
70
+ showguides="true"
71
+ inkscape:guide-bbox="true"
72
+ inkscape:window-width="1594"
73
+ inkscape:window-height="1143"
74
+ inkscape:window-x="0"
75
+ inkscape:window-y="0" />
76
+ <metadata
77
+ id="metadata1333">
78
+ <rdf:RDF>
79
+ <cc:Work
80
+ rdf:about="">
81
+ <dc:format>image/svg+xml</dc:format>
82
+ <dc:type
83
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
84
+ </cc:Work>
85
+ </rdf:RDF>
86
+ </metadata>
87
+ <g
88
+ inkscape:label="Layer 1"
89
+ inkscape:groupmode="layer"
90
+ id="layer1">
91
+ <g
92
+ id="g3409"
93
+ transform="matrix(0.276042,0.264838,-0.264838,0.276042,702.5009,852.4515)"
94
+ inkscape:export-filename="/home/qerub/Desktop/feedalizer.png"
95
+ inkscape:export-xdpi="44.940571"
96
+ inkscape:export-ydpi="44.940571">
97
+ <path
98
+ id="path2408"
99
+ d="M -1455.1635,-1127.3108 C -1480.8436,-1184.3602 -1502.1543,-1231.8246 -1502.5205,-1232.7871 C -1503.1489,-1234.4385 -1500.5064,-1234.5371 -1455.5794,-1234.5371 L -1407.9724,-1234.5371 L -1407.9724,-1129.0371 C -1407.9724,-1071.012 -1408.0849,-1023.5477 -1408.2224,-1023.5607 C -1408.3599,-1023.5737 -1429.4834,-1070.2612 -1455.1635,-1127.3108 z "
100
+ style="fill:#fe4545;stroke:#fe4545;stroke-width:4.19999981;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
101
+ <path
102
+ id="path3307"
103
+ d="M -1405.9505,-1128.7871 L -1405.9724,-1234.5371 L -1358.4724,-1234.5371 C -1332.3474,-1234.5371 -1310.9724,-1234.3035 -1310.9724,-1234.018 C -1310.9724,-1233.6259 -1394.1099,-1048.8415 -1404.0965,-1027.037 C -1405.8864,-1023.1291 -1405.929,-1025.4709 -1405.9505,-1128.7871 z "
104
+ style="fill:#fe4545;stroke:#fe4545;stroke-width:4.19999981;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
105
+ <path
106
+ id="path3305"
107
+ d="M -1505.2262,-1170.2871 C -1555.5138,-1248.2496 -1596.5327,-1312.1957 -1596.3793,-1312.3897 C -1596.226,-1312.5837 -1575.7092,-1294.7278 -1550.7865,-1272.71 L -1505.4724,-1232.6776 L -1460.4724,-1133.4126 C -1411.3162,-1024.9793 -1412.9119,-1028.537 -1413.4316,-1028.537 C -1413.6311,-1028.537 -1454.9387,-1092.3245 -1505.2262,-1170.2871 z "
108
+ style="fill:#fe4545;stroke:#fe4545;stroke-width:4.19999981;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
109
+ <path
110
+ id="path3303"
111
+ d="M -1400.7601,-1031.138 C -1400.0519,-1032.7933 -1379.2224,-1078.8109 -1354.4724,-1133.3996 L -1309.4724,-1232.6515 L -1264.1442,-1272.6827 C -1239.2136,-1294.6998 -1218.702,-1312.5616 -1218.5629,-1312.3754 C -1218.2983,-1312.0215 -1399.8866,-1030.2784 -1401.2601,-1028.912 C -1401.6933,-1028.481 -1401.4683,-1029.4827 -1400.7601,-1031.138 z "
112
+ style="fill:#fe4545;stroke:#fe4545;stroke-width:4.19999981;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
113
+ <path
114
+ id="path3301"
115
+ d="M -1499.4084,-1253.2871 C -1496.9868,-1262.4996 -1490.1185,-1288.4871 -1484.1456,-1311.0371 L -1473.2859,-1352.0371 L -1440.6292,-1352.3007 L -1407.9724,-1352.5644 L -1407.9724,-1294.5507 L -1407.9724,-1236.5371 L -1455.8919,-1236.5371 L -1503.8114,-1236.5371 L -1499.4084,-1253.2871 z "
116
+ style="fill:#fe4545;stroke:#fe4545;stroke-width:4.19999981;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
117
+ <path
118
+ id="path3299"
119
+ d="M -1405.9724,-1294.5507 L -1405.9724,-1352.5644 L -1373.2969,-1352.3007 L -1340.6214,-1352.0371 L -1329.7905,-1311.0371 C -1323.8335,-1288.4871 -1316.9806,-1262.4996 -1314.5619,-1253.2871 L -1310.1641,-1236.5371 L -1358.0683,-1236.5371 L -1405.9724,-1236.5371 L -1405.9724,-1294.5507 z "
120
+ style="fill:#fe4545;stroke:#fe4545;stroke-width:4.19999981;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
121
+ <path
122
+ id="path3297"
123
+ d="M -1552.3022,-1277.5405 C -1577.4208,-1299.5751 -1597.9724,-1317.9282 -1597.9724,-1318.325 C -1597.9724,-1319.2879 -1519.1343,-1398.0774 -1518.7555,-1397.493 C -1518.5929,-1397.2422 -1508.636,-1387.0756 -1496.6289,-1374.9006 L -1474.798,-1352.7641 L -1484.4281,-1316.9006 C -1489.7247,-1297.1756 -1496.5861,-1271.5871 -1499.6757,-1260.0371 C -1502.7652,-1248.4871 -1505.5943,-1238.6862 -1505.9625,-1238.2573 C -1506.3307,-1237.8284 -1527.1836,-1255.5059 -1552.3022,-1277.5405 z "
124
+ style="fill:#fe4545;stroke:#fe4545;stroke-width:4.19999981;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
125
+ <path
126
+ id="path3295"
127
+ d="M -1308.2609,-1238.2284 C -1308.5244,-1238.6731 -1315.5977,-1264.5978 -1323.9793,-1295.8388 L -1339.2186,-1352.6405 L -1319.9126,-1372.3388 C -1309.2942,-1383.1728 -1299.3356,-1393.3816 -1297.7822,-1395.025 L -1294.958,-1398.013 L -1255.4652,-1358.5298 C -1233.7442,-1336.814 -1216.0046,-1318.5944 -1216.044,-1318.0418 C -1216.1063,-1317.1665 -1301.0906,-1242.1925 -1305.9472,-1238.7284 C -1306.9562,-1238.0086 -1307.9974,-1237.7836 -1308.2609,-1238.2284 z "
128
+ style="fill:#fe4545;stroke:#fe4545;stroke-width:4.19999981;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
129
+ <path
130
+ id="path3293"
131
+ d="M -1598.77,-1324.0371 C -1598.4752,-1325.1371 -1594.5003,-1339.342 -1589.9369,-1355.6036 L -1581.6399,-1385.1701 L -1541.6229,-1406.6035 C -1479.8145,-1439.7087 -1477.9724,-1440.6826 -1477.9724,-1440.2576 C -1477.9724,-1439.8035 -1580.5497,-1339.607 -1591.8893,-1328.9847 C -1596.5138,-1324.6527 -1599.1043,-1322.79 -1598.77,-1324.0371 z "
132
+ style="fill:#fe4545;stroke:#fe4545;stroke-width:4.19999981;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
133
+ <path
134
+ id="path3291"
135
+ d="M -1263.5841,-1369.1097 C -1289.9227,-1394.7558 -1317.0974,-1421.3723 -1323.9724,-1428.2574 L -1336.4724,-1440.7757 L -1324.4057,-1434.4064 C -1317.769,-1430.9032 -1294.321,-1418.3864 -1272.2991,-1406.5913 L -1232.2591,-1385.1456 L -1223.5996,-1354.1909 C -1218.8368,-1337.1658 -1215.11,-1323.0661 -1215.3179,-1322.8583 C -1215.5257,-1322.6504 -1237.2455,-1343.4636 -1263.5841,-1369.1097 z "
136
+ style="fill:#fe4545;stroke:#fe4545;stroke-width:4.19999981;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
137
+ <path
138
+ id="path3289"
139
+ d="M -1494.7312,-1376.7956 C -1506.4139,-1388.4878 -1515.9724,-1398.5043 -1515.9724,-1399.0545 C -1515.9724,-1399.6047 -1506.631,-1409.3884 -1495.2137,-1420.796 L -1474.455,-1441.537 L -1407.455,-1441.537 L -1340.455,-1441.537 L -1319.2137,-1420.2785 C -1307.531,-1408.5863 -1297.9724,-1398.5698 -1297.9724,-1398.0196 C -1297.9724,-1397.4693 -1307.3139,-1387.6857 -1318.7312,-1376.2781 L -1339.4899,-1355.5371 L -1406.4899,-1355.5371 L -1473.4899,-1355.5371 L -1494.7312,-1376.7956 z "
140
+ style="fill:#fe4545;stroke:#fe4545;stroke-width:4.19999981;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
141
+ <path
142
+ style="fill:#eb0000"
143
+ d="M -1455.6115,-1129.4532 L -1502.7505,-1234.0371 L -1455.7047,-1234.2969 C -1429.8295,-1234.4399 -1408.5024,-1234.4003 -1408.311,-1234.209 C -1408.1197,-1234.0177 -1408.0778,-1186.838 -1408.2178,-1129.3652 L -1408.4724,-1024.8692 L -1455.6115,-1129.4532 z M -1405.9505,-1129.2871 L -1405.9724,-1234.5371 L -1358.4851,-1234.5371 L -1310.9977,-1234.5371 L -1313.3363,-1229.2871 C -1316.3248,-1222.5783 -1401.6526,-1033.3745 -1404.0968,-1028.037 C -1405.8863,-1024.1292 -1405.929,-1026.4618 -1405.9505,-1129.2871 z M -1417.478,-1034.8158 C -1419.0641,-1037.5008 -1485.9253,-1141.3239 -1569.2807,-1270.5371 C -1579.7474,-1286.7621 -1589.8906,-1302.5121 -1591.8212,-1305.5371 L -1595.3312,-1311.0371 L -1592.1518,-1308.5371 C -1590.4032,-1307.1621 -1570.3686,-1289.6121 -1547.6306,-1269.5371 L -1506.2887,-1233.0371 L -1460.6654,-1132.5856 C -1435.5726,-1077.3372 -1415.1626,-1032.0135 -1415.3098,-1031.8663 C -1415.4571,-1031.719 -1416.4328,-1033.0463 -1417.478,-1034.8158 z M -1398.6871,-1034.537 C -1398.3948,-1035.362 -1387.5974,-1059.212 -1374.6929,-1087.537 C -1361.7883,-1115.8621 -1342.5664,-1158.1621 -1331.9775,-1181.5371 C -1321.3885,-1204.9121 -1311.6733,-1226.1245 -1310.3881,-1228.6759 C -1308.5122,-1232.4 -1299.8186,-1240.5826 -1266.2962,-1270.1759 C -1243.3308,-1290.4495 -1223.4908,-1307.8747 -1222.2072,-1308.8985 C -1220.6635,-1310.1299 -1221.6977,-1307.9296 -1225.2624,-1302.3985 C -1228.2263,-1297.7997 -1267.9146,-1236.2121 -1313.4586,-1165.5371 C -1397.0384,-1035.8381 -1399.6463,-1031.8297 -1398.6871,-1034.537 z M -1502.9724,-1237.2026 C -1502.9724,-1237.5687 -1496.2224,-1263.3989 -1487.9724,-1294.603 C -1479.7224,-1325.8072 -1472.9724,-1351.6077 -1472.9724,-1351.9375 C -1472.9724,-1352.2672 -1458.3474,-1352.5371 -1440.4724,-1352.5371 L -1407.9724,-1352.5371 L -1407.9724,-1294.5371 L -1407.9724,-1236.5371 L -1455.4724,-1236.5371 C -1481.5974,-1236.5371 -1502.9724,-1236.8366 -1502.9724,-1237.2026 z M -1405.9724,-1294.5371 L -1405.9724,-1352.5371 L -1373.4724,-1352.5371 C -1355.5974,-1352.5371 -1340.9724,-1352.2739 -1340.9724,-1351.9522 C -1340.9724,-1351.6305 -1334.4696,-1326.768 -1326.5218,-1296.7022 C -1318.5739,-1266.6364 -1311.7751,-1240.7996 -1311.4134,-1239.2871 L -1310.7556,-1236.5371 L -1358.364,-1236.5371 L -1405.9724,-1236.5371 L -1405.9724,-1294.5371 z M -1307.9724,-1237.7812 C -1307.9724,-1238.3277 -1337.8442,-1349.6817 -1338.3715,-1351.1008 C -1338.5889,-1351.6859 -1328.948,-1362.2609 -1316.9474,-1374.6008 L -1295.128,-1397.037 L -1255.5135,-1357.4988 L -1215.899,-1317.9605 L -1254.168,-1284.4988 C -1275.216,-1266.0948 -1295.9325,-1247.9585 -1300.2047,-1244.1958 C -1304.477,-1240.4331 -1307.9724,-1237.5465 -1307.9724,-1237.7812 z M -1597.9724,-1324.0532 C -1597.9724,-1325.4126 -1581.3898,-1384.4638 -1580.8802,-1384.9194 C -1580.5627,-1385.2032 -1490.4513,-1433.5843 -1481.3951,-1438.3333 C -1479.4326,-1439.3624 -1496.3215,-1422.5536 -1544.4724,-1375.5552 C -1556.0224,-1364.2817 -1572.7849,-1347.8583 -1581.7224,-1339.0588 C -1590.6599,-1330.2594 -1597.9724,-1323.5068 -1597.9724,-1324.0532 z M -1231.9724,-1338.7909 C -1240.4974,-1347.1345 -1256.4724,-1362.758 -1267.4724,-1373.5096 C -1325.8507,-1430.5695 -1335.2926,-1439.8572 -1334.4223,-1439.3657 C -1333.8999,-1439.0707 -1319.2974,-1431.2481 -1301.9724,-1421.9823 C -1284.6474,-1412.7164 -1261.9668,-1400.5517 -1251.571,-1394.9497 L -1232.6696,-1384.7641 L -1224.3148,-1354.9193 C -1219.7197,-1338.5046 -1216.0753,-1324.7473 -1216.2162,-1324.3475 C -1216.3571,-1323.9477 -1223.4474,-1330.4472 -1231.9724,-1338.7909 z M -1494.7312,-1376.7956 C -1506.4139,-1388.4878 -1515.9724,-1398.5043 -1515.9724,-1399.0545 C -1515.9724,-1399.6047 -1506.631,-1409.3884 -1495.2137,-1420.796 L -1474.455,-1441.537 L -1407.455,-1441.537 L -1340.455,-1441.537 L -1319.2137,-1420.2785 C -1307.531,-1408.5863 -1297.9724,-1398.5698 -1297.9724,-1398.0196 C -1297.9724,-1397.4693 -1307.3139,-1387.6857 -1318.7312,-1376.2781 L -1339.4899,-1355.5371 L -1406.4899,-1355.5371 L -1473.4899,-1355.5371 L -1494.7312,-1376.7956 z "
144
+ id="path2410" />
145
+ <path
146
+ style="fill:#d60000"
147
+ d="M -1455.6115,-1129.4532 L -1502.7505,-1234.0371 L -1455.7047,-1234.2969 C -1429.8295,-1234.4399 -1408.5024,-1234.4003 -1408.311,-1234.209 C -1408.1197,-1234.0177 -1408.0778,-1186.838 -1408.2178,-1129.3652 L -1408.4724,-1024.8692 L -1455.6115,-1129.4532 z M -1405.9505,-1129.2871 L -1405.9724,-1234.5371 L -1358.4851,-1234.5371 L -1310.9977,-1234.5371 L -1313.3363,-1229.2871 C -1316.3248,-1222.5783 -1401.6526,-1033.3745 -1404.0968,-1028.037 C -1405.8863,-1024.1292 -1405.929,-1026.4618 -1405.9505,-1129.2871 z M -1398.6871,-1034.537 C -1398.3948,-1035.362 -1387.5974,-1059.212 -1374.6929,-1087.537 C -1361.7883,-1115.8621 -1342.5664,-1158.1621 -1331.9775,-1181.5371 C -1321.3885,-1204.9121 -1311.6733,-1226.1245 -1310.3881,-1228.6759 C -1308.5122,-1232.4 -1299.8186,-1240.5826 -1266.2962,-1270.1759 C -1243.3308,-1290.4495 -1223.4908,-1307.8747 -1222.2072,-1308.8985 C -1220.6635,-1310.1299 -1221.6977,-1307.9296 -1225.2624,-1302.3985 C -1228.2263,-1297.7997 -1267.9146,-1236.2121 -1313.4586,-1165.5371 C -1397.0384,-1035.8381 -1399.6463,-1031.8297 -1398.6871,-1034.537 z M -1405.9724,-1294.5371 L -1405.9724,-1352.5371 L -1373.4724,-1352.5371 C -1355.5974,-1352.5371 -1340.9724,-1352.2739 -1340.9724,-1351.9522 C -1340.9724,-1351.6305 -1334.4696,-1326.768 -1326.5218,-1296.7022 C -1318.5739,-1266.6364 -1311.7751,-1240.7996 -1311.4134,-1239.2871 L -1310.7556,-1236.5371 L -1358.364,-1236.5371 L -1405.9724,-1236.5371 L -1405.9724,-1294.5371 z M -1307.9724,-1237.7812 C -1307.9724,-1238.3277 -1337.8442,-1349.6817 -1338.3715,-1351.1008 C -1338.5889,-1351.6859 -1328.948,-1362.2609 -1316.9474,-1374.6008 L -1295.128,-1397.037 L -1255.5135,-1357.4988 L -1215.899,-1317.9605 L -1254.168,-1284.4988 C -1275.216,-1266.0948 -1295.9325,-1247.9585 -1300.2047,-1244.1958 C -1304.477,-1240.4331 -1307.9724,-1237.5465 -1307.9724,-1237.7812 z M -1597.9724,-1324.0532 C -1597.9724,-1325.4126 -1581.3898,-1384.4638 -1580.8802,-1384.9194 C -1580.5627,-1385.2032 -1490.4513,-1433.5843 -1481.3951,-1438.3333 C -1479.4326,-1439.3624 -1496.3215,-1422.5536 -1544.4724,-1375.5552 C -1556.0224,-1364.2817 -1572.7849,-1347.8583 -1581.7224,-1339.0588 C -1590.6599,-1330.2594 -1597.9724,-1323.5068 -1597.9724,-1324.0532 z M -1231.9724,-1338.7909 C -1240.4974,-1347.1345 -1256.4724,-1362.758 -1267.4724,-1373.5096 C -1325.8507,-1430.5695 -1335.2926,-1439.8572 -1334.4223,-1439.3657 C -1333.8999,-1439.0707 -1319.2974,-1431.2481 -1301.9724,-1421.9823 C -1284.6474,-1412.7164 -1261.9668,-1400.5517 -1251.571,-1394.9497 L -1232.6696,-1384.7641 L -1224.3148,-1354.9193 C -1219.7197,-1338.5046 -1216.0753,-1324.7473 -1216.2162,-1324.3475 C -1216.3571,-1323.9477 -1223.4474,-1330.4472 -1231.9724,-1338.7909 z M -1494.7312,-1376.7956 C -1506.4139,-1388.4878 -1515.9724,-1398.5043 -1515.9724,-1399.0545 C -1515.9724,-1399.6047 -1506.631,-1409.3884 -1495.2137,-1420.796 L -1474.455,-1441.537 L -1407.455,-1441.537 L -1340.455,-1441.537 L -1319.2137,-1420.2785 C -1307.531,-1408.5863 -1297.9724,-1398.5698 -1297.9724,-1398.0196 C -1297.9724,-1397.4693 -1307.3139,-1387.6857 -1318.7312,-1376.2781 L -1339.4899,-1355.5371 L -1406.4899,-1355.5371 L -1473.4899,-1355.5371 L -1494.7312,-1376.7956 z "
148
+ id="path2412" />
149
+ <path
150
+ style="fill:#ae0000"
151
+ d="M -1405.942,-1129.7871 L -1405.9724,-1234.5371 L -1358.4373,-1234.5371 C -1313.4792,-1234.5371 -1310.9523,-1234.4422 -1311.8289,-1232.7871 C -1312.3387,-1231.8246 -1333.3277,-1185.3621 -1358.4711,-1129.5371 C -1383.6145,-1073.712 -1404.5746,-1027.362 -1405.049,-1026.537 C -1405.5367,-1025.689 -1405.9248,-1070.5679 -1405.942,-1129.7871 z M -1398.6871,-1034.537 C -1398.3948,-1035.362 -1387.5974,-1059.212 -1374.6929,-1087.537 C -1361.7883,-1115.8621 -1342.5664,-1158.1621 -1331.9775,-1181.5371 C -1321.3885,-1204.9121 -1311.6733,-1226.1245 -1310.3881,-1228.6759 C -1308.5122,-1232.4 -1299.8186,-1240.5826 -1266.2962,-1270.1759 C -1243.3308,-1290.4495 -1223.4908,-1307.8747 -1222.2072,-1308.8985 C -1220.6635,-1310.1299 -1221.6977,-1307.9296 -1225.2624,-1302.3985 C -1228.2263,-1297.7997 -1267.9146,-1236.2121 -1313.4586,-1165.5371 C -1397.0384,-1035.8381 -1399.6463,-1031.8297 -1398.6871,-1034.537 z M -1308.8935,-1241.8106 C -1309.5358,-1244.1352 -1316.4739,-1269.9415 -1324.3115,-1299.1579 L -1338.5616,-1352.2788 L -1316.8352,-1374.6579 L -1295.1087,-1397.037 L -1255.5346,-1357.5295 L -1215.9604,-1318.0219 L -1257.2164,-1281.8906 C -1279.9072,-1262.0183 -1300.5544,-1243.9199 -1303.0991,-1241.6717 L -1307.7257,-1237.5842 L -1308.8935,-1241.8106 z M -1231.9724,-1338.7909 C -1240.4974,-1347.1345 -1256.4724,-1362.758 -1267.4724,-1373.5096 C -1325.8507,-1430.5695 -1335.2926,-1439.8572 -1334.4223,-1439.3657 C -1333.8999,-1439.0707 -1319.2974,-1431.2481 -1301.9724,-1421.9823 C -1284.6474,-1412.7164 -1261.9668,-1400.5517 -1251.571,-1394.9497 L -1232.6696,-1384.7641 L -1224.3148,-1354.9193 C -1219.7197,-1338.5046 -1216.0753,-1324.7473 -1216.2162,-1324.3475 C -1216.3571,-1323.9477 -1223.4474,-1330.4472 -1231.9724,-1338.7909 z M -1597.4083,-1326.7392 C -1597.0239,-1327.9503 -1593.1972,-1341.4967 -1588.9046,-1356.8421 C -1584.612,-1372.1876 -1580.9587,-1384.8459 -1580.7862,-1384.9718 C -1580.6136,-1385.0977 -1576.1974,-1387.4612 -1570.9724,-1390.2241 C -1558.1941,-1396.981 -1490.6256,-1433.1287 -1484.9724,-1436.2322 C -1480.2997,-1438.7975 -1491.8345,-1427.0339 -1539.5165,-1380.6059 C -1550.4923,-1369.9188 -1567.8453,-1352.9313 -1578.0787,-1342.8559 C -1588.3121,-1332.7806 -1597.0049,-1324.5371 -1597.3961,-1324.5371 C -1597.7872,-1324.5371 -1597.7927,-1325.528 -1597.4083,-1326.7392 z "
152
+ id="path2414" />
153
+ </g>
154
+ <g
155
+ id="g1426"
156
+ transform="matrix(0.462133,0,0,0.462133,806.8796,93.55829)"
157
+ inkscape:export-filename="/home/qerub/Desktop/feedalizer.png"
158
+ inkscape:export-xdpi="44.940571"
159
+ inkscape:export-ydpi="44.940571">
160
+ <circle
161
+ transform="translate(-436.0367,-81.89454)"
162
+ id="circle1375"
163
+ r="24"
164
+ cy="189"
165
+ cx="68"
166
+ sodipodi:cx="68"
167
+ sodipodi:cy="189"
168
+ sodipodi:rx="24"
169
+ sodipodi:ry="24"
170
+ style="fill:#ffffff" />
171
+ <path
172
+ id="path1377"
173
+ d="M -276.0367,131.10546 L -310.0367,131.10546 C -310.0367,85.81811 -346.74935,49.10546 -392.0367,49.10546 L -392.0367,15.10546 C -327.97167,15.10546 -276.0367,67.04043 -276.0367,131.10546 z "
174
+ style="fill:#ffffff" />
175
+ <path
176
+ id="path1379"
177
+ d="M -252.0367,131.10546 C -252.0367,53.7856 -314.71684,-8.89454 -392.0367,-8.89454 L -392.0367,-43.89454 C -295.38687,-43.89454 -217.0367,34.45563 -217.0367,131.10546 L -252.0367,131.10546 z "
178
+ style="fill:#ffffff" />
179
+ </g>
180
+ <text
181
+ xml:space="preserve"
182
+ style="font-size:20.09537506px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Georgia"
183
+ x="23.999416"
184
+ y="154.71768"
185
+ id="text1431"
186
+ sodipodi:linespacing="100%"
187
+ inkscape:export-filename="/home/qerub/Desktop/feedalizer.png"
188
+ inkscape:export-xdpi="44.940571"
189
+ inkscape:export-ydpi="44.940571"><tspan
190
+ sodipodi:role="line"
191
+ id="tspan1433"
192
+ x="23.999416"
193
+ y="154.71768"
194
+ style="font-size:120.572258px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Georgia">Feedalizer</tspan></text>
195
+ </g>
196
+ </svg>
@@ -13,7 +13,7 @@ class TestFeedalizer < Test::Unit::TestCase
13
13
  end
14
14
 
15
15
  def test_construction
16
- assert_kind_of RSS::Maker::RSS10::Channel, @feedalizer.feed
16
+ assert_kind_of RSS::Maker::RSS20::Channel, @feedalizer.feed
17
17
  assert_kind_of Hpricot::Doc, @feedalizer.source
18
18
  end
19
19
 
@@ -37,7 +37,7 @@ class TestFeedalizer < Test::Unit::TestCase
37
37
  @feedalizer.scrape_items("div.item") do |item, element|
38
38
  elements << element
39
39
 
40
- assert_kind_of RSS::Maker::RSS10::Items::Item, item
40
+ assert_kind_of RSS::Maker::RSS20::Items::Item, item
41
41
  assert_kind_of Hpricot::Elem, element
42
42
  end
43
43
 
@@ -57,14 +57,23 @@ class TestFeedalizer < Test::Unit::TestCase
57
57
  def test_grab_page
58
58
  assert_kind_of Hpricot::Doc, @feedalizer.grab_page(TEST_FILE)
59
59
  end
60
+
61
+ def test_existance_of_generator
62
+ f = @feedalizer.feed
63
+
64
+ f.about = f.title = f.description = "..."
65
+
66
+ assert @feedalizer.output.include?("Feedalizer")
67
+ end
60
68
 
61
69
  def test_output
62
70
  f = @feedalizer.feed
71
+
63
72
  f.about = f.title = f.description = "..."
64
73
 
65
74
  output = @feedalizer.output
66
75
 
67
- assert output.include?('<rdf:RDF xmlns="http://purl.org/rss/1.0/"')
68
- assert output.size > 600
76
+ assert output.include?("<rss")
77
+ assert output.size > 320
69
78
  end
70
79
  end
metadata CHANGED
@@ -1,64 +1,88 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
3
- specification_version: 1
4
2
  name: feedalizer
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.1.0
7
- date: 2006-10-11 00:00:00 +02:00
8
- summary: Transforms web pages into RSS feeds
9
- require_paths:
10
- - lib
11
- email: christoffer.sawicki@gmail.com
12
- homepage: http://termos.vemod.net/feedalizer
13
- rubyforge_project: feedalizer
14
- description: Feedalizer glues together Hpricot with Ruby's RSS library in a way that makes it dead easy to transform web pages into RSS feeds.
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 0.1.1
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
6
  authors:
29
7
  - Christoffer Sawicki
30
- files:
31
- - CHANGELOG
32
- - lib/feedalizer.rb
33
- - tests/test.html
34
- - tests/tc_feedalizer.rb
35
- - TODO
36
- - COPYING
37
- - README
38
- - examples
39
- - examples/mongrel-news.rb
40
- - examples/pjvault.rb
41
- - examples/sydsvenskan-nemi.rb
42
- - bin/feedalizer
43
- test_files: []
44
-
45
- rdoc_options: []
46
-
47
- extra_rdoc_files: []
48
-
49
- executables:
50
- - feedalizer
51
- extensions: []
52
-
53
- requirements: []
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
54
11
 
12
+ date: 2008-03-27 00:00:00 +01:00
13
+ default_executable:
55
14
  dependencies:
56
15
  - !ruby/object:Gem::Dependency
57
16
  name: hpricot
58
17
  version_requirement:
59
- version_requirements: !ruby/object:Gem::Version::Requirement
18
+ version_requirements: !ruby/object:Gem::Requirement
60
19
  requirements:
61
- - - ">"
20
+ - - ">="
62
21
  - !ruby/object:Gem::Version
63
- version: 0.0.0
22
+ version: "0"
64
23
  version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: hoe
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 1.5.1
32
+ version:
33
+ description: Feedalizer is a *small* Ruby library that glues together Hpricot with the standard RSS library in a way that makes it easy to transform web pages into RSS feeds. If you ask me, it makes it *too* easy.
34
+ email:
35
+ - christoffer.sawicki@gmail.com
36
+ executables:
37
+ - feedalizer
38
+ extensions: []
39
+
40
+ extra_rdoc_files:
41
+ - CHANGELOG.txt
42
+ - COPYING.txt
43
+ - Manifest.txt
44
+ - README.txt
45
+ - TODO.txt
46
+ files:
47
+ - bin/feedalizer
48
+ - CHANGELOG.txt
49
+ - COPYING.txt
50
+ - examples/pjvault.rb
51
+ - examples/sydsvenskan-nemi.rb
52
+ - lib/feedalizer.rb
53
+ - logo.svg
54
+ - Manifest.txt
55
+ - Rakefile
56
+ - README.txt
57
+ - tests/test.html
58
+ - tests/test_feedalizer.rb
59
+ - TODO.txt
60
+ has_rdoc: true
61
+ homepage: http://termos.vemod.net/feedalizer
62
+ post_install_message:
63
+ rdoc_options:
64
+ - --main
65
+ - README.txt
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ requirements: []
81
+
82
+ rubyforge_project: feedalizer
83
+ rubygems_version: 1.0.1
84
+ signing_key:
85
+ specification_version: 2
86
+ summary: Transforms web pages into RSS feeds
87
+ test_files: []
88
+
data/CHANGELOG DELETED
@@ -1,7 +0,0 @@
1
- This changelog only mentions what you, as a user of Feedalizer,
2
- might want to know. See the Subversion log for more.
3
-
4
- [ 2006-08-23 20:23 ]
5
-
6
- Added optional limit parameter to scrape_items.
7
- Thanks to Thanh Vinh Tang for the hint that it is needed.
data/README DELETED
@@ -1,37 +0,0 @@
1
- ___ _ _ _
2
- | __|__ ___ __| |__ _| (_)______ _ _
3
- | _/ -_) -_) _` / _` | | |_ / -_) '_|
4
- |_|\___\___\__,_\__,_|_|_/__\___|_|
5
-
6
- Project Website:
7
- http://termos.vemod.net/feedalizer
8
-
9
- = Dependencies
10
-
11
- * Hpricot
12
- http://code.whytheluckystiff.net/hpricot/
13
- % gem install hpricot
14
-
15
- = Documentation
16
-
17
- First of all, see the included examples. Then read some Hpricot
18
- documentation (http://code.whytheluckystiff.net/hpricot/).
19
-
20
- (Yes, a tutorial would be nice.)
21
-
22
- = Copyright
23
-
24
- Copyright (c) Christoffer Sawicki <christoffer.sawicki@gmail.com> 2006
25
-
26
- This program is free software; you can redistribute it and/or modify
27
- it under the terms of the GNU General Public License version 2 as
28
- published by the Free Software Foundation.
29
-
30
- This program is distributed in the hope that it will be useful,
31
- but WITHOUT ANY WARRANTY; without even the implied warranty of
32
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33
- GNU General Public License for more details.
34
-
35
- You should have received a copy of the GNU General Public License
36
- along with this program; if not, write to the Free Software
37
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@@ -1,45 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # This script was contributed by Chu Yeow Cheah, thanks!
4
-
5
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
6
-
7
- require 'feedalizer'
8
- require 'time'
9
-
10
- url = 'http://mongrel.rubyforge.org/news.html'
11
-
12
- feedalize(url) do
13
-
14
- feed.title = 'Mongrel News'
15
- feed.about = '...'
16
- feed.description = 'Latest Mongrel news from the official site'
17
-
18
- scrape_items('h2') do |rss_item, html_element|
19
-
20
- siblings = html_element.parent.containers
21
- html_element_index = siblings.index(html_element)
22
-
23
- date, title = html_element.innerHTML.strip.split(':')
24
- date = Time.parse(date.sub(/-/, ' ')) # date is before the first ':'
25
- title.strip!
26
-
27
- # Grab siblings after the <h2> and put into description.
28
- description = ''
29
- (html_element_index+1...siblings.size).each do |i|
30
- next_sibling = siblings[i]
31
- unless 'h2' == next_sibling.stag.name
32
- description = description + next_sibling.to_s
33
- else
34
- break
35
- end
36
- end
37
-
38
- rss_item.link = url
39
- rss_item.title = title
40
- rss_item.date = date
41
- rss_item.description = description
42
- end
43
-
44
- output!
45
- end