rss-atom-feed_history 0.0.3.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -3,5 +3,7 @@ require "bundler/gem_tasks"
3
3
  require 'rake/testtask'
4
4
  require 'yard'
5
5
 
6
+ task :default => :test
7
+
6
8
  Rake::TestTask.new
7
9
  YARD::Rake::YardocTask.new
@@ -17,7 +17,18 @@ module RSS
17
17
  def included(klass)
18
18
  ELEMENTS.each do |name|
19
19
  full_name = "#{PREFIX}_#{name}"
20
- klass.install_have_child_element(name, URI, '?', full_name)
20
+ klass.install_must_call_validator PREFIX, URI
21
+ klass.install_have_child_element name, URI, '?', full_name
22
+ # This is a dirty redifinition. Should define writer type `:feed_history` and pass it to `install_have_child_element`?
23
+ klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
24
+ def #{full_name}_element(need_convert=true, indent='')
25
+ if @#{full_name}
26
+ Atom::FeedHistory::#{Utils.to_class_name(name)}.new.to_s(need_convert, indent)
27
+ else
28
+ ''
29
+ end
30
+ end
31
+ EOC
21
32
  end
22
33
  end
23
34
  end
@@ -1,6 +1,7 @@
1
1
  module RSS
2
2
  module Atom
3
3
  class Feed
4
+ install_ns FeedHistory::PREFIX, FeedHistory::URI
4
5
  include FeedHistory
5
6
  end
6
7
  end
@@ -1,7 +1,7 @@
1
1
  module RSS
2
2
  module Atom
3
3
  module FeedHistory
4
- VERSION = "0.0.3.2"
4
+ VERSION = "0.0.4"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,23 @@
1
+ require 'rss/atom/feed_history'
2
+ require 'rss/maker'
3
+
4
+ module RSS
5
+ module Maker
6
+ module Atom
7
+ module FeedHistory
8
+ class << self
9
+ def append_features(klass)
10
+ super
11
+
12
+ ::RSS::Atom::FeedHistory::ELEMENTS.each do |name|
13
+ full_name = "#{::RSS::Atom::FeedHistory::PREFIX}_#{name}"
14
+ klass.def_other_element full_name
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ class ChannelBase; include Atom::FeedHistory; end
22
+ end
23
+ end
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = RSS::Atom::FeedHistory::VERSION
17
17
 
18
- gem.add_development_dependency 'test-unit'
18
+ gem.add_development_dependency 'test-unit-full'
19
19
  gem.add_development_dependency 'simplecov'
20
20
  gem.add_development_dependency 'yard'
21
21
  gem.add_development_dependency 'redcarpet'
@@ -0,0 +1,60 @@
1
+ require 'test/unit/full'
2
+ require 'rexml/document'
3
+ require 'rss/maker/atom/feed_history'
4
+
5
+ class TestFeedHistory < Test::Unit::TestCase
6
+ def setup
7
+ @uri = 'http://purl.org/syndication/history/1.0'
8
+ end
9
+
10
+ class TestMaker < TestFeedHistory
11
+ def test_namespace_existence
12
+ doc = REXML::Document.new(make_feed.to_s)
13
+ assert_include doc.root.namespaces.values, @uri
14
+ end
15
+
16
+ def test_set_fh_element
17
+ complete_feed = make_feed {|maker| maker.channel.fh_complete = true}
18
+ doc = REXML::Document.new(complete_feed.to_s)
19
+ fh_elements = REXML::XPath.match(doc, "//*[namespace-uri()='#{@uri}']")
20
+ assert_not_empty fh_elements
21
+ end
22
+
23
+ def test_set_complete
24
+ complete_feed = make_feed {|maker| maker.channel.fh_complete = true}
25
+ doc = REXML::Document.new(complete_feed.to_s)
26
+ complete_element = REXML::XPath.first(doc, "//*[namespace-uri()='#{@uri}'][local-name()='complete']")
27
+ assert_equal '<fh:complete/>', complete_element.to_s
28
+ end
29
+
30
+ def test_set_archive
31
+ complete_feed = make_feed {|maker| maker.channel.fh_archive = true}
32
+ doc = REXML::Document.new(complete_feed.to_s)
33
+ archive_element = REXML::XPath.first(doc, "//*[namespace-uri()='#{@uri}'][local-name()='archive']")
34
+ assert_equal '<fh:archive/>', archive_element.to_s
35
+ end
36
+
37
+ def test_unset_complete
38
+ complete_feed = make_feed {|maker|
39
+ maker.channel.fh_complete = false
40
+ maker.channel.fh_archive = true
41
+ }
42
+ doc = REXML::Document.new(complete_feed.to_s)
43
+ complete_element = REXML::XPath.first(doc, "//*[namespace-uri()='#{@uri}'][local-name()='complete']")
44
+ assert_nil complete_element
45
+ end
46
+
47
+ private
48
+
49
+ def make_feed
50
+ RSS::Maker.make('atom') do |maker|
51
+ %w[id author title].each do |property|
52
+ maker.channel.send "#{property}=", property
53
+ end
54
+ maker.channel.updated = Time.now
55
+
56
+ yield maker if block_given?
57
+ end
58
+ end
59
+ end
60
+ 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.3.2
4
+ version: 0.0.4
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-10-07 00:00:00.000000000Z
12
+ date: 2012-10-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: test-unit
16
- requirement: &17876580 !ruby/object:Gem::Requirement
15
+ name: test-unit-full
16
+ requirement: &4972280 !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: *17876580
24
+ version_requirements: *4972280
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: simplecov
27
- requirement: &17875300 !ruby/object:Gem::Requirement
27
+ requirement: &4971520 !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: *17875300
35
+ version_requirements: *4971520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: yard
38
- requirement: &17873720 !ruby/object:Gem::Requirement
38
+ requirement: &4970600 !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: *17873720
46
+ version_requirements: *4970600
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: redcarpet
49
- requirement: &17833740 !ruby/object:Gem::Requirement
49
+ requirement: &4969880 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *17833740
57
+ version_requirements: *4969880
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: pry
60
- requirement: &17833100 !ruby/object:Gem::Requirement
60
+ requirement: &4968960 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *17833100
68
+ version_requirements: *4968960
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry-doc
71
- requirement: &17831960 !ruby/object:Gem::Requirement
71
+ requirement: &4968060 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *17831960
79
+ version_requirements: *4968060
80
80
  description: Enables standard bundled RSS library parse and make feeds including "Feed
81
81
  Paging and Archiving"(RFC 5005).
82
82
  email:
@@ -93,8 +93,10 @@ files:
93
93
  - lib/rss/atom/feed_history.rb
94
94
  - lib/rss/atom/feed_history/atom.rb
95
95
  - lib/rss/atom/feed_history/version.rb
96
+ - lib/rss/maker/atom/feed_history.rb
96
97
  - rss-atom-feed_history.gemspec
97
98
  - setup.rb
99
+ - test/test_feed_history.rb
98
100
  homepage: http://rss-ext.rubyforge.org/
99
101
  licenses: []
100
102
  post_install_message:
@@ -109,7 +111,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
111
  version: '0'
110
112
  segments:
111
113
  - 0
112
- hash: -3739305800348400313
114
+ hash: -149253708578188249
113
115
  required_rubygems_version: !ruby/object:Gem::Requirement
114
116
  none: false
115
117
  requirements:
@@ -118,12 +120,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
120
  version: '0'
119
121
  segments:
120
122
  - 0
121
- hash: -3739305800348400313
123
+ hash: -149253708578188249
122
124
  requirements: []
123
125
  rubyforge_project:
124
126
  rubygems_version: 1.8.8
125
127
  signing_key:
126
128
  specification_version: 3
127
129
  summary: Feed Paging and Archiving support for standard bundled RSS library
128
- test_files: []
130
+ test_files:
131
+ - test/test_feed_history.rb
129
132
  has_rdoc: