lifestream 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lifestream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Hunter