Permalink
Browse files

Remove Twitter#from_user

  • Loading branch information...
1 parent 4ef37d6 commit d2ae9f1cc1f5224bcdff06cda65fabdf9e7fbcb3 @sferik committed Jul 26, 2013
Showing with 19 additions and 27 deletions.
  1. +16 −1 README.md
  2. +3 −9 lib/twitter/tweet.rb
  3. +0 −17 spec/twitter/tweet_spec.rb
View
@@ -245,6 +245,21 @@ The `Twitter::SearchResults` class has also been redesigned to have an
this class no longer inherits from `Twitter::Base`. As a result, the `#[]`
method has been removed without replacement.
+### Users
+The `Twitter::User` object has been cleaned up. The following methods have been
+removed:
+
+* `#from_user`
+* `#from_user_id`
+* `#from_user_name`
+* `#to_user`
+* `$to_user_id`
+* `to_user_name`
+* `profile_image_url`
+* `profile_image_url_https`
+
+These attributes can be accessed through the `#user` method.
+
## Configuration
Twitter API v1.1 requires you to authenticate via OAuth, so you'll need to
[register your application with Twitter][register]. Once you've registered an
@@ -420,7 +435,7 @@ Twitter.status(27558893223)
```ruby
Twitter.search("to:justinbieber marry me", :count => 3, :result_type => "recent").collect do |tweet|
- "#{tweet.from_user}: #{tweet.text}"
+ "#{tweet.user.screen_name}: #{tweet.text}"
end
```
**Find a Japanese-language Tweet tagged #ruby (excluding retweets)**
View
@@ -4,10 +4,9 @@
module Twitter
class Tweet < Twitter::Identity
include Twitter::Creatable
- attr_reader :favorite_count, :favorited, :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, :lang, :retweet_count, :retweeted, :source, :text,
- :to_user, :to_user_id, :to_user_name, :truncated
+ attr_reader :favorite_count, :favorited, :in_reply_to_screen_name,
+ :in_reply_to_attrs_id, :in_reply_to_status_id, :in_reply_to_user_id,
+ :lang, :retweet_count, :retweeted, :source, :text, :truncated
alias favorites_count favorite_count
alias favourite_count favorite_count
alias favourites_count favorite_count
@@ -23,11 +22,6 @@ def entities?
!@attrs[:entities].nil?
end
- # @return [String]
- def from_user
- @attrs[:from_user] || user && user.screen_name
- end
-
def filter_level
@attrs[:filter_level] || "none"
end
@@ -60,23 +60,6 @@
end
end
- describe "#from_user" do
- it "returns a screen name when from_user is set" do
- tweet = Twitter::Tweet.new(:id => 28669546014, :from_user => "sferik")
- expect(tweet.from_user).to be_a String
- expect(tweet.from_user).to eq "sferik"
- end
- it "returns a screen name when screen_name is set" do
- tweet = Twitter::Tweet.new(:id => 28669546014, :user => {:id => 7505382, :screen_name => "sferik"})
- expect(tweet.from_user).to be_a String
- expect(tweet.from_user).to eq "sferik"
- end
- it "returns nil when not set" do
- tweet = Twitter::Tweet.new(:id => 28669546014)
- expect(tweet.from_user).to be_nil
- end
- end
-
describe "#filter_level" do
it "returns the filter level when filter_level is set" do
tweet = Twitter::Tweet.new(:id => 28669546014, :filter_level => "high")

0 comments on commit d2ae9f1

Please sign in to comment.