tinyatom 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -55,10 +55,10 @@ puts feed.make(:indent => 2)
55
55
  # open('atom.xml', 'w') { |f| feed.make(:target => f) }
56
56
 
57
57
  <?xml version="1.0" encoding="UTF-8"?>
58
- <feed xmlns:media="http://purl.org/syndication/atommedia" xmlns="http://www.w3.org/2005/Atom">
58
+ <feed xmlns:media="http://search.yahoo.com/mrss/" xmlns="http://www.w3.org/2005/Atom">
59
59
  <title>My Blog</title>
60
60
  <link rel="self" href="http://mysite.com/blog/atom.xml"/>
61
- <updated>2010-11-14T10:35:27-05:00</updated>
61
+ <updated>2010-11-14T11:36:03-05:00</updated>
62
62
  <id>http://mysite.com/blog/</id>
63
63
  <author>
64
64
  <name>me</name>
@@ -70,7 +70,7 @@ puts feed.make(:indent => 2)
70
70
  <title>post 1</title>
71
71
  <link href="http://mysite.com/blog/1"/>
72
72
  <id>tag:mysite.com,2010-11-14:1</id>
73
- <updated>2010-11-14T10:35:27-05:00</updated>
73
+ <updated>2010-11-14T11:36:03-05:00</updated>
74
74
  <summary>the summary</summary>
75
75
  <content>the content</content>
76
76
  <author>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
data/lib/tinyatom.rb CHANGED
@@ -1,4 +1,2 @@
1
- Dir.glob(File.join(File.dirname(__FILE__), 'tinyatom', '*.rb')).
2
- map { |f| File.join('tinyatom', File.basename(f, '.rb')) }.
3
- sort.
4
- each { |m| require m }
1
+ require 'tinyatom/feed'
2
+ require 'tinyatom/uri'
data/lib/tinyatom/feed.rb CHANGED
@@ -25,46 +25,46 @@ module TinyAtom
25
25
  }.merge(options)
26
26
  end
27
27
 
28
- # Build the feed and return a Builder::XmlMarkup
28
+ # Build the feed and return a Builder::XmlMarkup.
29
29
  def make(options={})
30
30
  xm = Builder::XmlMarkup.new(options)
31
- xm.instruct!(:xml)
31
+ xm.instruct! :xml
32
32
 
33
33
  xm.feed(:xmlns => 'http://www.w3.org/2005/Atom',
34
34
  :'xmlns:media' => 'http://search.yahoo.com/mrss/') {
35
- xm.title(title)
36
- xm.link(:href => feed_url, :rel => 'self')
37
- xm.updated(updated.xmlschema)
38
- xm.id(site_url)
39
- TinyAtom::author(xm, feed_options)
35
+ xm.title title
36
+ xm.link :href => feed_url, :rel => 'self'
37
+ xm.updated updated.xmlschema
38
+ xm.id site_url
39
+ TinyAtom::author xm, feed_options
40
40
  feed_options.fetch(:hubs, []).each do |hub|
41
- xm.link(:rel => 'hub', :href => hub)
41
+ xm.link :rel => 'hub', :href => hub
42
42
  end
43
43
 
44
44
  entries.each do |e|
45
45
  xm.entry {
46
- xm.title(e[:title])
47
- xm.link(:href => e[:link])
48
- xm.id(entry_id(e))
49
- xm.updated(e[:updated].xmlschema)
50
- xm.summary(e[:summary]) if e[:summary]
51
- xm.content(e[:content]) if e[:content]
52
-
53
- (e[:authors] || [e]).each { |h| TinyAtom::author(xm, h) }
54
- (e[:enclosures] || [e]).each { |h| TinyAtom::enclosure(xm, h) }
46
+ xm.title e[:title]
47
+ xm.link :href => e[:link]
48
+ xm.id entry_id(e)
49
+ xm.updated e[:updated].xmlschema
50
+ xm.summary(e[:summary]) if e[:summary]
51
+ xm.content(e[:content]) if e[:content]
52
+
53
+ (e[:authors] || [e]).each { |h| TinyAtom::author xm, h }
54
+ (e[:enclosures] || [e]).each { |h| TinyAtom::enclosure xm, h }
55
55
  (e[:media_thumbnails] || [e]).each do |h|
56
- TinyAtom::media_thumbnail(xm, h)
56
+ TinyAtom::media_thumbnail xm, h
57
57
  end
58
- TinyAtom::via(xm, e)
58
+ TinyAtom::via xm, e
59
59
  }
60
60
  end
61
61
  }
62
62
  end
63
63
 
64
- # Return the last update time of the feed
64
+ # Return the last update time of the feed.
65
65
  def updated; entries.map { |e| e[:updated] }.max; end
66
66
 
67
- # Build an entry id
67
+ # Build an entry id.
68
68
  def entry_id(e)
69
69
  # http://diveintomark.org/archives/2004/05/28/howto-atom-id
70
70
  "tag:#{site_domain},#{e[:updated].strftime('%Y-%m-%d')}:#{e[:id]}"
@@ -80,13 +80,13 @@ module TinyAtom
80
80
 
81
81
  module_function
82
82
 
83
- # Add author tags if present
83
+ # Add author tags if present.
84
84
  def author(markup, h)
85
85
  if h[:author_name]
86
86
  markup.author {
87
- markup.name(h[:author_name])
88
- markup.email(h[:author_email]) if h[:author_email]
89
- markup.uri(h[:author_uri]) if h[:author_uri]
87
+ markup.name h[:author_name]
88
+ markup.email(h[:author_email]) if h[:author_email]
89
+ markup.uri(h[:author_uri]) if h[:author_uri]
90
90
  }
91
91
  end
92
92
  end
@@ -96,7 +96,7 @@ module TinyAtom
96
96
  :enclosure_length => :length,
97
97
  }
98
98
 
99
- # Add enclosure tags if present
99
+ # Add enclosure tags if present.
100
100
  def enclosure(markup, h)
101
101
  if h[:enclosure_type] and h[:enclosure_href] and h[:enclosure_title]
102
102
  options = {}
@@ -106,8 +106,8 @@ module TinyAtom
106
106
  end
107
107
  end
108
108
 
109
- link(markup, 'enclosure', h[:enclosure_type], h[:enclosure_href],
110
- h[:enclosure_title], options)
109
+ link markup, 'enclosure', h[:enclosure_type], h[:enclosure_href],
110
+ h[:enclosure_title], options
111
111
  end
112
112
  end
113
113
 
@@ -128,19 +128,19 @@ module TinyAtom
128
128
  end
129
129
  end
130
130
 
131
- markup.media(:thumbnail,
132
- { :url => h[:media_thumbnail_url] }.merge(options))
131
+ markup.media :thumbnail,
132
+ { :url => h[:media_thumbnail_url] }.merge(options)
133
133
  end
134
134
  end
135
135
 
136
- # Add via tags if present
136
+ # Add via tags if present.
137
137
  def via(markup, h)
138
138
  if h[:via_type] and h[:via_href] and h[:via_title]
139
- link(markup, 'via', h[:via_type], h[:via_href], h[:via_title])
139
+ link markup, 'via', h[:via_type], h[:via_href], h[:via_title]
140
140
  end
141
141
  end
142
142
 
143
- # Create link tag
143
+ # Create link tag.
144
144
  def link(markup, rel, type, href, title, options={})
145
145
  markup.link({
146
146
  :rel => rel,
data/lib/tinyatom/uri.rb CHANGED
@@ -2,7 +2,7 @@ require 'uri'
2
2
 
3
3
  class URI::Generic
4
4
 
5
- # Add domain method to URI
5
+ # Add domain method to URI.
6
6
  def domain
7
7
  if (host and (d = host[/[a-z\d-]+\.[a-z]{2,}(\.[a-z]{2})?$/]))
8
8
  d.downcase
data/tinyatom.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tinyatom}
8
- s.version = "0.3.2"
8
+ s.version = "0.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matthew M. Boedicker"]
12
- s.date = %q{2010-11-14}
12
+ s.date = %q{2010-11-21}
13
13
  s.description = %q{Small and easy to use ruby Atom feed generator.}
14
14
  s.email = %q{matthewm@boedicker.org}
15
15
  s.extra_rdoc_files = [
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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matthew M. Boedicker
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-14 00:00:00 -05:00
18
+ date: 2010-11-21 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency