Skip to content

Commit

Permalink
Add spaces to blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Dec 11, 2013
1 parent a0a50bd commit 26e20e9
Show file tree
Hide file tree
Showing 25 changed files with 81 additions and 84 deletions.
2 changes: 1 addition & 1 deletion lib/twitter/factory.rb
Expand Up @@ -12,7 +12,7 @@ class << self
# @return [Twitter::Base]
def new(method, klass, attrs = {})
type = attrs.fetch(method.to_sym)
const_name = type.gsub(/\/(.?)/){"::#{Regexp.last_match[1].upcase}"}.gsub(/(?:^|_)(.)/){Regexp.last_match[1].upcase}
const_name = type.gsub(/\/(.?)/) { "::#{Regexp.last_match[1].upcase}" }.gsub(/(?:^|_)(.)/) { Regexp.last_match[1].upcase }
klass.const_get(const_name.to_sym).new(attrs)
end

Expand Down
4 changes: 2 additions & 2 deletions lib/twitter/place.rb
Expand Up @@ -25,7 +25,7 @@ def ==(other)

# @return [String]
def country_code
@attrs[:country_code] || @attrs[:countryCode]
@attrs[:country_code] || @attrs[:countryCode] # rubocop:disable SymbolName
end
memoize :country_code

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

# @return [String]
def place_type
@attrs[:place_type] || @attrs[:placeType] && @attrs[:placeType][:name]
@attrs[:place_type] || @attrs[:placeType] && @attrs[:placeType][:name] # rubocop:disable SymbolName
end
memoize :place_type

Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/rest/client.rb
Expand Up @@ -99,7 +99,7 @@ def get(path, params = {})

# Perform an HTTP POST request
def post(path, params = {})
signature_params = params.values.any?{|value| value.respond_to?(:to_io)} ? {} : params
signature_params = params.values.any? { |value| value.respond_to?(:to_io) } ? {} : params
request(:post, path, params, signature_params)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/search_results.rb
Expand Up @@ -132,7 +132,7 @@ def query_string_to_hash(query_string)
# @example Convert hash's keys to symbols
# symbolize_keys({"foo"=>"bar", "baz"=>"qux"}) #=> {:foo=>"bar", :baz=>"qux"}
def symbolize_keys(hash)
Hash[hash.map{|key, value| [key.to_sym, value]}]
Hash[hash.map { |key, value| [key.to_sym, value] }]
end

end
Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/tweet.rb
Expand Up @@ -23,7 +23,7 @@ class Tweet < Twitter::Identity

# @return [Boolean]
def entities?
!@attrs[:entities].nil? && @attrs[:entities].any?{|_, array| !array.empty?}
!@attrs[:entities].nil? && @attrs[:entities].any? { |_, array| !array.empty? }
end
memoize :entities?

Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/base_spec.rb
Expand Up @@ -20,7 +20,7 @@

describe '#attrs' do
it 'returns a hash of attributes' do
expect(@base.attrs).to eq({:id => 1})
expect(@base.attrs).to eq(:id => 1)
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/twitter/cursor_spec.rb
Expand Up @@ -9,19 +9,19 @@
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'requests the correct resources' do
@client.follower_ids('sferik').each{}
@client.follower_ids('sferik').each {}
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'})).to have_been_made
end
it 'iterates' do
count = 0
@client.follower_ids('sferik').each{count += 1}
@client.follower_ids('sferik').each { count += 1 }
expect(count).to eq(6)
end
context 'with start' do
it 'iterates' do
count = 0
@client.follower_ids('sferik').each(5){count += 1}
@client.follower_ids('sferik').each(5) { count += 1 }
expect(count).to eq(1)
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/twitter/error_spec.rb
Expand Up @@ -36,7 +36,7 @@
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:screen_name => 'sferik'}).to_return(:status => status, :body => body_message)
end
it "raises #{exception.name}" do
expect{@client.user_timeline('sferik')}.to raise_error exception
expect { @client.user_timeline('sferik') }.to raise_error exception
end
end
end
Expand All @@ -49,15 +49,15 @@
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:screen_name => 'sferik'}).to_return(:status => status, :body => body_message)
end
it "raises #{exception.name}" do
expect{@client.user_timeline('sferik')}.to raise_error{|error| expect(error.code).to be_nil}
expect { @client.user_timeline('sferik') }.to raise_error { |error| expect(error.code).to be_nil }
end
context 'when error code is 187' do
before do
body_message = '{"errors":[{"message":"Client Error","code":187}]}'
stub_get('/1.1/statuses/user_timeline.json').with(:query => {:screen_name => 'sferik'}).to_return(:status => status, :body => body_message)
end
it "raises #{exception.name}" do
expect{@client.user_timeline('sferik')}.to raise_error{|error| expect(error.code).to eq(187)}
expect { @client.user_timeline('sferik') }.to raise_error { |error| expect(error.code).to eq(187) }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/geo_factory_spec.rb
Expand Up @@ -12,7 +12,7 @@
expect(geo).to be_a Twitter::Geo::Polygon
end
it 'raises an IndexError when type is not specified' do
expect{Twitter::GeoFactory.new}.to raise_error IndexError
expect { Twitter::GeoFactory.new }.to raise_error IndexError
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/twitter/geo_results_spec.rb
Expand Up @@ -8,13 +8,13 @@
end
it 'iterates' do
count = 0
@geo_results.each{count += 1}
@geo_results.each { count += 1 }
expect(count).to eq(6)
end
context 'with start' do
it 'iterates' do
count = 0
@geo_results.each(5){count += 1}
@geo_results.each(5) { count += 1 }
expect(count).to eq(1)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/identifiable_spec.rb
Expand Up @@ -4,7 +4,7 @@

describe '#initialize' do
it 'raises an IndexError when id is not specified' do
expect{Twitter::Identity.new}.to raise_error IndexError
expect { Twitter::Identity.new }.to raise_error IndexError
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/twitter/media_factory_spec.rb
Expand Up @@ -8,7 +8,7 @@
expect(media).to be_a Twitter::Media::Photo
end
it 'raises an IndexError when type is not specified' do
expect{Twitter::MediaFactory.new}.to raise_error IndexError
expect { Twitter::MediaFactory.new }.to raise_error IndexError
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/twitter/place_spec.rb
Expand Up @@ -99,7 +99,7 @@
expect(place.country_code).to eq('US')
end
it 'returns a country code when set with countryCode' do
place = Twitter::Place.new(:woeid => '247f43d441defc03', :countryCode => 'US')
place = Twitter::Place.new(:woeid => '247f43d441defc03', :countryCode => 'US') # rubocop:disable SymbolName
expect(place.country_code).to eq('US')
end
it 'returns nil when not set' do
Expand All @@ -125,7 +125,7 @@
expect(place.place_type).to eq('city')
end
it 'returns a place type when set with placeType[name]' do
place = Twitter::Place.new(:woeid => '247f43d441defc03', :placeType => {:name => 'Town'})
place = Twitter::Place.new(:woeid => '247f43d441defc03', :placeType => {:name => 'Town'}) # rubocop:disable SymbolName
expect(place.place_type).to eq('Town')
end
it 'returns nil when not set' do
Expand Down
6 changes: 3 additions & 3 deletions spec/twitter/rest/api/favorites_spec.rb
Expand Up @@ -107,7 +107,7 @@
stub_post('/1.1/favorites/create.json').with(:body => {:id => '25938088801'}).to_return(:status => 403, :body => fixture('already_favorited.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'does not raises an error' do
expect{@client.favorite(25_938_088_801)}.not_to raise_error
expect { @client.favorite(25_938_088_801) }.not_to raise_error
end
end
context 'with a URI object passed' do
Expand Down Expand Up @@ -151,15 +151,15 @@
stub_post('/1.1/favorites/create.json').with(:body => {:id => '25938088801'}).to_return(:status => 403, :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'raises a Forbidden error' do
expect{@client.favorite!(25_938_088_801)}.to raise_error Twitter::Error::Forbidden
expect { @client.favorite!(25_938_088_801) }.to raise_error Twitter::Error::Forbidden
end
end
context 'already favorited' do
before do
stub_post('/1.1/favorites/create.json').with(:body => {:id => '25938088801'}).to_return(:status => 403, :body => fixture('already_favorited.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'raises an AlreadyFavorited error' do
expect{@client.favorite!(25_938_088_801)}.to raise_error Twitter::Error::AlreadyFavorited
expect { @client.favorite!(25_938_088_801) }.to raise_error Twitter::Error::AlreadyFavorited
end
end
context 'with a URI object passed' do
Expand Down
28 changes: 14 additions & 14 deletions spec/twitter/rest/api/friends_and_followers_spec.rb
Expand Up @@ -25,7 +25,7 @@
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'requests the correct resource' do
@client.friend_ids('sferik').each{}
@client.friend_ids('sferik').each {}
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'})).to have_been_made
end
Expand All @@ -44,7 +44,7 @@
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '1305102810874389703', :user_id => '7505382'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'requests the correct resource' do
@client.friend_ids(7_505_382).each{}
@client.friend_ids(7_505_382).each {}
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '1305102810874389703', :user_id => '7505382'})).to have_been_made
end
Expand All @@ -70,7 +70,7 @@
stub_get('/1.1/friends/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'requests the correct resource' do
@client.friend_ids.each{}
@client.friend_ids.each {}
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
expect(a_get('/1.1/friends/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'})).to have_been_made
Expand Down Expand Up @@ -98,7 +98,7 @@
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'requests the correct resource' do
@client.follower_ids('sferik').each{}
@client.follower_ids('sferik').each {}
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'})).to have_been_made
end
Expand All @@ -117,7 +117,7 @@
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '1305102810874389703', :user_id => '7505382'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'requests the correct resource' do
@client.follower_ids(7_505_382).each{}
@client.follower_ids(7_505_382).each {}
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '1305102810874389703', :user_id => '7505382'})).to have_been_made
end
Expand All @@ -143,7 +143,7 @@
stub_get('/1.1/followers/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'requests the correct resource' do
@client.follower_ids.each{}
@client.follower_ids.each {}
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
expect(a_get('/1.1/followers/ids.json').with(:query => {:cursor => '1305102810874389703', :screen_name => 'sferik'})).to have_been_made
Expand Down Expand Up @@ -262,7 +262,7 @@
stub_get('/1.1/friendships/incoming.json').with(:query => {:cursor => '1305102810874389703'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'requests the correct resource' do
@client.friendships_incoming.each{}
@client.friendships_incoming.each {}
expect(a_get('/1.1/friendships/incoming.json').with(:query => {:cursor => '1305102810874389703'})).to have_been_made
end
end
Expand All @@ -286,7 +286,7 @@
stub_get('/1.1/friendships/outgoing.json').with(:query => {:cursor => '1305102810874389703'}).to_return(:body => fixture('ids_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'requests the correct resource' do
@client.friendships_outgoing.each{}
@client.friendships_outgoing.each {}
expect(a_get('/1.1/friendships/outgoing.json').with(:query => {:cursor => '1305102810874389703'})).to have_been_made
end
end
Expand Down Expand Up @@ -510,7 +510,7 @@
stub_get('/1.1/followers/list.json').with(:query => {:cursor => '1419103567112105362', :screen_name => 'sferik'}).to_return(:body => fixture('followers_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'requests the correct resource' do
@client.followers('sferik').each{}
@client.followers('sferik').each {}
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '1419103567112105362', :screen_name => 'sferik'})).to have_been_made
end
Expand All @@ -529,7 +529,7 @@
stub_get('/1.1/followers/list.json').with(:query => {:cursor => '1419103567112105362', :user_id => '7505382'}).to_return(:body => fixture('followers_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'requests the correct resource' do
@client.followers(7_505_382).each{}
@client.followers(7_505_382).each {}
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '1419103567112105362', :user_id => '7505382'})).to have_been_made
end
Expand All @@ -555,7 +555,7 @@
stub_get('/1.1/followers/list.json').with(:query => {:cursor => '1419103567112105362', :screen_name => 'sferik'}).to_return(:body => fixture('followers_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'requests the correct resource' do
@client.followers.each{}
@client.followers.each {}
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
expect(a_get('/1.1/followers/list.json').with(:query => {:cursor => '1419103567112105362', :screen_name => 'sferik'})).to have_been_made
Expand Down Expand Up @@ -583,7 +583,7 @@
stub_get('/1.1/friends/list.json').with(:query => {:cursor => '1418947360875712729', :screen_name => 'sferik'}).to_return(:body => fixture('friends_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'requests the correct resource' do
@client.friends('sferik').each{}
@client.friends('sferik').each {}
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '1418947360875712729', :screen_name => 'sferik'})).to have_been_made
end
Expand All @@ -602,7 +602,7 @@
stub_get('/1.1/friends/list.json').with(:query => {:cursor => '1418947360875712729', :user_id => '7505382'}).to_return(:body => fixture('friends_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'requests the correct resource' do
@client.friends(7_505_382).each{}
@client.friends(7_505_382).each {}
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :user_id => '7505382'})).to have_been_made
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '1418947360875712729', :user_id => '7505382'})).to have_been_made
end
Expand All @@ -628,7 +628,7 @@
stub_get('/1.1/friends/list.json').with(:query => {:cursor => '1418947360875712729', :screen_name => 'sferik'}).to_return(:body => fixture('friends_list2.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
end
it 'requests the correct resource' do
@client.friends.each{}
@client.friends.each {}
expect(a_get('/1.1/account/verify_credentials.json')).to have_been_made
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '-1', :screen_name => 'sferik'})).to have_been_made
expect(a_get('/1.1/friends/list.json').with(:query => {:cursor => '1418947360875712729', :screen_name => 'sferik'})).to have_been_made
Expand Down

0 comments on commit 26e20e9

Please sign in to comment.