Skip to content

Commit

Permalink
Merge pull request #8 from jcohenho/rename-followers-count
Browse files Browse the repository at this point in the history
Rename followers_count to follower_count
  • Loading branch information
claudiofullscreen committed Oct 20, 2014
2 parents 62bdebf + 0941298 commit e941bf4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ For more information about changelogs, check
## 0.1.1 - 2014-10-16

* [FEATURE] Add `Instagram::User` supporting `find_by` and `find_by!`.

## 0.2.0 - 2014-10-20

**How to upgrade**

If your code never calls the `followers_count` method on a `Twitter::User`, then you are good to go.
If it does, then replace your calls to `followers_count` with `follower_count` (singular).

* [ENHANCEMENT] Use the same `follower_count` name both for Twitter and Instagram users
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ After [configuring your Twitter app](#configuring-your-twitter-app), you can run
```ruby
user = Net::Twitter::User.find_by screen_name: 'fullscreen'
user.screen_name #=> "Fullscreen"
user.followers_count #=> 48_200
user.follower_count #=> 48_200
```
After [configuring your Instagram app](#configuring-your-instagram-app), you can run commands like:

Expand Down Expand Up @@ -49,10 +49,10 @@ Use [Net::Twitter::User]() to:

```ruby
user = Net::Twitter::User.find_by screen_name: 'fullscreen'
user.followers_count #=> 48_200
user.follower_count #=> 48_200

users = Net::Twitter::User.where screen_name: ['fullscreen', 'brohemian6']
users.map(&:followers_count).sort #=> [12, 48_200]
users.map(&:follower_count).sort #=> [12, 48_200]
```

*The methods above require a configured Twitter app (see below).*
Expand Down
5 changes: 3 additions & 2 deletions lib/net/twitter/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ module Net
module Twitter
module Models
class User
attr_reader :screen_name, :followers_count
attr_reader :screen_name, :follower_count

def initialize(attrs = {})
attrs.each{|k, v| instance_variable_set("@#{k}", v) unless v.nil?}
@follower_count = attrs['followers_count']
end

# Returns the existing Twitter user matching the provided attributes or
Expand Down Expand Up @@ -77,4 +78,4 @@ def self.to_where_params(conditions = {})
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/net/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Net
VERSION = "0.1.1"
VERSION = "0.2.0"
end
8 changes: 4 additions & 4 deletions spec/net/twitter/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

it 'returns an object representing that user' do
expect(user.screen_name).to eq 'Fullscreen'
expect(user.followers_count).to be_an Integer
expect(user.follower_count).to be_an Integer
end
end

Expand All @@ -37,7 +37,7 @@

it 'returns an object representing that user' do
expect(user.screen_name).to eq 'Fullscreen'
expect(user.followers_count).to be_an Integer
expect(user.follower_count).to be_an Integer
end
end

Expand All @@ -59,7 +59,7 @@

it 'returns an array of objects representing those users' do
expect(users.map &:screen_name).to contain_exactly('Fullscreen', 'brohemian6')
expect(users.map &:followers_count).to all(be_an Integer)
expect(users.map &:follower_count).to all(be_an Integer)
end
end

Expand Down Expand Up @@ -95,4 +95,4 @@
end
end
end
end
end

0 comments on commit e941bf4

Please sign in to comment.