lifestream 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/lifestream/branch.rb +8 -3
- data/lib/lifestream/channel/rss2.rb +1 -1
- data/test/lifestream/branch_test.rb +22 -0
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/lifestream/branch.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
module Lifestream
|
2
2
|
class Branch
|
3
3
|
|
4
|
-
attr_accessor :published_at, :title, :body
|
4
|
+
attr_accessor :channel, :published_at, :title, :body
|
5
5
|
|
6
|
-
def initialize published_at, title, body = nil
|
7
|
-
@published_at, @title, @body = published_at, title, body
|
6
|
+
def initialize channel, published_at, title, body = nil
|
7
|
+
@channel, @published_at, @title, @body = channel, published_at, title, body
|
8
|
+
unless @channel.kind_of?(Lifestream::Channel)
|
9
|
+
raise Lifestream::Branch::InvalidBranch.new('@channel is not a kind if Lifestream::Channel')
|
10
|
+
end
|
8
11
|
end
|
9
12
|
|
13
|
+
class InvalidBranch < StandardError; end
|
14
|
+
|
10
15
|
end
|
11
16
|
end
|
@@ -17,7 +17,7 @@ module Lifestream
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def to_branch(branch)
|
20
|
-
Lifestream::Branch.new(branch.pubDate, branch.title, branch.description)
|
20
|
+
Lifestream::Branch.new(self, branch.pubDate, branch.title, branch.description)
|
21
21
|
end
|
22
22
|
|
23
23
|
class MalformedFeed < StandardError; end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class BranchTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "A Lifestream::Branch instance" do
|
6
|
+
|
7
|
+
setup { @lifestream = Lifestream.run }
|
8
|
+
|
9
|
+
should "be aware of its parent channel" do
|
10
|
+
@lifestream.branches.first.channel.should_not be_nil
|
11
|
+
@lifestream.branches.first.channel.should be_a(Lifestream::Channel::Rss2)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "raise an exception if the channel is set to a non channel object" do
|
15
|
+
assert_raise Lifestream::Branch::InvalidBranch do
|
16
|
+
Lifestream::Branch.new nil, 'hi', 'hi', 'hi'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|