Improved feed library with comments, bug fixes and code factorization.

This commit is contained in:
2015-09-08 21:45:27 +02:00
parent 39887c8bdb
commit a5e150d1c0
12 changed files with 46 additions and 41 deletions

View File

@@ -48,7 +48,7 @@ feature -- Access
then then
l_title := t l_title := t
create Result.make (l_title) create Result.make (l_title)
Result.set_description (xml_element_text (x_feed, "subtitle")) Result.set_description (xml_element_text (x_feed, "subtitle"), "plain")
Result.set_id (xml_element_text (x_feed, "id")) Result.set_id (xml_element_text (x_feed, "id"))
Result.set_updated_date_with_text (xml_element_text (x_feed, "updated")) Result.set_updated_date_with_text (xml_element_text (x_feed, "updated"))
if attached links_from_xml (x_feed, "link") as l_links then if attached links_from_xml (x_feed, "link") as l_links then

View File

@@ -10,20 +10,13 @@ inherit
FEED_VISITOR FEED_VISITOR
FEED_GENERATOR FEED_GENERATOR
rename
process_feed as visit_feed
end
create create
make make
feature {NONE} -- Initialization
make (a_buffer: STRING_8)
do
buffer := a_buffer
create indentation.make_empty
end
buffer: STRING_8
feature -- Visitor feature -- Visitor
visit_feed (a_feed: FEED) visit_feed (a_feed: FEED)

View File

@@ -1,6 +1,5 @@
note note
description: "Summary description for {FEED}." description: "FEED interface, could be RSS, ATOM, ..."
author: ""
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"
@@ -30,6 +29,10 @@ feature -- Access
description: detachable IMMUTABLE_STRING_32 description: detachable IMMUTABLE_STRING_32
-- Associated description/subtitle. -- Associated description/subtitle.
description_content_type: detachable READABLE_STRING_8
-- Optional content type for `description'.
-- By default, this should be text/plain.
id: detachable IMMUTABLE_STRING_32 id: detachable IMMUTABLE_STRING_32
-- Id associated with Current feed if any. -- Id associated with Current feed if any.
@@ -44,12 +47,15 @@ feature -- Access
feature -- Element change feature -- Element change
set_description (a_description: detachable READABLE_STRING_GENERAL) set_description (a_description: detachable READABLE_STRING_GENERAL; a_description_content_type: like description_content_type)
-- Set `description' with `a_description' and optional content type `text:$a_description_content_type'.
do do
if a_description = Void then if a_description = Void then
description := Void description := Void
description_content_type := Void
else else
create description.make_from_string_general (a_description) create description.make_from_string_general (a_description)
description_content_type := a_description_content_type
end end
end end
@@ -83,6 +89,4 @@ feature -- Visitor
vis.visit_feed (Current) vis.visit_feed (Current)
end end
invariant
end end

View File

@@ -1,6 +1,5 @@
note note
description: "Summary description for {FEED_AUTHOR}." description: "Object representing author of Feed or feed entry."
author: ""
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"

View File

@@ -1,6 +1,5 @@
note note
description: "Summary description for {FEED_ENTRY}." description: "Item of feed."
author: ""
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"
@@ -170,6 +169,4 @@ feature -- Visitor
vis.visit_entry (Current) vis.visit_entry (Current)
end end
invariant
end end

View File

@@ -1,6 +1,5 @@
note note
description: "Summary description for {FEED_LINK}." description: "Link mentioned in feed and feed entry."
author: ""
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"
@@ -21,10 +20,13 @@ feature {NONE} -- Initialization
feature -- Access feature -- Access
href: READABLE_STRING_8 href: READABLE_STRING_8
-- Location of Current link.
relation: READABLE_STRING_32 relation: READABLE_STRING_32
-- Relation associated with Current link.
type: detachable READABLE_STRING_8 type: detachable READABLE_STRING_8
-- Optional type of link.
feature -- Element change feature -- Element change

View File

@@ -51,7 +51,7 @@ feature -- Access
if attached x_rss.element_by_name ("channel") as x_channel then if attached x_rss.element_by_name ("channel") as x_channel then
if attached xml_element_text (x_channel, "title") as x_title then if attached xml_element_text (x_channel, "title") as x_title then
create Result.make (x_title) create Result.make (x_title)
Result.set_description (xml_element_text (x_channel, "description")) Result.set_description (xml_element_text (x_channel, "description"), "xhtml")
Result.set_updated_date_with_text (xml_element_text (x_channel, "lastBuildDate")) Result.set_updated_date_with_text (xml_element_text (x_channel, "lastBuildDate"))
if attached links_from_xml (x_channel, "link") as l_links then if attached links_from_xml (x_channel, "link") as l_links then
across across

View File

@@ -10,20 +10,13 @@ inherit
FEED_VISITOR FEED_VISITOR
FEED_GENERATOR FEED_GENERATOR
rename
process_feed as visit_feed
end
create create
make make
feature {NONE} -- Initialization
make (a_buffer: STRING_8)
do
buffer := a_buffer
initialize
end
buffer: STRING_8
feature -- Visitor feature -- Visitor
visit_feed (a_feed: FEED) visit_feed (a_feed: FEED)

View File

@@ -1,6 +1,5 @@
note note
description: "Summary description for {FEED_GENERATOR}." description: "Common ancestor for feed generator."
author: ""
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"
@@ -10,13 +9,28 @@ deferred class
inherit inherit
XML_UTILITIES XML_UTILITIES
feature {NONE} -- Helpers feature {NONE} -- Initialization
initialize make (a_buffer: STRING_8)
do do
buffer := a_buffer
create indentation.make_empty create indentation.make_empty
end end
feature -- Access
buffer: STRING_8
-- Output of feed conversion.
feature -- Conversion
process_feed (a_feed: FEED)
-- Convert `a_feed' into string representation in `buffer'.
deferred
end
feature {NONE} -- Helpers
indent indent
do do
indentation.append ("%T") indentation.append ("%T")

View File

@@ -1,6 +1,5 @@
note note
description: "Summary description for {FEED_VISITOR}." description: "Interface to visit Feed objects."
author: ""
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"

View File

@@ -98,6 +98,8 @@ echo Install library: openid
echo Install library: uri_template echo Install library: uri_template
%COPYCMD% %TMP_DIR%\library\text\parser\uri_template %TMP_CONTRIB_DIR%\library\text\parser\uri_template %COPYCMD% %TMP_DIR%\library\text\parser\uri_template %TMP_CONTRIB_DIR%\library\text\parser\uri_template
echo Install library: feed
%COPYCMD% %TMP_DIR%\library\text\parser\feed %TMP_CONTRIB_DIR%\library\text\parser\feed
echo Install library: notification_email echo Install library: notification_email
%SAFE_MD% %TMP_CONTRIB_DIR%\library\runtime %SAFE_MD% %TMP_CONTRIB_DIR%\library\runtime

View File

@@ -65,6 +65,8 @@ echo Uninstall library: security\openid
%RDCMD% %TMP_CONTRIB_DIR%\library\web\authentication\openid %RDCMD% %TMP_CONTRIB_DIR%\library\web\authentication\openid
echo Uninstall library: uri_template echo Uninstall library: uri_template
%RDCMD% %TMP_CONTRIB_DIR%\library\text\parser\uri_template %RDCMD% %TMP_CONTRIB_DIR%\library\text\parser\uri_template
echo Uninstall library: feed
%RDCMD% %TMP_CONTRIB_DIR%\library\text\parser\feed
echo Uninstall library: runtime\process\notification_email echo Uninstall library: runtime\process\notification_email
%RDCMD% %TMP_CONTRIB_DIR%\library\runtime\process\notification_email %RDCMD% %TMP_CONTRIB_DIR%\library\runtime\process\notification_email