twithub 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,5 +14,10 @@ module Twithub
14
14
  @posted_at = posted_at
15
15
  self
16
16
  end
17
+
18
+ def with_url(url)
19
+ @url = url
20
+ self
21
+ end
17
22
  end
18
23
  end
@@ -2,7 +2,7 @@
2
2
  module Twithub
3
3
  class FeedEntry
4
4
  include Comparable
5
- attr_reader :content, :posted_at, :origin, :username
5
+ attr_reader :content, :posted_at, :origin, :username, :url
6
6
 
7
7
  def <=>(other_entry)
8
8
  other_entry.posted_at <=> posted_at
@@ -12,5 +12,13 @@ module Twithub
12
12
  { :content => content, :username => username,
13
13
  :posted_at => posted_at, :origin => origin }.to_json
14
14
  end
15
+
16
+ def from_twitter?
17
+ origin == Twithub::TWITTER
18
+ end
19
+
20
+ def from_github?
21
+ origin == Twithub::GITHUB
22
+ end
15
23
  end
16
24
  end
@@ -2,9 +2,9 @@ module Twithub
2
2
  class Github
3
3
  def self.entries_for(username)
4
4
  return [] unless username
5
- url = "http://github.com/#{username}.atom"
6
- Feedzirra::Feed.fetch_and_parse(url).entries.map do |entry|
7
- GithubEntry.new.with_content(entry.title).with_username(entry.author).with_posted_at(entry.published)
5
+ feed_url = "http://github.com/#{username}.atom"
6
+ Feedzirra::Feed.fetch_and_parse(feed_url).entries.map do |entry|
7
+ GithubEntry.new.with_content(entry.title).with_username(entry.author).with_posted_at(entry.published).with_url(entry.url)
8
8
  end
9
9
  end
10
10
  end
@@ -3,7 +3,8 @@ module Twithub
3
3
  def self.entries_for(username)
4
4
  return [] unless username
5
5
  ::Twitter.user_timeline(username).map do |status|
6
- TwitterEntry.new.with_content(status.text).with_username(status.from_user).with_posted_at(status.created_at)
6
+ url = "http://twitter.com/#{status.from_user}/status/#{status.id}"
7
+ TwitterEntry.new.with_content(status.text).with_username(status.from_user).with_posted_at(status.created_at).with_url(url)
7
8
  end
8
9
  end
9
10
  end
@@ -1,3 +1,3 @@
1
1
  module Twithub
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -24,6 +24,26 @@ describe Twithub::FeedEntry do
24
24
  end
25
25
  end
26
26
 
27
+ describe "entries with mocked out origins" do
28
+ let(:twitter_entry) { Twithub::FeedEntry.new }
29
+ let(:github_entry) { Twithub::FeedEntry.new }
30
+
31
+ before do
32
+ twitter_entry.stub(:origin).and_return(Twithub::TWITTER)
33
+ github_entry.stub(:origin).and_return(Twithub::GITHUB)
34
+ end
35
+
36
+ it "should know if the entry is from twitter" do
37
+ twitter_entry.from_twitter?.should be_true
38
+ github_entry.from_twitter?.should be_false
39
+ end
40
+
41
+ it "should know if the entry is from github" do
42
+ github_entry.from_github?.should be_true
43
+ twitter_entry.from_github?.should be_false
44
+ end
45
+ end
46
+
27
47
  describe "an entry with stubbed out attributes" do
28
48
  let(:entry) { Twithub::FeedEntry.new }
29
49
  let(:time) { Time.now }
@@ -4,12 +4,14 @@ describe Twithub::GithubEntry do
4
4
  let(:time) { Time.now }
5
5
  let(:text) { "just a random content string" }
6
6
  let(:username) { "randomusername" }
7
+ let(:url) { "http://foo" }
7
8
 
8
9
  it "should allow building of a twitter entry" do
9
- entry = Twithub::GithubEntry.new.with_content(text).with_username(username).with_posted_at(time)
10
+ entry = Twithub::GithubEntry.new.with_content(text).with_username(username).with_posted_at(time).with_url(url)
10
11
  entry.content.should == text
11
12
  entry.username.should == username
12
13
  entry.posted_at.should == time
13
14
  entry.origin.should == Twithub::GITHUB
15
+ entry.url.should == url
14
16
  end
15
17
  end
@@ -6,8 +6,9 @@ describe Twithub::Github do
6
6
  let(:recent_time) { Time.now }
7
7
  let(:username) { "pzimbelman" }
8
8
  let(:url) { "http://github.com/#{username}.atom" }
9
- let(:first_github_response) { double("git", :title => "pushed to master!", :author => username, :published => recent_time) }
10
- let(:second_github_response) { double("git", :title => "pushed to branch", :author => username, :published => early_time) }
9
+ let(:first_github_response) { double("git", :title => "pushed to master!", :author => username, :published => recent_time, :url => "http://fooness") }
10
+ let(:second_github_response) { double("git", :title => "pushed to branch", :author => username, :published => early_time, :url => "http://barness") }
11
+
11
12
  let(:responses) { [first_github_response, second_github_response] }
12
13
 
13
14
  before do
@@ -21,11 +22,13 @@ describe Twithub::Github do
21
22
  entries.first.content.should == first_github_response.title
22
23
  entries.first.username.should == username
23
24
  entries.first.posted_at.should == recent_time
25
+ entries.first.url.should == "http://fooness"
24
26
 
25
27
  entries.last.is_a?(Twithub::GithubEntry).should be_true
26
28
  entries.last.content.should == second_github_response.title
27
29
  entries.last.username.should == username
28
30
  entries.last.posted_at.should == early_time
31
+ entries.last.url.should == "http://barness"
29
32
  end
30
33
  end
31
34
 
@@ -4,12 +4,14 @@ describe Twithub::TwitterEntry do
4
4
  let(:time) { Time.now }
5
5
  let(:text) { "just a random content string" }
6
6
  let(:username) { "randomusername" }
7
+ let(:url) { "http://foobar" }
7
8
 
8
9
  it "should allow building of a twitter entry" do
9
- entry = Twithub::TwitterEntry.new.with_content(text).with_username(username).with_posted_at(time)
10
+ entry = Twithub::TwitterEntry.new.with_content(text).with_username(username).with_posted_at(time).with_url(url)
10
11
  entry.content.should == text
11
12
  entry.username.should == username
12
13
  entry.posted_at.should == time
13
14
  entry.origin.should == Twithub::TWITTER
15
+ entry.url.should == url
14
16
  end
15
17
  end
@@ -5,8 +5,8 @@ describe Twithub::Twitter do
5
5
  let(:early_time) { Time.parse("Jan 1 2011 1:00EST") }
6
6
  let(:recent_time) { Time.now }
7
7
  let(:username) { "pzimbelman" }
8
- let(:first_twitter_response) { double("twitter", :text => "the tweet!", :from_user => username, :created_at => recent_time) }
9
- let(:second_twitter_response) { double("twitter", :text => "the early tweet!", :from_user => username, :created_at => early_time) }
8
+ let(:first_twitter_response) { double("twitter", :text => "the tweet!", :from_user => username, :created_at => recent_time, :id => 1234) }
9
+ let(:second_twitter_response) { double("twitter", :text => "the early tweet!", :from_user => username, :created_at => early_time, :id => 123) }
10
10
 
11
11
  before do
12
12
  Twitter.should_receive(:user_timeline).with(username).and_return([first_twitter_response,
@@ -20,11 +20,13 @@ describe Twithub::Twitter do
20
20
  entries.first.content.should == "the tweet!"
21
21
  entries.first.username.should == username
22
22
  entries.first.posted_at.should == recent_time
23
+ entries.first.url.should == "http://twitter.com/pzimbelman/status/1234"
23
24
 
24
25
  entries.last.is_a?(Twithub::TwitterEntry).should be_true
25
26
  entries.last.content.should == "the early tweet!"
26
27
  entries.last.username.should == username
27
28
  entries.last.posted_at.should == early_time
29
+ entries.last.url.should == "http://twitter.com/pzimbelman/status/123"
28
30
  end
29
31
  end
30
32
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twithub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-07-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70108269820160 !ruby/object:Gem::Requirement
16
+ requirement: &70303926056680 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70108269820160
24
+ version_requirements: *70303926056680
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70108269819700 !ruby/object:Gem::Requirement
27
+ requirement: &70303926056200 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70108269819700
35
+ version_requirements: *70303926056200
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: twitter
38
- requirement: &70108269819180 !ruby/object:Gem::Requirement
38
+ requirement: &70303926055680 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '3.3'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70108269819180
46
+ version_requirements: *70303926055680
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: feedzirra
49
- requirement: &70108269818580 !ruby/object:Gem::Requirement
49
+ requirement: &70303926055160 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 0.2.0.rc2
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70108269818580
57
+ version_requirements: *70303926055160
58
58
  description: A gem to aggregate your recent twitter and github activity into a single
59
59
  feed. Can accept multiple logins for either service.
60
60
  email: