tinyatom 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/tinyatom/feed.rb +21 -14
- data/tinyatom.gemspec +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/tinyatom/feed.rb
CHANGED
@@ -6,12 +6,11 @@ module TinyAtom
|
|
6
6
|
class Feed
|
7
7
|
|
8
8
|
def initialize(site_url, title, feed_url, options={})
|
9
|
-
@site_url, @title, @feed_url = site_url, title, feed_url
|
9
|
+
@site_url, @title, @feed_url, @feed_options = site_url, title, feed_url,
|
10
|
+
options
|
10
11
|
|
11
12
|
@site_domain = URI(@site_url).domain
|
12
13
|
|
13
|
-
@hubs = options[:hubs] || []
|
14
|
-
|
15
14
|
@entries = []
|
16
15
|
end
|
17
16
|
|
@@ -35,7 +34,10 @@ module TinyAtom
|
|
35
34
|
xm.link(:href => feed_url, :rel => 'self')
|
36
35
|
xm.updated(updated.xmlschema)
|
37
36
|
xm.id(site_url)
|
38
|
-
|
37
|
+
TinyAtom::author(xm, feed_options)
|
38
|
+
feed_options.fetch(:hubs, []).each do |hub|
|
39
|
+
xm.link(:rel => 'hub', :href => hub)
|
40
|
+
end
|
39
41
|
|
40
42
|
entries.each do |e|
|
41
43
|
xm.entry {
|
@@ -44,6 +46,7 @@ module TinyAtom
|
|
44
46
|
xm.id(entry_id(e))
|
45
47
|
xm.updated(e[:updated])
|
46
48
|
xm.summary(e[:summary]) if e[:summary]
|
49
|
+
xm.content(e[:content]) if e[:content]
|
47
50
|
|
48
51
|
TinyAtom::author(xm, e)
|
49
52
|
TinyAtom::enclosure(xm, e)
|
@@ -65,8 +68,8 @@ module TinyAtom
|
|
65
68
|
attr_reader :site_url
|
66
69
|
attr_reader :title
|
67
70
|
attr_reader :feed_url
|
71
|
+
attr_reader :feed_options
|
68
72
|
attr_reader :site_domain
|
69
|
-
attr_reader :hubs
|
70
73
|
attr_reader :entries
|
71
74
|
end
|
72
75
|
|
@@ -74,29 +77,33 @@ module TinyAtom
|
|
74
77
|
|
75
78
|
# Add author tags if present
|
76
79
|
def author(markup, h)
|
77
|
-
if h[:author_name]
|
80
|
+
if h[:author_name]
|
78
81
|
markup.author {
|
79
82
|
markup.name(h[:author_name]) if h[:author_name]
|
80
|
-
markup.
|
81
|
-
markup.
|
83
|
+
markup.email(h[:author_email]) if h[:author_email]
|
84
|
+
markup.uri(h[:author_uri]) if h[:author_uri]
|
82
85
|
}
|
83
86
|
end
|
84
87
|
end
|
85
88
|
|
86
89
|
# Add enclosure tags if present
|
87
90
|
def enclosure(markup, h)
|
88
|
-
if h[:enclosure_type] and h[:
|
89
|
-
|
90
|
-
|
91
|
+
if h[:enclosure_type] and h[:enclosure_href] and h[:enclosure_title]
|
92
|
+
link(markup, 'enclosure', h[:enclosure_type], h[:enclosure_href],
|
93
|
+
h[:enclosure_title])
|
91
94
|
end
|
92
95
|
end
|
93
96
|
|
94
97
|
# Add via tags if present
|
95
98
|
def via(markup, h)
|
96
|
-
if h[:via_type] and h[:
|
97
|
-
|
98
|
-
:href => h[:via_url], :title => h[:via_title])
|
99
|
+
if h[:via_type] and h[:via_href] and h[:via_title]
|
100
|
+
link(markup, 'via', h[:via_type], h[:via_href], h[:via_title])
|
99
101
|
end
|
100
102
|
end
|
101
103
|
|
104
|
+
# Create link tag
|
105
|
+
def link(markup, rel, type, href, title)
|
106
|
+
markup.link(:rel => rel, :type => type, :href => href, :title => title)
|
107
|
+
end
|
108
|
+
|
102
109
|
end
|
data/tinyatom.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tinyatom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matthew M. Boedicker
|