superfeedr-superfeedr-ruby 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 0
2
+ :patch: 1
3
3
  :major: 0
4
4
  :minor: 3
@@ -9,6 +9,7 @@
9
9
  # - chunks (long entries might be notified in several chunks)
10
10
  # - chunk (current chunk out of chunks)
11
11
  #
12
+ require "cgi"
12
13
  class Item
13
14
  include SAXMachine
14
15
  element :item, :as => :chunk, :value => :chunk
@@ -19,6 +20,10 @@ class Item
19
20
  element :id, :as => :unique_id
20
21
  element :published
21
22
 
23
+ def link
24
+ CGI.unescape(@link).gsub("\n", "")
25
+ end
26
+
22
27
  def published
23
28
  Time.parse(@published)
24
29
  end
@@ -56,6 +61,10 @@ class NotificationStanza
56
61
  @http_status.to_i
57
62
  end
58
63
 
64
+ def feed_url
65
+ CGI.unescape(@feed_url).gsub("\n", "")
66
+ end
67
+
59
68
  element :http, :as => :message_status
60
69
  element :http, :as => :http_status, :value => :code
61
70
  element :status, :value => :feed, :as => :feed_url
data/lib/superfeedr.rb CHANGED
@@ -82,11 +82,11 @@ module Superfeedr
82
82
  ##
83
83
  # List all subscriptions, by sending them by blocks (page), starting at page specified in argument
84
84
  def self.subscriptions(start_page = 1, &block)
85
- Superfeedr.subscriptions_by_page(start_page) do |result|
85
+ Superfeedr.subscriptions_by_page(start_page) do |page, result|
86
86
  if !result.empty?
87
87
  subscriptions(start_page + 1, &block)
88
+ block.call(page, result)
88
89
  end
89
- block.call(result)
90
90
  end
91
91
  end
92
92
 
@@ -139,8 +139,8 @@ module Superfeedr
139
139
  ##
140
140
  # Called with a response to a subscriptions listing
141
141
  def self.on_subscriptions(stanza, &block)
142
- page = stanza.xpath('//xmlns:subscriptions', { 'xmlns' => 'http://jabber.org/protocol/pubsub' }).first["page"].to_i
143
- feeds = stanza.xpath('//xmlns:subscription', { 'xmlns' => 'http://jabber.org/protocol/pubsub' }).map { |s| s["node"] }
142
+ page = stanza.xpath('//subscriptions').first["page"].to_i
143
+ feeds = stanza.xpath('//subscription').map { |s| s["node"] }
144
144
  block.call(page, feeds)
145
145
  end
146
146
 
@@ -41,12 +41,12 @@ describe Superfeedr do
41
41
  it "should call subscriptions_by_page for each page as long as they're not empty" do
42
42
  def method_called_upon_page
43
43
  end
44
- self.should_receive(:method_called_upon_page).exactly(4).times
44
+ self.should_receive(:method_called_upon_page).exactly(3).times
45
45
  3.times do |t|
46
- Superfeedr.should_receive(:subscriptions_by_page).with(t+1).and_yield(["a", "b", "c"])
46
+ Superfeedr.should_receive(:subscriptions_by_page).with(t+1).and_yield( t+1 , ["a", "b", "c"])
47
47
  end
48
- Superfeedr.should_receive(:subscriptions_by_page).with(4).and_yield([])
49
- Superfeedr.subscriptions do |result|
48
+ Superfeedr.should_receive(:subscriptions_by_page).with(4).and_yield(4, [])
49
+ Superfeedr.subscriptions do |page, result|
50
50
  method_called_upon_page
51
51
  end
52
52
  end
@@ -219,8 +219,8 @@ EOXML
219
219
  it "should call the block with the page number and the list of feeds as an array" do
220
220
  xml = <<-EOXML
221
221
  <iq type="result" to="you@superfeedr.com/home" id="subman1" from="firehoser.superfeedr.com">
222
- <pubsub xmlns="http://jabber.org/protocol/pubsub" xmlns:superfeedr="http://superfeedr.com/xmpp-pubsub-ext" >
223
- <subscriptions superfeedr:page="3">
222
+ <pubsub>
223
+ <subscriptions page="3">
224
224
  <subscription node="http://domain.tld/path/to/a/feed/atom.xml" subscription="subscribed" jid="you@superfeedr.com" />
225
225
  <subscription node="http://domain2.tld/path/to/feed.rss" subscription="subscribed" jid="you@superfeedr.com" />
226
226
  </subscriptions>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: superfeedr-superfeedr-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - julien Genestoux
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-06 00:00:00 -07:00
12
+ date: 2009-06-09 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency