rss-atom-feed_history 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -20,10 +20,11 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- require 'rss/atom/feed_history'
23
+ require 'rss/atom/feed_history/atom'
24
24
 
25
25
  feed = RSS::Parser.parse uri
26
- feed.fh_complete # => RSS::Atom::FeedHistory::Complete object
26
+ feed.complete? # => true when the feed includes <fh:complete/>
27
+ arch = open(feed.previous_archive_page) if feed.archived?
27
28
 
28
29
  ## Contributing
29
30
 
@@ -0,0 +1,9 @@
1
+ require 'rss/atom/feed_history'
2
+
3
+ module RSS
4
+ module Atom
5
+ class Feed
6
+ include FeedHistory
7
+ end
8
+ end
9
+ end
@@ -1,7 +1,7 @@
1
1
  module RSS
2
2
  module Atom
3
3
  module FeedHistory
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  end
7
7
  end
@@ -10,6 +10,8 @@ module RSS
10
10
  'complete',
11
11
  'archive'
12
12
  ]
13
+ PAGED_FEED_RELS = ['first', 'last', 'previous', 'next']
14
+ ARCHIVED_FEED_RELS = ['prev-archive', 'next-archive', 'current']
13
15
 
14
16
  class << self
15
17
  def included(klass)
@@ -20,6 +22,27 @@ module RSS
20
22
  end
21
23
  end
22
24
 
25
+ def complete?
26
+ !!fh_complete
27
+ end
28
+
29
+ def paged?
30
+ links.any? {|link| FeedHistory::PAGED_FEED_RELS.include? link.rel}
31
+ end
32
+
33
+ def archived?
34
+ !!fh_archive
35
+ end
36
+
37
+ (PAGED_FEED_RELS + ARCHIVED_FEED_RELS).each do |rel|
38
+ method_name = "#{rel}_page".gsub(/-/, '_')
39
+ define_method(method_name) do
40
+ if link = links.find {|link| link.rel == rel}
41
+ link.href
42
+ end
43
+ end
44
+ end
45
+
23
46
  ELEMENTS.each do |name|
24
47
  module_eval(<<-EOC, *Utils.get_file_and_line_from_caller(0))
25
48
  class #{Utils.to_class_name(name)} < Element
@@ -51,9 +74,5 @@ module RSS
51
74
  BaseListener.install_class_name(URI, name, Utils.to_class_name(name))
52
75
  end
53
76
  end
54
-
55
- class Feed
56
- include FeedHistory
57
- end
58
77
  end
59
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rss-atom-feed_history
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-02 00:00:00.000000000Z
12
+ date: 2012-04-03 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-unit
16
- requirement: &14149480 !ruby/object:Gem::Requirement
16
+ requirement: &17839340 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *14149480
24
+ version_requirements: *17839340
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: simplecov
27
- requirement: &14149040 !ruby/object:Gem::Requirement
27
+ requirement: &17838920 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *14149040
35
+ version_requirements: *17838920
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: yard
38
- requirement: &14148620 !ruby/object:Gem::Requirement
38
+ requirement: &17838500 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *14148620
46
+ version_requirements: *17838500
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: pry
49
- requirement: &14148200 !ruby/object:Gem::Requirement
49
+ requirement: &17838080 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *14148200
57
+ version_requirements: *17838080
58
58
  description: Enables standard bundled RSS library parse and make feeds including "Feed
59
59
  Paging and Archiving"(RFC 5005).
60
60
  email:
@@ -69,6 +69,7 @@ files:
69
69
  - README.md
70
70
  - Rakefile
71
71
  - lib/rss/atom/feed_history.rb
72
+ - lib/rss/atom/feed_history/atom.rb
72
73
  - lib/rss/atom/feed_history/version.rb
73
74
  - rss-atom-feed_history.gemspec
74
75
  - setup.rb
@@ -86,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
86
87
  version: '0'
87
88
  segments:
88
89
  - 0
89
- hash: -2374968449051688314
90
+ hash: -2424412047240753055
90
91
  required_rubygems_version: !ruby/object:Gem::Requirement
91
92
  none: false
92
93
  requirements:
@@ -95,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
96
  version: '0'
96
97
  segments:
97
98
  - 0
98
- hash: -2374968449051688314
99
+ hash: -2424412047240753055
99
100
  requirements: []
100
101
  rubyforge_project:
101
102
  rubygems_version: 1.8.8