feedvalidator 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.travis.yml +10 -0
- data/Gemfile +2 -0
- data/README.md +71 -0
- data/Rakefile +16 -0
- data/feedvalidator.gemspec +23 -0
- data/lib/feed_validator.rb +151 -148
- data/lib/feed_validator/assertions.rb +70 -70
- data/test/feeds/weblog.rubyonrails.org_rss_2_0_articles.xml +14 -11
- data/test/unit/feed_validator_assertions_test.rb +26 -25
- data/test/unit/feed_validator_test.rb +51 -50
- metadata +81 -49
- data/README +0 -71
- data/rakefile +0 -109
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bde10f8cafaa7c9178d757b85928686685531244
|
4
|
+
data.tar.gz: 31a0ef70f2f842b951a143c80a7ea3abe90b499d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ac20e1b26b07723a310c942f8fbfa9da465e5b54cd002ed9f574b1d792ae479cf8885a170ae547e760f36e9e6c92d949db4b677a8880e2b352761713a10f7ab8
|
7
|
+
data.tar.gz: f971a4c67e56acca285532fd7374e6cec90dd06da40ccc2a479242f88be997983d7421bb6889a15bc3e5a72ba596ab53a51aa5d458fff83cefc43cf90203261c
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# FeedValidator [![Build Status](https://travis-ci.org/edgar/feedvalidator.png?branch=master)](https://travis-ci.org/edgar/feedvalidator) [![Gem Version](https://badge.fury.io/rb/feedvalidator.svg)](http://badge.fury.io/rb/feedvalidator)
|
2
|
+
|
3
|
+
FeedValidator is an interface to the [W3C Feed Validation online service](http://validator.w3.org/feed/),
|
4
|
+
based on its SOAP 1.2 support.
|
5
|
+
|
6
|
+
It helps to find errors in RSS or ATOM feeds.
|
7
|
+
|
8
|
+
FeedValidator add a new assertion (`assert_valid_feed`) which you can use in Rails applications.
|
9
|
+
This assertion implements a cache to improve the performance of the tests and to not abuse of the
|
10
|
+
[W3C Feed Validation online service](http://validator.w3.org/feed/)
|
11
|
+
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'feed_validator'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install feed_validator
|
28
|
+
|
29
|
+
|
30
|
+
## Examples
|
31
|
+
|
32
|
+
* For use FeedValidator just do this:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
require 'feed_validator'
|
36
|
+
|
37
|
+
v = W3C::FeedValidator.new()
|
38
|
+
v.validate_url('http://www.w3.org/QA/news.rss')
|
39
|
+
puts v.to_s unless v.valid?
|
40
|
+
```
|
41
|
+
|
42
|
+
* In Rails you can use it in your functional tests, just modify your /test/test_helper.rb adding this line:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
require 'feed_validator/assertions'
|
46
|
+
```
|
47
|
+
|
48
|
+
And now you can use in your functional test, in this way:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
def test_bar_valid_feed
|
52
|
+
get :bar
|
53
|
+
assert_valid_feed
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
Or use the class-level method to quickly create validation tests for a bunch of actions at once:
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
assert_valid_feed :bar, :foo
|
61
|
+
```
|
62
|
+
|
63
|
+
## Documentation
|
64
|
+
|
65
|
+
Documentation can be found at
|
66
|
+
|
67
|
+
* http://feedvalidator.rubyforge.org
|
68
|
+
|
69
|
+
## License
|
70
|
+
|
71
|
+
FeedValidator is released under the MIT license.
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
desc "Default Task"
|
7
|
+
task :default => [ :test_all ]
|
8
|
+
|
9
|
+
# Run the unit tests
|
10
|
+
|
11
|
+
Rake::TestTask.new("test_all") { |t|
|
12
|
+
t.libs << "test"
|
13
|
+
t.pattern = 'test/**/*_test.rb'
|
14
|
+
t.verbose = true
|
15
|
+
}
|
16
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Describe your gem and declare its dependencies:
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "feed_validator"
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.files = `git ls-files`.split($\)
|
7
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
8
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
9
|
+
gem.summary = %q{Interface to the W3C Feed Validation online service http://validator.w3.org/feed/}
|
10
|
+
gem.name = "feedvalidator"
|
11
|
+
gem.require_paths = ["lib"]
|
12
|
+
gem.version = W3C::FeedValidator::VERSION
|
13
|
+
gem.license = "MIT"
|
14
|
+
gem.authors = ["Edgar Gonzalez"]
|
15
|
+
gem.email = ["edgargonzalez@gmail.com"]
|
16
|
+
gem.description = %q{Interface to the W3C Feed Validation online service http://validator.w3.org/feed/}
|
17
|
+
|
18
|
+
gem.add_development_dependency 'rake'
|
19
|
+
|
20
|
+
if RUBY_VERSION > '2.0.0'
|
21
|
+
gem.add_development_dependency 'test-unit'
|
22
|
+
end
|
23
|
+
end
|
data/lib/feed_validator.rb
CHANGED
@@ -19,151 +19,154 @@
|
|
19
19
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
20
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
#
|
24
|
-
# Provide an interface to the {W3C Feed Validation online service}[http://validator.w3.org/feed/],
|
25
|
-
# based on its SOAP 1.2 support.
|
26
|
-
#
|
27
|
-
require 'net/http'
|
28
|
-
require 'cgi'
|
29
|
-
require 'rexml/document'
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
#
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
#
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
#
|
54
|
-
# <tt>:
|
55
|
-
#
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
#
|
60
|
-
# <tt>:
|
61
|
-
#
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
#
|
66
|
-
# <tt>:
|
67
|
-
#
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
#
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
#
|
78
|
-
#
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
msg
|
118
|
-
|
119
|
-
msg << "
|
120
|
-
|
121
|
-
msg
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
:
|
136
|
-
:
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
:
|
146
|
-
:
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
:
|
155
|
-
:
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
@
|
165
|
-
@
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
end
|
22
|
+
#++
|
23
|
+
#
|
24
|
+
# Provide an interface to the {W3C Feed Validation online service}[http://validator.w3.org/feed/],
|
25
|
+
# based on its SOAP 1.2 support.
|
26
|
+
#
|
27
|
+
require 'net/http'
|
28
|
+
require 'cgi'
|
29
|
+
require 'rexml/document'
|
30
|
+
|
31
|
+
|
32
|
+
module W3C
|
33
|
+
|
34
|
+
# Implements an interface to the {W3C Feed Validation online service}[http://validator.w3.org/feed/],
|
35
|
+
# based on its SOAP 1.2 support.
|
36
|
+
#
|
37
|
+
# It helps to find errors in RSS or Atom feeds.
|
38
|
+
# ---
|
39
|
+
# Please remember that the {W3C Feed Validation service}[http://validator.w3.org/feed/] is a shared resource,
|
40
|
+
# so do not abuse it: you should make your scripts sleep between requests.
|
41
|
+
#
|
42
|
+
class FeedValidator
|
43
|
+
VERSION = "0.2.0"
|
44
|
+
|
45
|
+
# True if the w3c feed validation service not found errors in the feed.
|
46
|
+
#
|
47
|
+
attr_reader :valid
|
48
|
+
|
49
|
+
# The complete response (as Net::HTTPResponse object) sent it by the w3c feed validation service.
|
50
|
+
#
|
51
|
+
attr_reader :response
|
52
|
+
|
53
|
+
# Collection of _errors_ founded by the w3c feed validation service.
|
54
|
+
# Every error is a hash containing: <tt>:type</tt>, <tt>:line</tt>,
|
55
|
+
# <tt>:column</tt>, <tt>:text</tt>, <tt>:element</tt>
|
56
|
+
#
|
57
|
+
attr_reader :errors
|
58
|
+
|
59
|
+
# Collection of _warnings_ founded by the w3c feed validation service.
|
60
|
+
# Every error is a hash containing: <tt>:type</tt>, <tt>:line</tt>,
|
61
|
+
# <tt>:column</tt>, <tt>:text</tt>, <tt>:element</tt>
|
62
|
+
#
|
63
|
+
attr_reader :warnings
|
64
|
+
|
65
|
+
# Collection of _informations_ founded by the w3c feed validation service.
|
66
|
+
# Every error is a hash containing: <tt>:type</tt>, <tt>:line</tt>,
|
67
|
+
# <tt>:column</tt>, <tt>:text</tt>, <tt>:element</tt>
|
68
|
+
#
|
69
|
+
attr_reader :informations
|
70
|
+
|
71
|
+
# Initialize the feed validator object
|
72
|
+
#
|
73
|
+
def initialize
|
74
|
+
clear
|
75
|
+
end
|
76
|
+
|
77
|
+
# Validate the data provided.
|
78
|
+
# Returns a true value if the validation succeeded (regardless of whether the feed contains errors).
|
79
|
+
#
|
80
|
+
def validate_data(rawdata)
|
81
|
+
clear
|
82
|
+
params = "rawdata=#{CGI.escape(rawdata)}&manual=1&output=soap12"
|
83
|
+
begin
|
84
|
+
# headers = VERSION == "1.8.4" ? {'Content-Type'=>'application/x-www-form-urlencoded'} : {}
|
85
|
+
headers = {'Content-Type'=>'application/x-www-form-urlencoded'}
|
86
|
+
@response = Net::HTTP.start('validator.w3.org',80) {|http|
|
87
|
+
http.post('/feed/check.cgi',params,headers)
|
88
|
+
}
|
89
|
+
rescue Exception => e
|
90
|
+
warn "Exception: #{e.class}: #{e.message}\n\t#{e.backtrace.join("\n\t")}" if $VERBOSE
|
91
|
+
return false
|
92
|
+
end
|
93
|
+
|
94
|
+
parse_response(@response.body)
|
95
|
+
return true
|
96
|
+
end
|
97
|
+
|
98
|
+
# Validate the url provided.
|
99
|
+
# Returns a true value if the validation succeeded (regardless of whether the feed contains errors).
|
100
|
+
#
|
101
|
+
def validate_url(url)
|
102
|
+
clear
|
103
|
+
params = "url=#{CGI.escape(url)}&output=soap12"
|
104
|
+
begin
|
105
|
+
@response = Net::HTTP.get_response('validator.w3.org',"/feed/check.cgi?#{params}",80)
|
106
|
+
rescue Exception => e
|
107
|
+
warn "Exception: #{e.class}: #{e.message}\n\t#{e.backtrace.join("\n\t")}" if $VERBOSE
|
108
|
+
return false
|
109
|
+
end
|
110
|
+
parse_response(@response.body)
|
111
|
+
return true
|
112
|
+
end
|
113
|
+
|
114
|
+
alias :valid? :valid
|
115
|
+
|
116
|
+
def to_s
|
117
|
+
msg = "Vailidity: #{@valid}\n"
|
118
|
+
msg << "Errors count: #{@errors.size}\n"
|
119
|
+
@errors.each_with_index{ |item, i| msg << "(#{i+1}) type: #{item[:type]} | line: #{item[:line]} | column: #{item[:column]} | text: #{item[:text]},\n"}
|
120
|
+
msg << "Warnings count: #{@warnings.size}\n"
|
121
|
+
@warnings.each_with_index{ |item, i| msg << "(#{i+1}) type: #{item[:type]} | line: #{item[:line]} | column: #{item[:column]} | text: #{item[:text]},\n"}
|
122
|
+
msg << "Informations count: #{@informations.size}\n"
|
123
|
+
@informations.each_with_index{ |item, i| msg << "(#{i+1}) type: #{item[:type]} | line: #{item[:line]} | column: #{item[:column]} | text: #{item[:text]},\n"}
|
124
|
+
msg
|
125
|
+
end
|
126
|
+
|
127
|
+
private
|
128
|
+
|
129
|
+
def parse_response(response) #nodoc
|
130
|
+
xml = REXML::Document.new(response)
|
131
|
+
@valid = (/true/.match(xml.root.elements["env:Body/m:feedvalidationresponse/m:validity"].get_text.value))? true : false
|
132
|
+
unless @valid
|
133
|
+
xml.elements.each("env:Envelope/env:Body/m:feedvalidationresponse/m:errors/m:errorlist/error") do |error|
|
134
|
+
@errors << {
|
135
|
+
:type => error.elements["type"].nil? ? "" : error.elements["type"].get_text.value,
|
136
|
+
:line => error.elements["line"].nil? ? "" : error.elements["line"].get_text.value,
|
137
|
+
:column => error.elements["column"].nil? ? "" : error.elements["column"].get_text.value,
|
138
|
+
:text => error.elements["text"].nil? ? "" : error.elements["text"].get_text.value,
|
139
|
+
:element => error.elements["element"].nil? ? "" : error.elements["element"].get_text.value
|
140
|
+
}
|
141
|
+
end
|
142
|
+
end
|
143
|
+
xml.elements.each("env:Envelope/env:Body/m:feedvalidationresponse/m:warnings/m:warninglist/warning") do |warning|
|
144
|
+
@warnings << {
|
145
|
+
:type => warning.elements["type"].nil? ? "" : warning.elements["type"].get_text.value,
|
146
|
+
:line => warning.elements["line"].nil? ? "" : warning.elements["line"].get_text.value,
|
147
|
+
:column => warning.elements["column"].nil? ? "" : warning.elements["column"].get_text.value,
|
148
|
+
:text => warning.elements["text"].nil? ? "" : warning.elements["text"].get_text.value,
|
149
|
+
:element => warning.elements["element"].nil? ? "" : warning.elements["element"].get_text.value
|
150
|
+
}
|
151
|
+
end
|
152
|
+
xml.elements.each("env:Envelope/env:Body/m:feedvalidationresponse/m:informations/m:infolist/information") do |info|
|
153
|
+
@informations << {
|
154
|
+
:type => info.elements["type"].nil? ? "" : info.elements["type"].get_text.value,
|
155
|
+
:line => info.elements["line"].nil? ? "" : info.elements["line"].get_text.value,
|
156
|
+
:column => info.elements["column"].nil? ? "" : info.elements["column"].get_text.value,
|
157
|
+
:text => info.elements["text"].nil? ? "" : info.elements["text"].get_text.value,
|
158
|
+
:element => info.elements["element"].nil? ? "" : info.elements["element"].get_text.value
|
159
|
+
}
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def clear #nodoc
|
164
|
+
@response = nil
|
165
|
+
@valid = false
|
166
|
+
@errors = []
|
167
|
+
@warnings = []
|
168
|
+
@informations = []
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
end
|
@@ -19,73 +19,73 @@
|
|
19
19
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
20
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
|
-
require 'feed_validator'
|
25
|
-
require 'test/unit'
|
26
|
-
require 'tmpdir'
|
27
|
-
require 'md5'
|
28
|
-
|
29
|
-
module W3C
|
30
|
-
class FeedValidator
|
31
|
-
# Parse a response from the w3c feed validation service.
|
32
|
-
# Used by assert_valid_feed
|
33
|
-
def parse(response)
|
34
|
-
clear
|
35
|
-
if response.respond_to?(:body)
|
36
|
-
parse_response(response.body)
|
37
|
-
else
|
38
|
-
parse_response(response)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
class Test::Unit::TestCase
|
45
|
-
|
46
|
-
# Assert that feed is valid according the {W3C Feed Validation online service}[http://validator.w3.org/feed/].
|
47
|
-
# By default, it validates the contents of @response.body, which is set after calling
|
48
|
-
# one of the get/post/etc helper methods in rails. You can also pass it a string to be validated.
|
49
|
-
# Validation errors, warnings and informations, if any, will be included in the output. The response from the validator
|
50
|
-
# service will be cached in the system temp directory to minimize duplicate calls.
|
51
|
-
#
|
52
|
-
# For example in Rails, if you have a FooController with an action Bar, put this in foo_controller_test.rb:
|
53
|
-
#
|
54
|
-
# def test_bar_valid_feed
|
55
|
-
# get :bar
|
56
|
-
# assert_valid_feed
|
57
|
-
# end
|
58
|
-
#
|
59
|
-
def assert_valid_feed(fragment=@response.body)
|
60
|
-
v = W3C::FeedValidator.new()
|
61
|
-
filename = File.join Dir::tmpdir, 'feed.' + MD5.
|
62
|
-
begin
|
63
|
-
response = File.open filename do |f| Marshal.load(f) end
|
64
|
-
v.parse(response)
|
65
|
-
rescue
|
66
|
-
unless v.validate_data(fragment)
|
67
|
-
warn("Sorry! could not validate the feed.")
|
68
|
-
return assert(true,'')
|
69
|
-
end
|
70
|
-
File.open filename, 'w+' do |f| Marshal.dump v.response, f end
|
71
|
-
end
|
72
|
-
assert(v.valid?, v.valid? ? '' : v.to_s)
|
73
|
-
end
|
74
|
-
|
75
|
-
# Class-level method to quickly create validation tests for a bunch of actions at once in Rails.
|
76
|
-
# For example, if you have a FooController with three actions, just add one line to foo_controller_test.rb:
|
77
|
-
#
|
78
|
-
# assert_valid_feed :bar, :baz, :qux
|
79
|
-
#
|
80
|
-
def self.assert_valid_feed(*actions)
|
81
|
-
actions.each do |action|
|
82
|
-
class_eval <<-EOF
|
83
|
-
def test_#{action}_valid_feed
|
84
|
-
get :#{action}
|
85
|
-
assert_valid_feed
|
86
|
-
end
|
87
|
-
EOF
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|
22
|
+
#++
|
23
|
+
|
24
|
+
require 'feed_validator'
|
25
|
+
require 'test/unit'
|
26
|
+
require 'tmpdir'
|
27
|
+
require 'digest/md5'
|
28
|
+
|
29
|
+
module W3C
|
30
|
+
class FeedValidator
|
31
|
+
# Parse a response from the w3c feed validation service.
|
32
|
+
# Used by assert_valid_feed
|
33
|
+
def parse(response)
|
34
|
+
clear
|
35
|
+
if response.respond_to?(:body)
|
36
|
+
parse_response(response.body)
|
37
|
+
else
|
38
|
+
parse_response(response)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class Test::Unit::TestCase
|
45
|
+
|
46
|
+
# Assert that feed is valid according the {W3C Feed Validation online service}[http://validator.w3.org/feed/].
|
47
|
+
# By default, it validates the contents of @response.body, which is set after calling
|
48
|
+
# one of the get/post/etc helper methods in rails. You can also pass it a string to be validated.
|
49
|
+
# Validation errors, warnings and informations, if any, will be included in the output. The response from the validator
|
50
|
+
# service will be cached in the system temp directory to minimize duplicate calls.
|
51
|
+
#
|
52
|
+
# For example in Rails, if you have a FooController with an action Bar, put this in foo_controller_test.rb:
|
53
|
+
#
|
54
|
+
# def test_bar_valid_feed
|
55
|
+
# get :bar
|
56
|
+
# assert_valid_feed
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
def assert_valid_feed(fragment=@response.body)
|
60
|
+
v = W3C::FeedValidator.new()
|
61
|
+
filename = File.join Dir::tmpdir, 'feed.' + Digest::MD5.hexdigest(fragment).to_s
|
62
|
+
begin
|
63
|
+
response = File.open filename do |f| Marshal.load(f) end
|
64
|
+
v.parse(response)
|
65
|
+
rescue
|
66
|
+
unless v.validate_data(fragment)
|
67
|
+
warn("Sorry! could not validate the feed.")
|
68
|
+
return assert(true,'')
|
69
|
+
end
|
70
|
+
File.open filename, 'w+' do |f| Marshal.dump v.response, f end
|
71
|
+
end
|
72
|
+
assert(v.valid?, v.valid? ? '' : v.to_s)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Class-level method to quickly create validation tests for a bunch of actions at once in Rails.
|
76
|
+
# For example, if you have a FooController with three actions, just add one line to foo_controller_test.rb:
|
77
|
+
#
|
78
|
+
# assert_valid_feed :bar, :baz, :qux
|
79
|
+
#
|
80
|
+
def self.assert_valid_feed(*actions)
|
81
|
+
actions.each do |action|
|
82
|
+
class_eval <<-EOF
|
83
|
+
def test_#{action}_valid_feed
|
84
|
+
get :#{action}
|
85
|
+
assert_valid_feed
|
86
|
+
end
|
87
|
+
EOF
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -1,7 +1,10 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
|
3
|
-
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"
|
3
|
+
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"
|
4
|
+
xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"
|
5
|
+
xmlns:atom="http://www.w3.org/2005/Atom">
|
4
6
|
<channel>
|
7
|
+
<atom:link href="http://weblog.rubyonrails.com/rss.xml" rel="self" type="application/rss+xml" />
|
5
8
|
<title>Riding Rails</title>
|
6
9
|
<link>http://weblog.rubyonrails.com/</link>
|
7
10
|
<language>en-us</language>
|
@@ -30,7 +33,7 @@
|
|
30
33
|
<p>Six months from now? The first annual <a href="http://railsconf.org">Rails Conference</a>. The next half year promises to be interesting. See you there.</p></description>
|
31
34
|
<pubDate>Wed, 01 Feb 2006 05:50:00 +0000</pubDate>
|
32
35
|
<guid isPermaLink="false">urn:uuid:967e9c30-7e78-4701-b9d4-bbf733495e87</guid>
|
33
|
-
<author
|
36
|
+
<author>foo@bar.com (Author)</author>
|
34
37
|
<link>http://weblog.rubyonrails.com/articles/2006/02/01/secrets-behind-ruby-on-rails-the-numbers</link>
|
35
38
|
<category>Horizon</category>
|
36
39
|
<category>Sightings</category>
|
@@ -41,7 +44,7 @@
|
|
41
44
|
<description><p>The <a href="http://www.litespeedtech.com/">LiteSpeed Web Server</a> is a commercial engine made to be largely config-compatible with Apache, but promising massive speed increases. If the web server is the bottleneck in your setup, you may just want to give it a look. And what better way than to get your Rails application up and running on it. Bob Silva explains <a href="http://www.railtie.net/articles/2006/01/21/up-and-running-in-the-speed-of-light">in easy steps how</a>.</p></description>
|
42
45
|
<pubDate>Thu, 26 Jan 2006 15:52:05 +0000</pubDate>
|
43
46
|
<guid isPermaLink="false">urn:uuid:bc8abcda-7759-4f1d-92d3-e5c0cc736d7a</guid>
|
44
|
-
<author>David</author>
|
47
|
+
<author>foo@bar.com (David)</author>
|
45
48
|
<link>http://weblog.rubyonrails.com/articles/2006/01/26/running-rails-on-the-litespeed-webserver</link>
|
46
49
|
<category>Sightings</category>
|
47
50
|
<trackback:ping>http://weblog.rubyonrails.com/archives/trackback/3087</trackback:ping>
|
@@ -60,7 +63,7 @@
|
|
60
63
|
<p><img src="http://redhanded.hobix.com/images/camping-xml-situps.png" /></p></description>
|
61
64
|
<pubDate>Thu, 26 Jan 2006 03:09:35 +0000</pubDate>
|
62
65
|
<guid isPermaLink="false">urn:uuid:677bdb11-f101-47a3-87da-9b4d7e020c7e</guid>
|
63
|
-
<author>
|
66
|
+
<author>foo@bar.com (Author)</author>
|
64
67
|
<link>http://weblog.rubyonrails.com/articles/2006/01/26/camping-a-micro-version-of-rails</link>
|
65
68
|
<category>Sightings</category>
|
66
69
|
<trackback:ping>http://weblog.rubyonrails.com/archives/trackback/3078</trackback:ping>
|
@@ -70,7 +73,7 @@
|
|
70
73
|
<description><p><a href="http://www.globalize-rails.org">www.globalize-rails.org</a> is the new home for the Globalize plugin that brings i18n functionality to Rails. They&#8217;re tackling everything from translations of model data, to proper formating of local times, and much anything in between. Velbekommen!</p></description>
|
71
74
|
<pubDate>Tue, 24 Jan 2006 23:10:19 +0000</pubDate>
|
72
75
|
<guid isPermaLink="false">urn:uuid:40718348-d229-4eb5-8125-211a142e856f</guid>
|
73
|
-
<author>
|
76
|
+
<author>foo@bar.com (Author)</author>
|
74
77
|
<link>http://weblog.rubyonrails.com/articles/2006/01/24/globalize-i18n-for-rails-gets-new-home</link>
|
75
78
|
<category>Sightings</category>
|
76
79
|
<trackback:ping>http://weblog.rubyonrails.com/archives/trackback/3056</trackback:ping>
|
@@ -80,7 +83,7 @@
|
|
80
83
|
<description><p><a href="http://osteele.com/projects/">Oliver Steele</a> is working on OpenLaszlo integration for Ruby on Rails. There&#8217;s a <a href="http://ropenlaszlo.rubyforge.org/">OpenLaszlo gem</a> out there now and <a href="http://laszlo-plugin.rubyforge.org/">a Rails plugin</a> to hook it all up for easy generation of OpenLaszlo applets. Check it out if <span class="caps">HTML</span> isn&#8217;t doing it for you on the view.</p></description>
|
81
84
|
<pubDate>Tue, 24 Jan 2006 23:00:22 +0000</pubDate>
|
82
85
|
<guid isPermaLink="false">urn:uuid:63154abc-8d98-40ee-8286-a59d4f207c27</guid>
|
83
|
-
<author>
|
86
|
+
<author>foo@bar.com (Author)</author>
|
84
87
|
<link>http://weblog.rubyonrails.com/articles/2006/01/24/openlaszlo-for-ruby-on-rails</link>
|
85
88
|
<category>Sightings</category>
|
86
89
|
<trackback:ping>http://weblog.rubyonrails.com/archives/trackback/3055</trackback:ping>
|
@@ -93,7 +96,7 @@
|
|
93
96
|
<p>So, if you&#8217;re the creator of a Rails addition of any kind, please do pick a license and include it with your software. I recommend <a href="http://dev.rubyonrails.org/browser/trunk/railties/MIT-LICENSE"><span class="caps">MIT</span></a>.</p></description>
|
94
97
|
<pubDate>Tue, 24 Jan 2006 17:36:50 +0000</pubDate>
|
95
98
|
<guid isPermaLink="false">urn:uuid:3d831e55-ced8-4674-aff1-a3973ea7db54</guid>
|
96
|
-
<author>
|
99
|
+
<author>foo@bar.com (Author)</author>
|
97
100
|
<link>http://weblog.rubyonrails.com/articles/2006/01/24/pick-a-license-for-your-rails-additions</link>
|
98
101
|
<category>General</category>
|
99
102
|
<trackback:ping>http://weblog.rubyonrails.com/archives/trackback/3032</trackback:ping>
|
@@ -112,7 +115,7 @@
|
|
112
115
|
<p>And coming soon will be Chad Fowler&#8217;s Rails Recipes and David A. Black&#8217;s Ruby for Rails, which will bring us to a total of six books. And I believe there&#8217;s at least a good handful of additional books in the works. Rails is certainly on track to be the best documented web framework for the dynamic languages. Rock on.</p></description>
|
113
116
|
<pubDate>Mon, 23 Jan 2006 23:27:00 +0000</pubDate>
|
114
117
|
<guid isPermaLink="false">urn:uuid:3b31f02e-96ff-4b67-970d-d29761bf3db6</guid>
|
115
|
-
<author>
|
118
|
+
<author>foo@bar.com (Author)</author>
|
116
119
|
<link>http://weblog.rubyonrails.com/articles/2006/01/23/oreillys-first-rails-book-premieres-in-beta-form</link>
|
117
120
|
<category>Documentation</category>
|
118
121
|
<trackback:ping>http://weblog.rubyonrails.com/archives/trackback/3017</trackback:ping>
|
@@ -125,7 +128,7 @@
|
|
125
128
|
<p>The <a href="http://www.prnewswire.com/cgi-bin/stories.pl?ACCT=104&amp;STORY=/www/story/01-20-2006/0004264613&amp;EDATE=">announcement</a> tells us that the book competes against such titles as Practical Common Lisp, Service-Oriented Architecture, and Wicked Cool Java. Rails 1.0 is going up against JBoss 4x, Coldfusion, and Zend Studio. Pretty exciting stuff. Hopefully we&#8217;ll be jolting in red shortly.</p></description>
|
126
129
|
<pubDate>Mon, 23 Jan 2006 05:02:16 +0000</pubDate>
|
127
130
|
<guid isPermaLink="false">urn:uuid:26b6880a-0b58-47f1-acb2-f3c71e893e93</guid>
|
128
|
-
<author>
|
131
|
+
<author>foo@bar.com (Author)</author>
|
129
132
|
<link>http://weblog.rubyonrails.com/articles/2006/01/23/rails-and-the-book-both-finalists-for-jolt-awards</link>
|
130
133
|
<category>Sightings</category>
|
131
134
|
<trackback:ping>http://weblog.rubyonrails.com/archives/trackback/3009</trackback:ping>
|
@@ -135,7 +138,7 @@
|
|
135
138
|
<description><p><a href="http://ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/176161">Rake 0.7.0</a> has taken a great leap forward with the addition of parallel execution tasks and namespaces. Upcoming releases of Rails will surely use namespaces, so please do familiarize yourself with them today. And many thanks to Jim Weirich for his continued stellar work on this.</p></description>
|
136
139
|
<pubDate>Fri, 20 Jan 2006 19:07:30 +0000</pubDate>
|
137
140
|
<guid isPermaLink="false">urn:uuid:22b06624-5713-483f-9e96-b2d0ee402187</guid>
|
138
|
-
<author>
|
141
|
+
<author>foo@bar.com (Author)</author>
|
139
142
|
<link>http://weblog.rubyonrails.com/articles/2006/01/20/rake-0-7-0-has-been-released</link>
|
140
143
|
<category>Tools</category>
|
141
144
|
<trackback:ping>http://weblog.rubyonrails.com/archives/trackback/3003</trackback:ping>
|
@@ -145,7 +148,7 @@
|
|
145
148
|
<description><p>The <a href="http://canadaonrails.com/yvr06-schedule.html">schedule and list of speakers</a> for Canada on Rails has been announced. The conference is happening April 13-14th in Vancouver.</p></description>
|
146
149
|
<pubDate>Fri, 20 Jan 2006 18:23:23 +0000</pubDate>
|
147
150
|
<guid isPermaLink="false">urn:uuid:d1246cb1-ec09-4195-a8d2-7d577e78f891</guid>
|
148
|
-
<author>
|
151
|
+
<author>foo@bar.com (Author)</author>
|
149
152
|
<link>http://weblog.rubyonrails.com/articles/2006/01/20/canada-on-rails-announces-schedule</link>
|
150
153
|
<category>Sightings</category>
|
151
154
|
<trackback:ping>http://weblog.rubyonrails.com/archives/trackback/3000</trackback:ping>
|
@@ -19,30 +19,31 @@
|
|
19
19
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
20
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
$:.unshift(File.dirname(__FILE__) + "/../../lib/")
|
24
|
-
|
22
|
+
#++
|
23
|
+
$:.unshift(File.dirname(__FILE__) + "/../../lib/")
|
24
|
+
|
25
25
|
require 'test/unit'
|
26
|
-
require 'feed_validator/assertions'
|
26
|
+
require 'feed_validator/assertions'
|
27
|
+
require 'digest/md5'
|
27
28
|
|
28
|
-
class FeedValidatorAssertionsTest < Test::Unit::TestCase
|
29
|
-
|
30
|
-
def test_assert_valid_feed
|
31
|
-
# a valid feed
|
32
|
-
data = ""
|
33
|
-
File.open(File.dirname(__FILE__) + "/../feeds/" + "www.w3.org_news.rss.xml").each { |line|
|
34
|
-
data << line
|
35
|
-
}
|
36
|
-
assert_valid_feed(data)
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_cache
|
40
|
-
# testing the cache using an invalid feed with a success response cached
|
41
|
-
fragment_feed = ">--invalid feed--<"
|
42
|
-
response = File.open File.dirname(__FILE__) + "/../responses/success_with_warnings" do |f| Marshal.load(f) end
|
43
|
-
filename = File.join Dir::tmpdir, 'feed.' + MD5.
|
44
|
-
File.open filename, 'w+' do |f| Marshal.dump response, f end
|
45
|
-
assert_valid_feed(fragment_feed)
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
29
|
+
class FeedValidatorAssertionsTest < Test::Unit::TestCase
|
30
|
+
|
31
|
+
def test_assert_valid_feed
|
32
|
+
# a valid feed
|
33
|
+
data = ""
|
34
|
+
File.open(File.dirname(__FILE__) + "/../feeds/" + "www.w3.org_news.rss.xml").each { |line|
|
35
|
+
data << line
|
36
|
+
}
|
37
|
+
assert_valid_feed(data)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_cache
|
41
|
+
# testing the cache using an invalid feed with a success response cached
|
42
|
+
fragment_feed = ">--invalid feed--<"
|
43
|
+
response = File.open File.dirname(__FILE__) + "/../responses/success_with_warnings" do |f| Marshal.load(f) end
|
44
|
+
filename = File.join Dir::tmpdir, 'feed.' + Digest::MD5.hexdigest(fragment_feed).to_s
|
45
|
+
File.open filename, 'w+' do |f| Marshal.dump response, f end
|
46
|
+
assert_valid_feed(fragment_feed)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -19,55 +19,56 @@
|
|
19
19
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
20
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
21
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
$:.unshift(File.dirname(__FILE__) + "/../../lib/")
|
24
|
-
|
22
|
+
#++
|
23
|
+
$:.unshift(File.dirname(__FILE__) + "/../../lib/")
|
24
|
+
|
25
25
|
require 'test/unit'
|
26
|
-
require 'feed_validator'
|
26
|
+
require 'feed_validator'
|
27
|
+
|
28
|
+
class FeedValidatorTest < Test::Unit::TestCase
|
29
|
+
|
30
|
+
def test_validate_url
|
31
|
+
v = W3C::FeedValidator.new()
|
32
|
+
assert v.validate_url('http://www.w3.org/QA/news.rss')
|
33
|
+
if v.valid?
|
34
|
+
assert v.errors.size == 0
|
35
|
+
else
|
36
|
+
assert v.errors.size > 0
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_validate_data
|
41
|
+
v = W3C::FeedValidator.new()
|
42
|
+
|
43
|
+
data = ""
|
44
|
+
File.open(File.dirname(__FILE__) + "/../feeds/" + "weblog.rubyonrails.org_rss_2_0_articles.xml").each { |line|
|
45
|
+
data << line
|
46
|
+
}
|
47
|
+
assert v.validate_data(data)
|
48
|
+
assert v.valid?
|
49
|
+
|
50
|
+
assert v.errors.size == 0
|
51
|
+
#assert v.warnings.size == 0
|
52
|
+
assert v.informations.size == 0
|
27
53
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
assert v.
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
v
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
assert v.errors.size > 0
|
50
|
-
assert v.warnings.size == 0
|
51
|
-
assert v.informations.size == 0
|
52
|
-
|
53
|
-
data = ""
|
54
|
-
File.open(File.dirname(__FILE__) + "/../feeds/" + "www.w3.org_news.rss.xml").each { |line|
|
55
|
-
data << line
|
56
|
-
}
|
57
|
-
assert v.validate_data(data)
|
58
|
-
assert v.valid?
|
59
|
-
assert v.errors.size == 0
|
60
|
-
assert v.warnings.size >= 1
|
61
|
-
|
62
|
-
data = ""
|
63
|
-
File.open(File.dirname(__FILE__) + "/../feeds/" + "weblog.rubyonrails.org_rss_2_0_articles_malformed.xml").each { |line|
|
64
|
-
data << line
|
65
|
-
}
|
66
|
-
assert v.validate_data(data)
|
67
|
-
assert !v.valid?
|
68
|
-
assert v.errors.size == 1
|
69
|
-
assert v.errors.first[:line] == "5"
|
70
|
-
assert v.errors.first[:column] == "4"
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
54
|
+
data = ""
|
55
|
+
File.open(File.dirname(__FILE__) + "/../feeds/" + "www.w3.org_news.rss.xml").each { |line|
|
56
|
+
data << line
|
57
|
+
}
|
58
|
+
assert v.validate_data(data)
|
59
|
+
assert v.valid?
|
60
|
+
assert v.errors.size == 0
|
61
|
+
assert v.warnings.size >= 1
|
62
|
+
|
63
|
+
data = ""
|
64
|
+
File.open(File.dirname(__FILE__) + "/../feeds/" + "weblog.rubyonrails.org_rss_2_0_articles_malformed.xml").each { |line|
|
65
|
+
data << line
|
66
|
+
}
|
67
|
+
assert v.validate_data(data)
|
68
|
+
assert !v.valid?
|
69
|
+
assert v.errors.size == 1
|
70
|
+
assert v.errors.first[:line] == "5"
|
71
|
+
assert v.errors.first[:column] == "4"
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
metadata
CHANGED
@@ -1,62 +1,94 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.0
|
3
|
-
specification_version: 1
|
1
|
+
--- !ruby/object:Gem::Specification
|
4
2
|
name: feedvalidator
|
5
|
-
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2006-08-28 00:00:00 -04:00
|
8
|
-
summary: An interface to the W3C Feed Validation online service
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: edgar@lacaraoscura.com
|
12
|
-
homepage: http://feedvalidator.rubyforge.org
|
13
|
-
rubyforge_project: feedvalidator
|
14
|
-
description: Implements a simple system for generating UUIDs.
|
15
|
-
autorequire: feed_validator
|
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:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
25
5
|
platform: ruby
|
26
|
-
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
|
-
authors:
|
6
|
+
authors:
|
30
7
|
- Edgar Gonzalez
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
-
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: test-unit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Interface to the W3C Feed Validation online service http://validator.w3.org/feed/
|
42
|
+
email:
|
43
|
+
- edgargonzalez@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".travis.yml"
|
35
50
|
- CHANGELOG
|
36
|
-
-
|
51
|
+
- Gemfile
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- feedvalidator.gemspec
|
55
|
+
- install.rb
|
37
56
|
- lib/feed_validator.rb
|
38
57
|
- lib/feed_validator/assertions.rb
|
39
|
-
- test/feeds
|
40
|
-
- test/responses
|
41
|
-
- test/unit
|
42
58
|
- test/feeds/weblog.rubyonrails.org_rss_2_0_articles.xml
|
43
59
|
- test/feeds/weblog.rubyonrails.org_rss_2_0_articles_malformed.xml
|
44
60
|
- test/feeds/www.w3.org_news.rss.xml
|
45
61
|
- test/responses/success_with_warnings
|
46
62
|
- test/unit/feed_validator_assertions_test.rb
|
47
63
|
- test/unit/feed_validator_test.rb
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
64
|
+
homepage:
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
59
82
|
requirements: []
|
60
|
-
|
61
|
-
|
62
|
-
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.4.5
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Interface to the W3C Feed Validation online service http://validator.w3.org/feed/
|
88
|
+
test_files:
|
89
|
+
- test/feeds/weblog.rubyonrails.org_rss_2_0_articles.xml
|
90
|
+
- test/feeds/weblog.rubyonrails.org_rss_2_0_articles_malformed.xml
|
91
|
+
- test/feeds/www.w3.org_news.rss.xml
|
92
|
+
- test/responses/success_with_warnings
|
93
|
+
- test/unit/feed_validator_assertions_test.rb
|
94
|
+
- test/unit/feed_validator_test.rb
|
data/README
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
= FeedValidator
|
2
|
-
|
3
|
-
FeedValidator is an interface to the {W3C Feed Validation online service}[http://validator.w3.org/feed/],
|
4
|
-
based on its SOAP 1.2 support.
|
5
|
-
|
6
|
-
It helps to find errors in RSS or ATOM feeds.
|
7
|
-
|
8
|
-
FeedValidator add a new assertion (<code>assert_valid_feed</code>) which you can use in Rails applications.
|
9
|
-
This assertion implements a cache to improve the performance of the tests and to not abuse of the
|
10
|
-
{W3C Feed Validation online service}[http://validator.w3.org/feed/]
|
11
|
-
|
12
|
-
|
13
|
-
== Examples
|
14
|
-
|
15
|
-
* For use FeedValidator just do this:
|
16
|
-
|
17
|
-
require 'feed_validator'
|
18
|
-
|
19
|
-
v = W3C::FeedValidator.new()
|
20
|
-
v.validate_url('http://www.w3.org/QA/news.rss')
|
21
|
-
puts v.to_s unless v.valid?
|
22
|
-
|
23
|
-
* In Rails you can use it in your functional tests, just modify your /test/test_helper.rb adding this line:
|
24
|
-
|
25
|
-
require 'feed_validator/assertions'
|
26
|
-
|
27
|
-
And now you can use in your functional test, in this way:
|
28
|
-
|
29
|
-
def test_bar_valid_feed
|
30
|
-
get :bar
|
31
|
-
assert_valid_feed
|
32
|
-
end
|
33
|
-
|
34
|
-
Or use the class-level method to quickly create validation tests for a bunch of actions at once:
|
35
|
-
|
36
|
-
assert_valid_feed :bar, :foo
|
37
|
-
|
38
|
-
|
39
|
-
== Download
|
40
|
-
|
41
|
-
The latest version of FeedValidator can be found at
|
42
|
-
|
43
|
-
* http://rubyforge.org/frs/?group_id=1533
|
44
|
-
|
45
|
-
Documentation can be found at
|
46
|
-
|
47
|
-
* http://feedvalidator.rubyforge.org
|
48
|
-
|
49
|
-
|
50
|
-
== Installation
|
51
|
-
|
52
|
-
You can install FeedValidator as a gem:
|
53
|
-
gem install feedvalidator
|
54
|
-
|
55
|
-
Or you can install it from the tarball or zip packages on the download page
|
56
|
-
and then extract it to your lib directory as you would with any other
|
57
|
-
Ruby library.
|
58
|
-
|
59
|
-
|
60
|
-
== License
|
61
|
-
|
62
|
-
FeedValidator is released under the MIT license.
|
63
|
-
|
64
|
-
|
65
|
-
== Support
|
66
|
-
|
67
|
-
You can find the Feed Validator RubyForge page at http://rubyforge.org/projects/feedvalidator.
|
68
|
-
|
69
|
-
Feel free to submit commits or feature requests.
|
70
|
-
|
71
|
-
For other information, feel free to contact mailto:edgar@lacaraoscura.com.
|
data/rakefile
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
require 'rake/testtask'
|
4
|
-
require 'rake/rdoctask'
|
5
|
-
require 'rake/packagetask'
|
6
|
-
require 'rake/gempackagetask'
|
7
|
-
require 'rake/contrib/rubyforgepublisher'
|
8
|
-
|
9
|
-
PKG_NAME = 'feedvalidator'
|
10
|
-
PKG_VERSION = '0.1.2'
|
11
|
-
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
12
|
-
|
13
|
-
RELEASE_NAME = "REL #{PKG_VERSION}"
|
14
|
-
|
15
|
-
RUBY_FORGE_PROJECT = "feedvalidator"
|
16
|
-
RUBY_FORGE_USER = "edgar"
|
17
|
-
|
18
|
-
PKG_FILES = FileList[
|
19
|
-
"lib/**/*", "test/**/*", "examples/**/*", "doc/**/*", "[A-Z]*", "install.rb", "rakefile"
|
20
|
-
].exclude(/\b.svn\b|~$/)
|
21
|
-
|
22
|
-
desc "Default Task"
|
23
|
-
task :default => [ :test_all ]
|
24
|
-
|
25
|
-
# Run the unit tests
|
26
|
-
|
27
|
-
Rake::TestTask.new("test_all") { |t|
|
28
|
-
t.libs << "test"
|
29
|
-
t.pattern = 'test/**/*_test.rb'
|
30
|
-
t.verbose = true
|
31
|
-
}
|
32
|
-
|
33
|
-
# Generate the RDoc documentation
|
34
|
-
|
35
|
-
Rake::RDocTask.new { |rdoc|
|
36
|
-
rdoc.rdoc_dir = 'doc'
|
37
|
-
rdoc.title = "FeedValidator"
|
38
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
39
|
-
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
40
|
-
rdoc.rdoc_files.include('README', 'CHANGELOG')
|
41
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
42
|
-
}
|
43
|
-
|
44
|
-
# Create compressed packages
|
45
|
-
|
46
|
-
dist_dirs = [ "lib", "test" ]
|
47
|
-
|
48
|
-
spec = Gem::Specification.new do |s|
|
49
|
-
s.name = PKG_NAME
|
50
|
-
s.version = PKG_VERSION
|
51
|
-
s.summary = "An interface to the W3C Feed Validation online service"
|
52
|
-
s.description = "Implements a simple system for generating UUIDs."
|
53
|
-
|
54
|
-
s.files = [ "rakefile", "install.rb", "README", "CHANGELOG" ]
|
55
|
-
dist_dirs.each do |dir|
|
56
|
-
s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if do |item|
|
57
|
-
item.include?( "\.svn" )
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
s.require_path = 'lib'
|
62
|
-
s.autorequire = 'feed_validator'
|
63
|
-
|
64
|
-
s.has_rdoc = true
|
65
|
-
s.extra_rdoc_files = %w( README )
|
66
|
-
s.rdoc_options.concat ['--main', 'README']
|
67
|
-
|
68
|
-
s.author = "Edgar Gonzalez"
|
69
|
-
s.email = "edgar@lacaraoscura.com"
|
70
|
-
s.homepage = "http://feedvalidator.rubyforge.org"
|
71
|
-
s.rubyforge_project = "feedvalidator"
|
72
|
-
end
|
73
|
-
|
74
|
-
Rake::GemPackageTask.new(spec) do |p|
|
75
|
-
p.gem_spec = spec
|
76
|
-
p.need_tar = true
|
77
|
-
p.need_zip = true
|
78
|
-
end
|
79
|
-
|
80
|
-
task :lines do
|
81
|
-
lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
|
82
|
-
|
83
|
-
for file_name in FileList["lib/**/*.rb"]
|
84
|
-
f = File.open(file_name)
|
85
|
-
|
86
|
-
while line = f.gets
|
87
|
-
lines += 1
|
88
|
-
next if line =~ /^\s*$/
|
89
|
-
next if line =~ /^\s*#/
|
90
|
-
codelines += 1
|
91
|
-
end
|
92
|
-
puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
|
93
|
-
|
94
|
-
total_lines += lines
|
95
|
-
total_codelines += codelines
|
96
|
-
|
97
|
-
lines, codelines = 0, 0
|
98
|
-
end
|
99
|
-
|
100
|
-
puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
|
101
|
-
end
|
102
|
-
|
103
|
-
|
104
|
-
# Publishing ------------------------------------------------------
|
105
|
-
|
106
|
-
desc "Publish the API documentation"
|
107
|
-
task :pdoc => [:rdoc] do
|
108
|
-
Rake::SshDirPublisher.new("edgar@rubyforge.org", "/var/www/gforge-projects/feedvalidator/", "doc").upload
|
109
|
-
end
|