-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added help/configuration and help/language methods
- Loading branch information
Showing
7 changed files
with
267 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Twitter | ||
class Client | ||
# Defines methods related twitter's supported features and configuration | ||
module Help | ||
# Returns the current configuration used by Twitter | ||
# | ||
# @format :json, :xml | ||
# @authenticated false | ||
# @rate_limited true | ||
# @return [Hashie::Mash] Twitter's configuration. | ||
# @see http://dev.twitter.com/doc/get/help/configuration | ||
# @example Return the current configuration used by Twitter | ||
# Twitter.configuration | ||
def configuration(options={}) | ||
response = get('help/configuration', options) | ||
format.to_s.downcase == 'xml' ? response['configuration'] : response | ||
end | ||
|
||
# Returns the list of languages supported by Twitter | ||
# | ||
# @format :json, :xml | ||
# @authenticated false | ||
# @rate_limited true | ||
# @return [Array] | ||
# @see http://dev.twitter.com/doc/get/help/languages | ||
# @example Return the list of languages Twitter supports | ||
# Twitter.languages | ||
def languages(options={}) | ||
response = get('help/languages', options) | ||
format.to_s.downcase == 'xml' ? response['languages']['language'] : response | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"photo_sizes":{"medium":{"h":1200,"w":600,"resize":"fit"},"small":{"h":480,"w":340,"resize":"fit"},"large":{"h":2048,"w":1024,"resize":"fit"},"thumb":{"h":150,"w":150,"resize":"crop"}},"non_username_paths":["about","account","accounts","activity","all","announcements","anywhere","api_rules","api_terms","apirules","apps","auth","badges","blog","business","buttons","contacts","devices","direct_messages","download","downloads","edit_announcements","faq","favorites","find_sources","find_users","followers","following","friend_request","friendrequest","friends","goodies","help","home","im_account","inbox","invitations","invite","jobs","list","login","logout","me","mentions","messages","mockview","newtwitter","notifications","nudge","oauth","phoenix_search","positions","privacy","public_timeline","related_tweets","replies","retweeted_of_mine","retweets","retweets_by_others","rules","saved_searches","search","sent","settings","share","signup","signin","similar_to","statistics","terms","tos","translate","trends","tweetbutton","twttr","update_discoverability","users","welcome","who_to_follow","widgets","zendesk_auth","media_signup","t1_qunit_tests","phoenix_qunit_tests"],"photo_size_limit":3145728,"max_media_per_upload":1,"short_url_length":19,"short_url_length_https":20,"characters_reserved_per_media":20} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
<short_url_length>19</short_url_length> | ||
<short_url_length_https>20</short_url_length_https> | ||
<non_username_paths type="array"> | ||
<non_username_path>about</non_username_path> | ||
<non_username_path>account</non_username_path> | ||
<non_username_path>accounts</non_username_path> | ||
<non_username_path>activity</non_username_path> | ||
<non_username_path>all</non_username_path> | ||
<non_username_path>announcements</non_username_path> | ||
<non_username_path>anywhere</non_username_path> | ||
<non_username_path>api_rules</non_username_path> | ||
<non_username_path>api_terms</non_username_path> | ||
<non_username_path>apirules</non_username_path> | ||
<non_username_path>apps</non_username_path> | ||
<non_username_path>auth</non_username_path> | ||
<non_username_path>badges</non_username_path> | ||
<non_username_path>blog</non_username_path> | ||
<non_username_path>business</non_username_path> | ||
<non_username_path>buttons</non_username_path> | ||
<non_username_path>contacts</non_username_path> | ||
<non_username_path>devices</non_username_path> | ||
<non_username_path>direct_messages</non_username_path> | ||
<non_username_path>download</non_username_path> | ||
<non_username_path>downloads</non_username_path> | ||
<non_username_path>edit_announcements</non_username_path> | ||
<non_username_path>faq</non_username_path> | ||
<non_username_path>favorites</non_username_path> | ||
<non_username_path>find_sources</non_username_path> | ||
<non_username_path>find_users</non_username_path> | ||
<non_username_path>followers</non_username_path> | ||
<non_username_path>following</non_username_path> | ||
<non_username_path>friend_request</non_username_path> | ||
<non_username_path>friendrequest</non_username_path> | ||
<non_username_path>friends</non_username_path> | ||
<non_username_path>goodies</non_username_path> | ||
<non_username_path>help</non_username_path> | ||
<non_username_path>home</non_username_path> | ||
<non_username_path>im_account</non_username_path> | ||
<non_username_path>inbox</non_username_path> | ||
<non_username_path>invitations</non_username_path> | ||
<non_username_path>invite</non_username_path> | ||
<non_username_path>jobs</non_username_path> | ||
<non_username_path>list</non_username_path> | ||
<non_username_path>login</non_username_path> | ||
<non_username_path>logout</non_username_path> | ||
<non_username_path>me</non_username_path> | ||
<non_username_path>mentions</non_username_path> | ||
<non_username_path>messages</non_username_path> | ||
<non_username_path>mockview</non_username_path> | ||
<non_username_path>newtwitter</non_username_path> | ||
<non_username_path>notifications</non_username_path> | ||
<non_username_path>nudge</non_username_path> | ||
<non_username_path>oauth</non_username_path> | ||
<non_username_path>phoenix_search</non_username_path> | ||
<non_username_path>positions</non_username_path> | ||
<non_username_path>privacy</non_username_path> | ||
<non_username_path>public_timeline</non_username_path> | ||
<non_username_path>related_tweets</non_username_path> | ||
<non_username_path>replies</non_username_path> | ||
<non_username_path>retweeted_of_mine</non_username_path> | ||
<non_username_path>retweets</non_username_path> | ||
<non_username_path>retweets_by_others</non_username_path> | ||
<non_username_path>rules</non_username_path> | ||
<non_username_path>saved_searches</non_username_path> | ||
<non_username_path>search</non_username_path> | ||
<non_username_path>sent</non_username_path> | ||
<non_username_path>settings</non_username_path> | ||
<non_username_path>share</non_username_path> | ||
<non_username_path>signup</non_username_path> | ||
<non_username_path>signin</non_username_path> | ||
<non_username_path>similar_to</non_username_path> | ||
<non_username_path>statistics</non_username_path> | ||
<non_username_path>terms</non_username_path> | ||
<non_username_path>tos</non_username_path> | ||
<non_username_path>translate</non_username_path> | ||
<non_username_path>trends</non_username_path> | ||
<non_username_path>tweetbutton</non_username_path> | ||
<non_username_path>twttr</non_username_path> | ||
<non_username_path>update_discoverability</non_username_path> | ||
<non_username_path>users</non_username_path> | ||
<non_username_path>welcome</non_username_path> | ||
<non_username_path>who_to_follow</non_username_path> | ||
<non_username_path>widgets</non_username_path> | ||
<non_username_path>zendesk_auth</non_username_path> | ||
<non_username_path>media_signup</non_username_path> | ||
<non_username_path>t1_qunit_tests</non_username_path> | ||
<non_username_path>phoenix_qunit_tests</non_username_path> | ||
</non_username_paths> | ||
<photo_size_limit>3145728</photo_size_limit> | ||
<max_media_per_upload>1</max_media_per_upload> | ||
<characters_reserved_per_media>20</characters_reserved_per_media> | ||
<photo_sizes> | ||
<thumb> | ||
<w>150</w> | ||
<h>150</h> | ||
<resize>crop</resize> | ||
</thumb> | ||
<small> | ||
<w>340</w> | ||
<h>480</h> | ||
<resize>fit</resize> | ||
</small> | ||
<medium> | ||
<w>600</w> | ||
<h>1200</h> | ||
<resize>fit</resize> | ||
</medium> | ||
<large> | ||
<w>1024</w> | ||
<h>2048</h> | ||
<resize>fit</resize> | ||
</large> | ||
</photo_sizes> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"name":"Portuguese","status":"production","code":"pt"},{"name":"Indonesian","status":"production","code":"id"},{"name":"Italian","status":"production","code":"it"},{"name":"Spanish","status":"production","code":"es"},{"name":"Turkish","status":"production","code":"tr"},{"name":"English","status":"production","code":"en"},{"name":"Korean","status":"production","code":"ko"},{"name":"French","status":"production","code":"fr"},{"name":"Dutch","status":"production","code":"nl"},{"name":"Russian","status":"production","code":"ru"},{"name":"German","status":"production","code":"de"},{"name":"Japanese","status":"production","code":"ja"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<languages> | ||
<language> | ||
<name>Portuguese</name> | ||
<code>pt</code> | ||
<status>production</status> | ||
</language> | ||
<language> | ||
<name>Indonesian</name> | ||
<code>id</code> | ||
<status>production</status> | ||
</language> | ||
<language> | ||
<name>Italian</name> | ||
<code>it</code> | ||
<status>production</status> | ||
</language> | ||
<language> | ||
<name>Spanish</name> | ||
<code>es</code> | ||
<status>production</status> | ||
</language> | ||
<language> | ||
<name>Turkish</name> | ||
<code>tr</code> | ||
<status>production</status> | ||
</language> | ||
<language> | ||
<name>English</name> | ||
<code>en</code> | ||
<status>production</status> | ||
</language> | ||
<language> | ||
<name>Korean</name> | ||
<code>ko</code> | ||
<status>production</status> | ||
</language> | ||
<language> | ||
<name>French</name> | ||
<code>fr</code> | ||
<status>production</status> | ||
</language> | ||
<language> | ||
<name>Dutch</name> | ||
<code>nl</code> | ||
<status>production</status> | ||
</language> | ||
<language> | ||
<name>Russian</name> | ||
<code>ru</code> | ||
<status>production</status> | ||
</language> | ||
<language> | ||
<name>German</name> | ||
<code>de</code> | ||
<status>production</status> | ||
</language> | ||
<language> | ||
<name>Japanese</name> | ||
<code>ja</code> | ||
<status>production</status> | ||
</language> | ||
</languages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require 'helper' | ||
|
||
describe Twitter::Client do | ||
%w(json xml).each do |format| | ||
context ".new(:format => '#{format}')" do | ||
before do | ||
@client = Twitter::Client.new(:format => format, :consumer_key => 'CK', :consumer_secret => 'CS', :oauth_token => 'OT', :oauth_token_secret => 'OS') | ||
end | ||
|
||
describe ".configuration" do | ||
|
||
before do | ||
stub_get("help/configuration.#{format}"). | ||
to_return(:body => fixture("configuration.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) | ||
end | ||
|
||
it "should get the correct resource" do | ||
@client.configuration | ||
a_get("help/configuration.#{format}"). | ||
should have_been_made | ||
end | ||
|
||
it "should return Twitter's current configuration" do | ||
configuration = @client.configuration | ||
configuration.characters_reserved_per_media.to_s.should == '20' | ||
end | ||
|
||
end | ||
|
||
describe ".languages" do | ||
|
||
before do | ||
stub_get("help/languages.#{format}"). | ||
to_return(:body => fixture("languages.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"}) | ||
end | ||
|
||
it "should get the correct resource" do | ||
@client.languages | ||
a_get("help/languages.#{format}"). | ||
should have_been_made | ||
end | ||
|
||
it "should return the list of languages supported by Twitter" do | ||
languages = @client.languages | ||
languages.first.name.should == "Portuguese" | ||
end | ||
end | ||
end | ||
end | ||
end |