Skip to content

Commit

Permalink
Rename Twitter::Status to Twitter::Tweet
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Aug 14, 2012
1 parent 1f9c9c4 commit 6d25887
Show file tree
Hide file tree
Showing 23 changed files with 622 additions and 621 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Here are some fun facts about the 3.0 release:

* The entire library is implemented in just 2,000 lines of code
* With over 5,000 lines of specs, the spec-to-code ratio is over 2.5:1
* The spec suite contains 675 examples and runs in under 2 seconds on a MacBook
* The spec suite contains 674 examples and runs in under 2 seconds on a MacBook
* This project has 100% C0 code coverage (the tests execute every line of
source code at least once)
* At the time of release, this library is comprehensive: you can request all
Expand Down
12 changes: 6 additions & 6 deletions lib/twitter/action/favorite.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
require 'twitter/action/status'
require 'twitter/action/tweet'

module Twitter
module Action
class Favorite < Twitter::Action::Status
class Favorite < Twitter::Action::Tweet
attr_reader :target_objects

# A collection containing the favorited status
# A collection containing the favorited tweet
#
# @return [Array<Twitter::Status>]
# @return [Array<Twitter::Tweet>]
def targets
@targets = Array(@attrs[:targets]).map do |status|
Twitter::Status.fetch_or_new(status)
@targets = Array(@attrs[:targets]).map do |tweet|
Twitter::Tweet.fetch_or_new(tweet)
end
end

Expand Down
10 changes: 5 additions & 5 deletions lib/twitter/action/mention.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'twitter/base'
require 'twitter/creatable'
require 'twitter/status'
require 'twitter/tweet'
require 'twitter/user'

module Twitter
Expand All @@ -25,12 +25,12 @@ def source
@source = sources.first
end

# A collection of statuses that mention a user
# A collection of tweets that mention a user
#
# @return [Array<Twitter::Status>]
# @return [Array<Twitter::Tweet>]
def target_objects
@target_objects = Array(@attrs[:target_objects]).map do |status|
Twitter::Status.fetch_or_new(status)
@target_objects = Array(@attrs[:target_objects]).map do |tweet|
Twitter::Tweet.fetch_or_new(tweet)
end
end

Expand Down
20 changes: 10 additions & 10 deletions lib/twitter/action/reply.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
require 'twitter/action/status'
require 'twitter/action/tweet'

module Twitter
module Action
class Reply < Twitter::Action::Status
class Reply < Twitter::Action::Tweet

# A collection of statuses that reply to a user
# A collection of tweets that reply to a user
#
# @return [Array<Twitter::Status>]
# @return [Array<Twitter::Tweet>]
def target_objects
@target_objects = Array(@attrs[:target_objects]).map do |status|
Twitter::Status.fetch_or_new(status)
@target_objects = Array(@attrs[:target_objects]).map do |tweet|
Twitter::Tweet.fetch_or_new(tweet)
end
end

# A collection that contains the replied-to status
# A collection that contains the replied-to tweets
#
# @return [Array<Twitter::Status>]
# @return [Array<Twitter::Tweet>]
def targets
@targets = Array(@attrs[:targets]).map do |status|
Twitter::Status.fetch_or_new(status)
@targets = Array(@attrs[:targets]).map do |tweet|
Twitter::Tweet.fetch_or_new(tweet)
end
end

Expand Down
10 changes: 5 additions & 5 deletions lib/twitter/action/retweet.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require 'twitter/action/status'
require 'twitter/action/tweet'

module Twitter
module Action
class Retweet < Twitter::Action::Status
class Retweet < Twitter::Action::Tweet

# A collection of retweets
#
# @return [Array<Twitter::Status>]
# @return [Array<Twitter::Tweet>]
def target_objects
@target_objects = Array(@attrs[:target_objects]).map do |status|
Twitter::Status.fetch_or_new(status)
@target_objects = Array(@attrs[:target_objects]).map do |tweet|
Twitter::Tweet.fetch_or_new(tweet)
end
end

Expand Down
5 changes: 3 additions & 2 deletions lib/twitter/action/status.rb → lib/twitter/action/tweet.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require 'twitter/base'
require 'twitter/creatable'
require 'twitter/status'
require 'twitter/tweet'
require 'twitter/user'

module Twitter
module Action
class Status < Twitter::Base
class Tweet < Twitter::Base
include Twitter::Creatable
attr_reader :max_position, :min_position

Expand All @@ -17,5 +17,6 @@ def sources
end

end
Status = Tweet
end
end
282 changes: 141 additions & 141 deletions lib/twitter/api.rb

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions lib/twitter/search_results.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require 'twitter/base'
require 'twitter/status'
require 'twitter/tweet'

module Twitter
class SearchResults < Twitter::Base
attr_reader :completed_in, :max_id, :next_page, :page, :query,
:refresh_url, :results_per_page, :since_id

# @return [Array<Twitter::Status>]
# @return [Array<Twitter::Tweet>]
def results
@results ||= Array(@attrs[:results]).map do |status|
Twitter::Status.fetch_or_new(status)
@results ||= Array(@attrs[:results]).map do |tweet|
Twitter::Tweet.fetch_or_new(tweet)
end
end
alias collection results
Expand Down
10 changes: 7 additions & 3 deletions lib/twitter/status.rb → lib/twitter/tweet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
require 'twitter/user'

module Twitter
class Status < Twitter::Identity
class Tweet < Twitter::Identity
include Twitter::Creatable
attr_reader :favorited, :favoriters, :from_user_id, :from_user_name,
:in_reply_to_screen_name, :in_reply_to_attrs_id, :in_reply_to_status_id,
:in_reply_to_user_id, :iso_language_code, :profile_image_url,
:profile_image_url_https, :repliers, :retweeted, :retweeters, :source,
:text, :to_user, :to_user_id, :to_user_name, :truncated
alias in_reply_to_tweet_id in_reply_to_status_id
alias favorited? favorited
alias favourited favorited
alias favourited? favorited
Expand Down Expand Up @@ -84,12 +85,13 @@ def repliers_count
end
alias reply_count repliers_count

# If this status is itself a retweet, the original tweet is available here.
# If this Tweet is a retweet, the original Tweet is available here.
#
# @return [Twitter::Status]
# @return [Twitter::Tweet]
def retweeted_status
@retweeted_status ||= self.class.fetch_or_new(@attrs[:retweeted_status])
end
alias retweeted_tweet retweeted_status

# @return [String]
def retweeters_count
Expand Down Expand Up @@ -131,4 +133,6 @@ def entities(klass, method)
end

end

Status = Tweet
end
6 changes: 3 additions & 3 deletions lib/twitter/user.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'twitter/basic_user'
require 'twitter/core_ext/hash'
require 'twitter/creatable'
require 'twitter/status'
require 'twitter/tweet'

module Twitter
class User < Twitter::BasicUser
Expand Down Expand Up @@ -69,9 +69,9 @@ def profile_image_url_https(size=:normal)
resize_profile_image_url(@attrs[:profile_image_url_https], size)
end

# @return [Twitter::Status]
# @return [Twitter::Tweet]
def status
@status ||= Twitter::Status.fetch_or_new(@attrs.dup[:status].merge(:user => @attrs.except(:status))) unless @attrs[:status].nil?
@status ||= Twitter::Tweet.fetch_or_new(@attrs.dup[:status].merge(:user => @attrs.except(:status))) unless @attrs[:status].nil?
end

private
Expand Down
6 changes: 3 additions & 3 deletions spec/twitter/action/favorite_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Twitter::Action::Favorite do

describe "#sources" do
it "returns a collection of users who favorited a status" do
it "returns a collection of users who favorited a Tweet" do
sources = Twitter::Action::Favorite.new(:sources => [{:id => 7505382}]).sources
sources.should be_an Array
sources.first.should be_a Twitter::User
Expand All @@ -15,10 +15,10 @@
end

describe "#targets" do
it "returns a collection containing the favorited status" do
it "returns a collection containing the favorited Tweet" do
targets = Twitter::Action::Favorite.new(:targets => [{:id => 25938088801}]).targets
targets.should be_an Array
targets.first.should be_a Twitter::Status
targets.first.should be_a Twitter::Tweet
end
it "is empty when not set" do
targets = Twitter::Action::Favorite.new.targets
Expand Down
4 changes: 2 additions & 2 deletions spec/twitter/action/mention_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
end

describe "#target_objects" do
it "returns a collection of statuses that mention a user" do
it "returns a collection of Tweets that mention a user" do
targets = Twitter::Action::Mention.new(:target_objects => [{:id => 25938088801}]).target_objects
targets.should be_an Array
targets.first.should be_a Twitter::Status
targets.first.should be_a Twitter::Tweet
end
it "is empty when not set" do
targets = Twitter::Action::Mention.new.target_objects
Expand Down
6 changes: 3 additions & 3 deletions spec/twitter/action/reply_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
end

describe "#target_objects" do
it "returns a collection of statuses that reply to a user" do
it "returns a collection of Tweets that reply to a user" do
targets = Twitter::Action::Reply.new(:target_objects => [{:id => 25938088801}]).target_objects
targets.should be_an Array
targets.first.should be_a Twitter::Status
targets.first.should be_a Twitter::Tweet
end
it "is empty when not set" do
targets = Twitter::Action::Reply.new.target_objects
Expand All @@ -30,7 +30,7 @@
it "returns a collection that contains the replied-to status" do
targets = Twitter::Action::Reply.new(:targets => [{:id => 25938088801}]).targets
targets.should be_an Array
targets.first.should be_a Twitter::Status
targets.first.should be_a Twitter::Tweet
end
it "is empty when not set" do
targets = Twitter::Action::Reply.new.targets
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/action/retweet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
it "returns a collection of retweets" do
targets = Twitter::Action::Retweet.new(:target_objects => [{:id => 25938088801}]).target_objects
targets.should be_an Array
targets.first.should be_a Twitter::Status
targets.first.should be_a Twitter::Tweet
end
it "is empty when not set" do
targets = Twitter::Action::Retweet.new.target_objects
Expand Down
4 changes: 0 additions & 4 deletions spec/twitter/action_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
action = Twitter::ActionFactory.fetch_or_new(:action => 'retweet')
action.should be_a Twitter::Action::Retweet
end
it "generates a Status" do
action = Twitter::ActionFactory.fetch_or_new(:action => 'status')
action.should be_a Twitter::Action::Status
end
it "raises an ArgumentError when action is not specified" do
lambda do
Twitter::ActionFactory.fetch_or_new
Expand Down
8 changes: 4 additions & 4 deletions spec/twitter/api/lists_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@
should have_been_made
end
it "returns the timeline for members of the specified list" do
statuses = @client.list_timeline("sferik", "presidents")
statuses.should be_an Array
statuses.first.should be_a Twitter::Status
statuses.first.text.should eq "Ruby is the best programming language for hiding the ugly bits."
tweets = @client.list_timeline("sferik", "presidents")
tweets.should be_an Array
tweets.first.should be_a Twitter::Tweet
tweets.first.text.should eq "Ruby is the best programming language for hiding the ugly bits."
end
end
context "without a screen name passed" do
Expand Down
8 changes: 4 additions & 4 deletions spec/twitter/api/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
with(:query => {:q => "twitter"}).
should have_been_made
end
it "returns recent statuses related to a query with images and videos embedded" do
it "returns recent Tweets related to a query with images and videos embedded" do
search = @client.search('twitter')
search.should be_a Twitter::SearchResults
search.results.should be_an Array
search.results.first.should be_a Twitter::Status
search.results.first.should be_a Twitter::Tweet
search.results.first.text.should eq "@KaiserKuo from not too far away your new twitter icon looks like Vader."
end
it "returns the max_id value for a search result" do
Expand Down Expand Up @@ -57,10 +57,10 @@
with(:query => {:q => "twitter"}).
should have_been_made
end
it "returns recent statuses related to a query with images and videos embedded" do
it "returns recent Tweets related to a query with images and videos embedded" do
search = @client.phoenix_search('twitter')
search.should be_an Array
search.first.should be_a Twitter::Status
search.first.should be_a Twitter::Tweet
search.first.text.should eq "looking at twitter trends just makes me realize how little i really understand about mankind."
end
end
Expand Down
Loading

0 comments on commit 6d25887

Please sign in to comment.