twithub 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/Gemfile.lock +59 -0
- data/README.markdown +1 -0
- data/Rakefile +7 -0
- data/lib/twithub/entry_builder_methods.rb +18 -0
- data/lib/twithub/feed_entry.rb +12 -0
- data/lib/twithub/github.rb +11 -0
- data/lib/twithub/github_entry.rb +9 -0
- data/lib/twithub/twitter.rb +10 -0
- data/lib/twithub/twitter_entry.rb +9 -0
- data/lib/twithub.rb +16 -0
- data/spec/twithub/feed_entry_spec.rb +27 -0
- data/spec/twithub/github_entry_spec.rb +15 -0
- data/spec/twithub/github_spec.rb +41 -0
- data/spec/twithub/twitter_entry_spec.rb +15 -0
- data/spec/twithub/twitter_spec.rb +40 -0
- data/spec/twithub_spec.rb +33 -0
- data/twithub.gemspec +20 -0
- metadata +125 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/pauldix/feedzirra.git
|
3
|
+
revision: fcdc0aeaa29efee2160651f12c71f81c82c65c32
|
4
|
+
tag: v0.2.0.rc2
|
5
|
+
specs:
|
6
|
+
feedzirra (0.2.0.rc2)
|
7
|
+
curb (~> 0.8.0)
|
8
|
+
gorillib (~> 0.1.9)
|
9
|
+
loofah (~> 1.2.1)
|
10
|
+
nokogiri (~> 1.5.3)
|
11
|
+
sax-machine (~> 0.2.0.rc1)
|
12
|
+
|
13
|
+
PATH
|
14
|
+
remote: .
|
15
|
+
specs:
|
16
|
+
twithub (0.1.0)
|
17
|
+
feedzirra
|
18
|
+
twitter
|
19
|
+
|
20
|
+
GEM
|
21
|
+
remote: http://rubygems.org/
|
22
|
+
specs:
|
23
|
+
curb (0.8.1)
|
24
|
+
diff-lcs (1.1.3)
|
25
|
+
faraday (0.8.1)
|
26
|
+
multipart-post (~> 1.1)
|
27
|
+
gorillib (0.1.11)
|
28
|
+
json
|
29
|
+
json (1.7.3)
|
30
|
+
loofah (1.2.1)
|
31
|
+
nokogiri (>= 1.4.4)
|
32
|
+
multi_json (1.3.6)
|
33
|
+
multipart-post (1.1.5)
|
34
|
+
nokogiri (1.5.5)
|
35
|
+
rake (0.9.2.2)
|
36
|
+
rspec (2.11.0)
|
37
|
+
rspec-core (~> 2.11.0)
|
38
|
+
rspec-expectations (~> 2.11.0)
|
39
|
+
rspec-mocks (~> 2.11.0)
|
40
|
+
rspec-core (2.11.1)
|
41
|
+
rspec-expectations (2.11.1)
|
42
|
+
diff-lcs (~> 1.1.3)
|
43
|
+
rspec-mocks (2.11.1)
|
44
|
+
sax-machine (0.2.0.rc1)
|
45
|
+
nokogiri (~> 1.5.2)
|
46
|
+
simple_oauth (0.1.8)
|
47
|
+
twitter (3.3.1)
|
48
|
+
faraday (~> 0.8)
|
49
|
+
multi_json (~> 1.3)
|
50
|
+
simple_oauth (~> 0.1.6)
|
51
|
+
|
52
|
+
PLATFORMS
|
53
|
+
ruby
|
54
|
+
|
55
|
+
DEPENDENCIES
|
56
|
+
feedzirra!
|
57
|
+
rake
|
58
|
+
rspec
|
59
|
+
twithub!
|
data/README.markdown
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Just a little gem...
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Twithub
|
2
|
+
module EntryBuilderMethods
|
3
|
+
def with_content(content)
|
4
|
+
@content = content
|
5
|
+
self
|
6
|
+
end
|
7
|
+
|
8
|
+
def with_username(username)
|
9
|
+
@username = username
|
10
|
+
self
|
11
|
+
end
|
12
|
+
|
13
|
+
def with_posted_at(posted_at)
|
14
|
+
@posted_at = posted_at
|
15
|
+
self
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Twithub
|
2
|
+
class Github
|
3
|
+
def self.entries_for(username)
|
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)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Twithub
|
2
|
+
class Twitter
|
3
|
+
def self.entries_for(username)
|
4
|
+
return [] unless username
|
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)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/lib/twithub.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'twitter'
|
2
|
+
require 'feedzirra'
|
3
|
+
require_relative 'twithub/entry_builder_methods'
|
4
|
+
require_relative 'twithub/feed_entry'
|
5
|
+
require_relative 'twithub/twitter'
|
6
|
+
require_relative 'twithub/github'
|
7
|
+
require_relative 'twithub/twitter_entry'
|
8
|
+
require_relative 'twithub/github_entry'
|
9
|
+
|
10
|
+
module Twithub
|
11
|
+
def entries_for(params)
|
12
|
+
entries = Twitter.entries_for(params[:twitter]) + Github.entries_for(params[:github])
|
13
|
+
entries.sort
|
14
|
+
end
|
15
|
+
module_function :entries_for
|
16
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative '../../lib/twithub'
|
2
|
+
describe Twithub::FeedEntry do
|
3
|
+
describe "an empty base entry" do
|
4
|
+
it "should have no attributes filled out by default" do
|
5
|
+
entry = Twithub::FeedEntry.new
|
6
|
+
entry.content.should be_nil
|
7
|
+
entry.username.should be_nil
|
8
|
+
entry.posted_at.should be_nil
|
9
|
+
entry.origin.should be_nil
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "two entries with stubbed out times" do
|
13
|
+
let(:old_entry) { Twithub::FeedEntry.new }
|
14
|
+
let(:new_entry) { Twithub::FeedEntry.new }
|
15
|
+
|
16
|
+
before do
|
17
|
+
old_entry.stub(:posted_at).and_return(Time.parse("Jan 1 2011"))
|
18
|
+
new_entry.stub(:posted_at).and_return(Time.now)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should allow comparing the entries to one another" do
|
22
|
+
(old_entry > new_entry).should be_true
|
23
|
+
(old_entry < new_entry).should be_false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative '../../lib/twithub'
|
2
|
+
|
3
|
+
describe Twithub::GithubEntry do
|
4
|
+
let(:time) { Time.now }
|
5
|
+
let(:text) { "just a random content string" }
|
6
|
+
let(:username) { "randomusername" }
|
7
|
+
|
8
|
+
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.content.should == text
|
11
|
+
entry.username.should == username
|
12
|
+
entry.posted_at.should == time
|
13
|
+
entry.origin.should == Twithub::FeedEntry::GITHUB
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative '../../lib/twithub'
|
2
|
+
|
3
|
+
describe Twithub::Github do
|
4
|
+
describe "when given a valid login" do
|
5
|
+
let(:early_time) { Time.parse("Jan 1 2011 1:00EST") }
|
6
|
+
let(:recent_time) { Time.now }
|
7
|
+
let(:username) { "pzimbelman" }
|
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) }
|
11
|
+
let(:responses) { [first_github_response, second_github_response] }
|
12
|
+
|
13
|
+
before do
|
14
|
+
Feedzirra::Feed.should_receive(:fetch_and_parse).with(url).and_return(responses)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return twitter entries for the values fetched from twitter" do
|
18
|
+
entries = Twithub::Github.entries_for("pzimbelman")
|
19
|
+
entries.size.should == 2
|
20
|
+
entries.first.is_a?(Twithub::GithubEntry).should be_true
|
21
|
+
entries.first.content.should == first_github_response.title
|
22
|
+
entries.first.username.should == username
|
23
|
+
entries.first.posted_at.should == recent_time
|
24
|
+
|
25
|
+
entries.last.is_a?(Twithub::GithubEntry).should be_true
|
26
|
+
entries.last.content.should == second_github_response.title
|
27
|
+
entries.last.username.should == username
|
28
|
+
entries.last.posted_at.should == early_time
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "when given nil" do
|
33
|
+
before do
|
34
|
+
Feedzirra::Feed.should_receive(:fetch_and_parse).never
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should not call feedzirra and return no entries" do
|
38
|
+
Twithub::Github.entries_for(nil).should == []
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative '../../lib/twithub'
|
2
|
+
|
3
|
+
describe Twithub::TwitterEntry do
|
4
|
+
let(:time) { Time.now }
|
5
|
+
let(:text) { "just a random content string" }
|
6
|
+
let(:username) { "randomusername" }
|
7
|
+
|
8
|
+
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.content.should == text
|
11
|
+
entry.username.should == username
|
12
|
+
entry.posted_at.should == time
|
13
|
+
entry.origin.should == Twithub::FeedEntry::TWITTER
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative '../../lib/twithub'
|
2
|
+
|
3
|
+
describe Twithub::Twitter do
|
4
|
+
describe "when given a valid login" do
|
5
|
+
let(:early_time) { Time.parse("Jan 1 2011 1:00EST") }
|
6
|
+
let(:recent_time) { Time.now }
|
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) }
|
10
|
+
|
11
|
+
before do
|
12
|
+
Twitter.should_receive(:user_timeline).with(username).and_return([first_twitter_response,
|
13
|
+
second_twitter_response])
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return twitter entries for the values fetched from twitter" do
|
17
|
+
entries = Twithub::Twitter.entries_for("pzimbelman")
|
18
|
+
entries.size.should == 2
|
19
|
+
entries.first.is_a?(Twithub::TwitterEntry).should be_true
|
20
|
+
entries.first.content.should == "the tweet!"
|
21
|
+
entries.first.username.should == username
|
22
|
+
entries.first.posted_at.should == recent_time
|
23
|
+
|
24
|
+
entries.last.is_a?(Twithub::TwitterEntry).should be_true
|
25
|
+
entries.last.content.should == "the early tweet!"
|
26
|
+
entries.last.username.should == username
|
27
|
+
entries.last.posted_at.should == early_time
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "when given nil" do
|
32
|
+
before do
|
33
|
+
::Twitter.should_receive(:user_timeline).never
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should not call twitter and return no entries" do
|
37
|
+
Twithub::Twitter.entries_for(nil).should == []
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative '../lib/twithub'
|
2
|
+
|
3
|
+
describe Twithub do
|
4
|
+
let(:twitter_name) { "twitteruser" }
|
5
|
+
let(:github_name) {"gituser" }
|
6
|
+
describe "with the twitter response being more recent" do
|
7
|
+
let(:github_entry) {Twithub::GithubEntry.new.with_content("foo").with_username(twitter_name).with_posted_at(Time.parse("Jan 1 2011")) }
|
8
|
+
let(:twitter_entry) {Twithub::TwitterEntry.new.with_content("bar").with_username(github_name).with_posted_at(Time.now) }
|
9
|
+
|
10
|
+
before do
|
11
|
+
Twithub::Github.should_receive(:entries_for).with(github_name).and_return([github_entry])
|
12
|
+
Twithub::Twitter.should_receive(:entries_for).with(twitter_name).and_return([twitter_entry])
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should call to the proper services and return sorted results" do
|
16
|
+
Twithub.entries_for(:twitter => twitter_name, :github => github_name).should == [twitter_entry, github_entry]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "with the github response being more recent" do
|
21
|
+
let(:github_entry) {Twithub::GithubEntry.new.with_content("foo").with_username(twitter_name).with_posted_at(Time.now) }
|
22
|
+
let(:twitter_entry) {Twithub::TwitterEntry.new.with_content("bar").with_username(github_name).with_posted_at(Time.parse("Jan 1 2011")) }
|
23
|
+
|
24
|
+
before do
|
25
|
+
Twithub::Github.should_receive(:entries_for).with(github_name).and_return([github_entry])
|
26
|
+
Twithub::Twitter.should_receive(:entries_for).with(twitter_name).and_return([twitter_entry])
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should call to the proper services and return sorted results" do
|
30
|
+
Twithub.entries_for(:twitter => twitter_name, :github => github_name).should == [github_entry, twitter_entry]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/twithub.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "twithub"
|
3
|
+
s.version = "0.1.0"
|
4
|
+
s.authors = ["Peter Zimbelman"]
|
5
|
+
s.email = ["pzimbelman@gmail.com"]
|
6
|
+
s.homepage = "https://github.com/pzimbelman/twithub"
|
7
|
+
s.summary = %q{A gem to aggregate your recent twitter and github activity}
|
8
|
+
s.description = %q{A gem to aggregate your recent twitter and github activity into a single feed. Can accept multiple logins for either service.}
|
9
|
+
|
10
|
+
s.files = `git ls-files`.split("\n")
|
11
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
12
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
13
|
+
s.require_paths = ["lib"]
|
14
|
+
|
15
|
+
s.add_development_dependency "rspec"
|
16
|
+
s.add_development_dependency "rake"
|
17
|
+
s.add_runtime_dependency "activesupport", "= 3.1.1"
|
18
|
+
s.add_dependency "twitter"
|
19
|
+
s.add_dependency "feedzirra"
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: twithub
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Peter Zimbelman
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70238926483460 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70238926483460
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &70238926483000 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70238926483000
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: activesupport
|
38
|
+
requirement: &70238926482460 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - =
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 3.1.1
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70238926482460
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: twitter
|
49
|
+
requirement: &70238926482000 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70238926482000
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: feedzirra
|
60
|
+
requirement: &70238926481520 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70238926481520
|
69
|
+
description: A gem to aggregate your recent twitter and github activity into a single
|
70
|
+
feed. Can accept multiple logins for either service.
|
71
|
+
email:
|
72
|
+
- pzimbelman@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- Gemfile
|
78
|
+
- Gemfile.lock
|
79
|
+
- README.markdown
|
80
|
+
- Rakefile
|
81
|
+
- lib/twithub.rb
|
82
|
+
- lib/twithub/entry_builder_methods.rb
|
83
|
+
- lib/twithub/feed_entry.rb
|
84
|
+
- lib/twithub/github.rb
|
85
|
+
- lib/twithub/github_entry.rb
|
86
|
+
- lib/twithub/twitter.rb
|
87
|
+
- lib/twithub/twitter_entry.rb
|
88
|
+
- spec/twithub/feed_entry_spec.rb
|
89
|
+
- spec/twithub/github_entry_spec.rb
|
90
|
+
- spec/twithub/github_spec.rb
|
91
|
+
- spec/twithub/twitter_entry_spec.rb
|
92
|
+
- spec/twithub/twitter_spec.rb
|
93
|
+
- spec/twithub_spec.rb
|
94
|
+
- twithub.gemspec
|
95
|
+
homepage: https://github.com/pzimbelman/twithub
|
96
|
+
licenses: []
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ! '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ! '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
requirements: []
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 1.8.17
|
116
|
+
signing_key:
|
117
|
+
specification_version: 3
|
118
|
+
summary: A gem to aggregate your recent twitter and github activity
|
119
|
+
test_files:
|
120
|
+
- spec/twithub/feed_entry_spec.rb
|
121
|
+
- spec/twithub/github_entry_spec.rb
|
122
|
+
- spec/twithub/github_spec.rb
|
123
|
+
- spec/twithub/twitter_entry_spec.rb
|
124
|
+
- spec/twithub/twitter_spec.rb
|
125
|
+
- spec/twithub_spec.rb
|