Skip to content

Commit

Permalink
better README and updated to gavagai release
Browse files Browse the repository at this point in the history
  • Loading branch information
ngrunwald committed Sep 6, 2012
1 parent 5c4ebfb commit d960ed2
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 7 deletions.
78 changes: 72 additions & 6 deletions README.md
@@ -1,26 +1,92 @@
# clj-rome

A simple Clojure wrapper for the ROME feed parsing and manipulation library. Right now only the wrapper for feed parsing and fetching are implemented.
A simple Clojure wrapper for the [ROME](http://rometools.org/) feed parsing and manipulation library. Right now only the wrapper for feed parsing and fetching are implemented.

## Usage

```clojure
;; build-feed will automaticaly dispatch on an xml string, a filepath or an url
;; returns a SyndFeedImpl object
(use 'clj-rome.reader)
(def feed (build-feed "test/clj_rome/test/feeds/lacuisinededoria.xml"))
```

The return value of `build-feed` is a lazy structure recursively translated from Java to Clojure with [gavagai](https://github.com/ngrunwald/gavagai). It has keys corresponding to the Java getter methods.

```clojure
(keys feed)

=> (:foreign-markup :published-date :entries :preserving-wire-feed? :copyright :link :contributors :author :supported-feed-types :feed-type :image :language :title :uri :categories :original :modules :interface :links :encoding :authors :title-ex :description :description-ex)

(first (:entries feed))

=> {:enclosures [],
:foreign-markup [],
:wire-entry nil,
:published-date #inst "2011-03-16T06:00:00.000-00:00",
:link "http://lacuisinededoria.over-blog.com/article-magret-laque-au-miel-epice-quenelles-de-navets-jaunes-et-polenta-69083687.html",
:contributors [],
:author "",
:title "Magret laqué au miel épicé, quenelles de navets jaunes et polenta",
:uri "ae447456b7dda12824d4e2dbf7e13279",
:updated-date nil,
:categories [{:name "Canard", :taxonomy-uri nil}],
:modules [{:subject nil,
:creator nil,
:date #inst "2011-03-16T06:00:00.000-00:00",
:identifier nil,
:formats [],
:subjects [],
:creators [],
:types [],
:contributors [],
:coverages [],
:contributor nil,
:language nil,
:title nil,
:uri "http://purl.org/dc/elements/1.1/",
:identifiers [],
:rights nil,
:rights-list [],
:coverage nil,
:type nil,
:interface com.sun.syndication.feed.module.DCModule,
:sources [],
:dates [#inst "2011-03-16T06:00:00.000-00:00"],
:format nil,
:publishers [],
:relations [],
:descriptions [],
:languages [],
:source nil,
:relation nil,
:titles [],
:publisher nil,
:description nil}],
:interface com.sun.syndication.feed.synd.SyndEntry,
:links [],
:authors [],
:title-ex {:type nil,
:interface com.sun.syndication.feed.synd.SyndContent,
:mode nil,
:value "Magret laqué au miel épicé, quenelles de navets jaunes et polenta"},
:description {:type "text/html",
:interface com.sun.syndication.feed.synd.SyndContent,
:mode nil,
:value "<p style=\"text-align: center;\"> <span style=\"font-family: comic sans ms,sans-serif; font-size: 12pt;\">Une recette réalisée par mon mari qui aime de plus en plus la cuisine et me \"voler\" la place derrière les fourneaux !</span></p>"},
:contents []}
```

You can use the ROME fetcher to retrieve a feed from the web with caching and conditional GET handled for you:

```clojure
;; creating a caching fetcher
(use 'clj-rome.fetcher)
(def fetcher (build-url-fetcher :disk "/tmp/cache"))

;; using the fetcher with a cache to fetch a feed
(def fetched
(def feed
(with-fetcher fetcher
(retrieve-feed "http://www.atomenabled.org/atom.xml")))

;; get-entries returns a vector of SyndEntryImpl
(def title (:title (first (:entries feed))))
```

For more documentation on ROME, see the [ROME javadocs](http://www.jarvana.com/jarvana/view/net/java/dev/rome/rome/1.0.0/rome-1.0.0-javadoc.jar!/index.html).
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Expand Up @@ -3,4 +3,4 @@
:dependencies [[org.clojure/clojure "1.4.0"]
[net.java.dev.rome/rome "1.0.0"]
[net.java.dev.rome/rome-fetcher "1.0.0"]
[gavagai "0.1.0-SNAPSHOT"]])
[gavagai "0.1.0"]])

0 comments on commit d960ed2

Please sign in to comment.