atomutil 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/lib/atomutil.rb +15 -15
- data/spec/feed_spec.rb +1 -0
- data/website/index.html +0 -11
- metadata +2 -2
data/History.txt
CHANGED
data/lib/atomutil.rb
CHANGED
@@ -55,7 +55,7 @@ module AtomUtil
|
|
55
55
|
module VERSION#:nodoc:
|
56
56
|
MAJOR = 0
|
57
57
|
MINOR = 0
|
58
|
-
TINY =
|
58
|
+
TINY = 3
|
59
59
|
STRING = [MAJOR, MINOR, TINY].join('.')
|
60
60
|
end
|
61
61
|
end
|
@@ -604,10 +604,10 @@ module Atom
|
|
604
604
|
def child_xpath(ns, element_name, attributes=nil)
|
605
605
|
ns_uri = ns.is_a?(Namespace) ? ns.uri : ns
|
606
606
|
unless !attributes.nil? && attributes.is_a?(Hash)
|
607
|
-
"
|
607
|
+
"child::*[local-name()='#{element_name}' and namespace-uri()='#{ns_uri}']"
|
608
608
|
else
|
609
609
|
attr_str = attributes.collect{|key, val| "@#{key.to_s}='#{val}'"}.join(' and ')
|
610
|
-
"
|
610
|
+
"child::*[local-name()='#{element_name}' and namespace-uri()='#{ns_uri}' and #{attr_str}]"
|
611
611
|
end
|
612
612
|
end
|
613
613
|
end
|
@@ -1435,7 +1435,7 @@ module Atompub
|
|
1435
1435
|
stream = file_path.open { |f| f.binmode; f.read }
|
1436
1436
|
service = @service_info.get(media_uri)
|
1437
1437
|
unless service.accept_media_type?(content_type)
|
1438
|
-
raise RequestError, "Unsupported Media Type"
|
1438
|
+
raise RequestError, "Unsupported Media Type: #{content_type}"
|
1439
1439
|
end
|
1440
1440
|
create_resource(media_uri, stream, content_type, slug)
|
1441
1441
|
@res['Location']
|
@@ -1496,7 +1496,7 @@ module Atompub
|
|
1496
1496
|
def get_contents_except_resources(uri, &block)
|
1497
1497
|
clear
|
1498
1498
|
uri = URI.parse(uri)
|
1499
|
-
@req = Net::HTTP::Get.new uri.
|
1499
|
+
@req = Net::HTTP::Get.new uri.request_uri
|
1500
1500
|
set_common_info(@req)
|
1501
1501
|
@http_class.start(uri.host, uri.port) do |http|
|
1502
1502
|
@res = http.request(@req)
|
@@ -1512,7 +1512,7 @@ module Atompub
|
|
1512
1512
|
def get_resource(uri)
|
1513
1513
|
clear
|
1514
1514
|
uri = URI.parse(uri)
|
1515
|
-
@req = Net::HTTP::Get.new uri.
|
1515
|
+
@req = Net::HTTP::Get.new uri.request_uri
|
1516
1516
|
set_common_info(@req)
|
1517
1517
|
cache = @cache.get(uri.to_s)
|
1518
1518
|
unless cache.nil?
|
@@ -1547,11 +1547,11 @@ module Atompub
|
|
1547
1547
|
def create_resource(uri, r, content_type, slug=nil)
|
1548
1548
|
clear
|
1549
1549
|
uri = URI.parse(uri)
|
1550
|
-
service = @service_info.get(uri.to_s)
|
1550
|
+
#service = @service_info.get(uri.to_s)
|
1551
1551
|
#unless service.accepts_media_type(content_type)
|
1552
1552
|
# raise UnsupportedMediaTypeError, "Unsupported media type: #{content_type}."
|
1553
1553
|
#end
|
1554
|
-
@req = Net::HTTP::Post.new uri.
|
1554
|
+
@req = Net::HTTP::Post.new uri.request_uri
|
1555
1555
|
@req['Content-Type'] = content_type
|
1556
1556
|
@req['Slug'] = URI.encode(URI.decode(slug)) unless slug.nil?
|
1557
1557
|
set_common_info(@req)
|
@@ -1560,8 +1560,8 @@ module Atompub
|
|
1560
1560
|
@res = http.request(@req)
|
1561
1561
|
case @res
|
1562
1562
|
when Net::HTTPSuccess
|
1563
|
-
warn "Bad Status Code" unless @res.class == Net::HTTPCreated
|
1564
|
-
warn "Bad Content Type" unless Atom::MediaType::ENTRY.is_a?(@res['Content-Type'])
|
1563
|
+
warn "Bad Status Code: #{@res.code}" unless @res.class == Net::HTTPCreated
|
1564
|
+
warn "Bad Content Type: #{@res['Content-Type']}" unless Atom::MediaType::ENTRY.is_a?(@res['Content-Type'])
|
1565
1565
|
if @res['Location'].nil?
|
1566
1566
|
raise ResponseError, "No Location"
|
1567
1567
|
end
|
@@ -1574,7 +1574,7 @@ module Atompub
|
|
1574
1574
|
}
|
1575
1575
|
end
|
1576
1576
|
else
|
1577
|
-
raise RequestError, "Failed to create resource."
|
1577
|
+
raise RequestError, "Failed to create resource. #{@res.code}"
|
1578
1578
|
end
|
1579
1579
|
end
|
1580
1580
|
end
|
@@ -1582,7 +1582,7 @@ module Atompub
|
|
1582
1582
|
def update_resource(uri, r, content_type)
|
1583
1583
|
clear
|
1584
1584
|
uri = URI.parse(uri)
|
1585
|
-
@req = Net::HTTP::Put.new uri.
|
1585
|
+
@req = Net::HTTP::Put.new uri.request_uri
|
1586
1586
|
@req['Content-Type'] = content_type
|
1587
1587
|
cache = @cache.get(uri.to_s)
|
1588
1588
|
unless cache.nil?
|
@@ -1612,7 +1612,7 @@ module Atompub
|
|
1612
1612
|
def delete_resource(uri)
|
1613
1613
|
clear
|
1614
1614
|
uri = URI.parse(uri)
|
1615
|
-
@req = Net::HTTP::Delete.new uri.
|
1615
|
+
@req = Net::HTTP::Delete.new uri.request_uri
|
1616
1616
|
@http_class.start(uri.host, uri.port) do |http|
|
1617
1617
|
@res = http.request(@req)
|
1618
1618
|
case @res
|
@@ -1661,7 +1661,7 @@ module Atompub
|
|
1661
1661
|
#
|
1662
1662
|
# Usaage:
|
1663
1663
|
#
|
1664
|
-
# req = Net::HTTP::Get.new uri.
|
1664
|
+
# req = Net::HTTP::Get.new uri.request_uri
|
1665
1665
|
# auth.authorize(req)
|
1666
1666
|
#
|
1667
1667
|
def authorize(req)
|
@@ -1704,7 +1704,7 @@ module Atompub
|
|
1704
1704
|
#
|
1705
1705
|
# Usage:
|
1706
1706
|
#
|
1707
|
-
# req = Net::HTTP::Get.new uri.
|
1707
|
+
# req = Net::HTTP::Get.new uri.request_uri
|
1708
1708
|
# auth.authorize(req)
|
1709
1709
|
#
|
1710
1710
|
def authorize(req)
|
data/spec/feed_spec.rb
CHANGED
@@ -12,6 +12,7 @@ describe Atom::Feed, "feed object" do
|
|
12
12
|
feed.self_link.should == 'http://example.org/feed.atom'
|
13
13
|
feed.rights.should == 'Copyright (c) 2003, Mark Pilgrim'
|
14
14
|
feed.generator.name.gsub(/^[\s\n]*(.+)[\s\n]*$/, '\1').should == 'Example Toolkit'
|
15
|
+
feed.links.length.should == 2
|
15
16
|
entry = feed.entries[0]
|
16
17
|
entry.title.should == 'Atom draft-07 snapshot'
|
17
18
|
entry.id.should == 'tag:example.org,2003:3.2397'
|
data/website/index.html
CHANGED
@@ -1,11 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
4
|
-
<title>atomutil</title>
|
5
|
-
|
6
|
-
</head>
|
7
|
-
<body id="body">
|
8
|
-
<p>This page has not yet been created for RubyGem <code>atomutil</code></p>
|
9
|
-
<p>To the developer: To generate it, update website/index.txt and run the rake task <code>website</code> to generate this <code>index.html</code> file.</p>
|
10
|
-
</body>
|
11
|
-
</html>
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: atomutil
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date:
|
6
|
+
version: 0.0.3
|
7
|
+
date: 2008-02-12 00:00:00 +09:00
|
8
8
|
summary: Utilities for AtomPub / Atom Syndication Format
|
9
9
|
require_paths:
|
10
10
|
- lib
|