dschn-twitter 0.3.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +106 -0
- data/License.txt +19 -0
- data/Manifest.txt +71 -0
- data/README.txt +84 -0
- data/Rakefile +4 -0
- data/bin/twitter +15 -0
- data/config/hoe.rb +74 -0
- data/config/requirements.rb +17 -0
- data/examples/blocks.rb +15 -0
- data/examples/direct_messages.rb +28 -0
- data/examples/favorites.rb +20 -0
- data/examples/friends_followers.rb +25 -0
- data/examples/friendships.rb +13 -0
- data/examples/identica_timeline.rb +7 -0
- data/examples/location.rb +8 -0
- data/examples/posting.rb +9 -0
- data/examples/replies.rb +26 -0
- data/examples/search.rb +17 -0
- data/examples/sent_messages.rb +26 -0
- data/examples/timeline.rb +33 -0
- data/examples/twitter.rb +27 -0
- data/examples/verify_credentials.rb +13 -0
- data/lib/twitter.rb +21 -0
- data/lib/twitter/base.rb +260 -0
- data/lib/twitter/cli.rb +328 -0
- data/lib/twitter/cli/config.rb +9 -0
- data/lib/twitter/cli/helpers.rb +97 -0
- data/lib/twitter/cli/migrations/20080722194500_create_accounts.rb +13 -0
- data/lib/twitter/cli/migrations/20080722194508_create_tweets.rb +16 -0
- data/lib/twitter/cli/migrations/20080722214605_add_account_id_to_tweets.rb +9 -0
- data/lib/twitter/cli/migrations/20080722214606_create_configurations.rb +13 -0
- data/lib/twitter/cli/models/account.rb +33 -0
- data/lib/twitter/cli/models/configuration.rb +13 -0
- data/lib/twitter/cli/models/tweet.rb +20 -0
- data/lib/twitter/direct_message.rb +22 -0
- data/lib/twitter/easy_class_maker.rb +43 -0
- data/lib/twitter/rate_limit_status.rb +19 -0
- data/lib/twitter/search.rb +94 -0
- data/lib/twitter/status.rb +22 -0
- data/lib/twitter/user.rb +37 -0
- data/lib/twitter/version.rb +9 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/spec/base_spec.rb +109 -0
- data/spec/cli/helper_spec.rb +35 -0
- data/spec/direct_message_spec.rb +35 -0
- data/spec/fixtures/followers.xml +706 -0
- data/spec/fixtures/friends.xml +609 -0
- data/spec/fixtures/friends_for.xml +584 -0
- data/spec/fixtures/friends_lite.xml +192 -0
- data/spec/fixtures/friends_timeline.xml +66 -0
- data/spec/fixtures/public_timeline.xml +148 -0
- data/spec/fixtures/rate_limit_status.xml +7 -0
- data/spec/fixtures/search_results.json +1 -0
- data/spec/fixtures/status.xml +25 -0
- data/spec/fixtures/user.xml +38 -0
- data/spec/fixtures/user_timeline.xml +465 -0
- data/spec/search_spec.rb +89 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/status_spec.rb +40 -0
- data/spec/user_spec.rb +42 -0
- data/tasks/deployment.rake +50 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/twitter.gemspec +49 -0
- data/website/css/common.css +47 -0
- data/website/images/terminal_output.png +0 -0
- data/website/index.html +156 -0
- metadata +180 -0
data/spec/search_spec.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe Twitter::Search do
|
4
|
+
before do
|
5
|
+
@search = Twitter::Search.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should be able to initialize with a search term" do
|
9
|
+
Twitter::Search.new('httparty').query[:q].should include('httparty')
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be able to specify from" do
|
13
|
+
@search.from('jnunemaker').query[:q].should include('from:jnunemaker')
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should be able to specify to" do
|
17
|
+
@search.to('jnunemaker').query[:q].should include('to:jnunemaker')
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should be able to specify referencing" do
|
21
|
+
@search.referencing('jnunemaker').query[:q].should include('@jnunemaker')
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should alias references to referencing" do
|
25
|
+
@search.references('jnunemaker').query[:q].should include('@jnunemaker')
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should alias ref to referencing" do
|
29
|
+
@search.ref('jnunemaker').query[:q].should include('@jnunemaker')
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should be able to specify containing" do
|
33
|
+
@search.containing('milk').query[:q].should include('milk')
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should alias contains to containing" do
|
37
|
+
@search.contains('milk').query[:q].should include('milk')
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should be able to specify hashed" do
|
41
|
+
@search.hashed('twitter').query[:q].should include('#twitter')
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should be able to specify the language" do
|
45
|
+
@search.lang('en').query[:lang].should == 'en'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should be able to specify the number of results per page" do
|
49
|
+
@search.per_page(25).query[:rpp].should == 25
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should be able to specify only returning results greater than an id" do
|
53
|
+
@search.since(1234).query[:since_id].should == 1234
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should be able to specify geo coordinates" do
|
57
|
+
@search.geocode('40.757929', '-73.985506', '25mi').query[:geocode].should == '40.757929,-73.985506,25mi'
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should be able to clear the filters set" do
|
61
|
+
@search.from('jnunemaker').to('oaknd1')
|
62
|
+
@search.clear.query.should == {:q => []}
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should be able to chain methods together" do
|
66
|
+
@search.from('jnunemaker').to('oaknd1').referencing('orderedlist').containing('milk').hashed('twitter').lang('en').per_page(20).since(1234).geocode('40.757929', '-73.985506', '25mi')
|
67
|
+
@search.query[:q].should == ['from:jnunemaker', 'to:oaknd1', '@orderedlist', 'milk', '#twitter']
|
68
|
+
@search.query[:lang].should == 'en'
|
69
|
+
@search.query[:rpp].should == 20
|
70
|
+
@search.query[:since_id].should == 1234
|
71
|
+
@search.query[:geocode].should == '40.757929,-73.985506,25mi'
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "fetching" do
|
75
|
+
before do
|
76
|
+
@response = open(File.dirname(__FILE__) + '/fixtures/friends_timeline.xml').read
|
77
|
+
@search.class.stub!(:get).and_return(@response)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should return results" do
|
81
|
+
@search.class.should_receive(:get).and_return(@response)
|
82
|
+
@search.from('jnunemaker').fetch().should == @response
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should be able to iterate over results" do
|
87
|
+
@search.respond_to?(:each).should == true
|
88
|
+
end
|
89
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
data/spec/status_spec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe Twitter::Status do
|
4
|
+
it "should create new status from xml doc" do
|
5
|
+
xml = <<EOF
|
6
|
+
<status>
|
7
|
+
<created_at>Sun May 04 21:59:52 +0000 2008</created_at>
|
8
|
+
<id>803435310</id>
|
9
|
+
<text>Writing tests (rspec) for the twitter gem that all can run. Wish I would have done this when I wrote it years back.</text>
|
10
|
+
<source><a href="http://iconfactory.com/software/twitterrific">twitterrific</a></source>
|
11
|
+
<truncated>false</truncated>
|
12
|
+
<in_reply_to_status_id></in_reply_to_status_id>
|
13
|
+
<in_reply_to_user_id></in_reply_to_user_id>
|
14
|
+
<favorited>false</favorited>
|
15
|
+
<user>
|
16
|
+
<id>4243</id>
|
17
|
+
<name>John Nunemaker</name>
|
18
|
+
<screen_name>jnunemaker</screen_name>
|
19
|
+
<location>Indiana</location>
|
20
|
+
<description>Loves his wife, ruby, notre dame football and iu basketball</description>
|
21
|
+
<profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/52619256/ruby_enterprise_shirt_normal.jpg</profile_image_url>
|
22
|
+
<url>http://addictedtonew.com</url>
|
23
|
+
<protected>false</protected>
|
24
|
+
<followers_count>363</followers_count>
|
25
|
+
</user>
|
26
|
+
</status>
|
27
|
+
EOF
|
28
|
+
s = Twitter::Status.new_from_xml(Hpricot.XML(xml))
|
29
|
+
s.id.should == '803435310'
|
30
|
+
s.created_at.should == 'Sun May 04 21:59:52 +0000 2008'
|
31
|
+
s.text.should == 'Writing tests (rspec) for the twitter gem that all can run. Wish I would have done this when I wrote it years back.'
|
32
|
+
s.source.should == '<a href="http://iconfactory.com/software/twitterrific">twitterrific</a>'
|
33
|
+
s.truncated.should == false
|
34
|
+
s.in_reply_to_status_id.should == ''
|
35
|
+
s.in_reply_to_user_id.should == ''
|
36
|
+
s.favorited.should == false
|
37
|
+
s.user.id.should == '4243'
|
38
|
+
s.user.name.should == 'John Nunemaker'
|
39
|
+
end
|
40
|
+
end
|
data/spec/user_spec.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe Twitter::User do
|
4
|
+
it "should create new user from xml doc" do
|
5
|
+
xml = <<EOF
|
6
|
+
<user>
|
7
|
+
<id>18713</id>
|
8
|
+
<name>Alex Payne</name>
|
9
|
+
<screen_name>al3x</screen_name>
|
10
|
+
<location>San Francisco, CA</location>
|
11
|
+
<description>Oh, hi. No, I just work here.</description>
|
12
|
+
<profile_image_url>http://s3.amazonaws.com/twitter_production/profile_images/51961745/al3x_normal.jpg</profile_image_url>
|
13
|
+
<url>http://www.al3x.net</url>
|
14
|
+
<protected>false</protected>
|
15
|
+
<followers_count>2889</followers_count>
|
16
|
+
<status>
|
17
|
+
<created_at>Sun May 04 22:38:39 +0000 2008</created_at>
|
18
|
+
<id>803453211</id>
|
19
|
+
<text>@5dots Yes. Give me about 8 hours. *sigh*</text>
|
20
|
+
|
21
|
+
<source><a href="http://iconfactory.com/software/twitterrific">twitterrific</a></source>
|
22
|
+
<truncated>false</truncated>
|
23
|
+
<in_reply_to_status_id>803450314</in_reply_to_status_id>
|
24
|
+
<in_reply_to_user_id>618923</in_reply_to_user_id>
|
25
|
+
<favorited>false</favorited>
|
26
|
+
|
27
|
+
</status>
|
28
|
+
</user>
|
29
|
+
EOF
|
30
|
+
u = Twitter::User.new_from_xml(Hpricot.XML(xml))
|
31
|
+
u.id.should == '18713'
|
32
|
+
u.name.should =='Alex Payne'
|
33
|
+
u.screen_name.should == 'al3x'
|
34
|
+
u.location.should == 'San Francisco, CA'
|
35
|
+
u.description.should == 'Oh, hi. No, I just work here.'
|
36
|
+
u.profile_image_url.should == 'http://s3.amazonaws.com/twitter_production/profile_images/51961745/al3x_normal.jpg'
|
37
|
+
u.url.should == 'http://www.al3x.net'
|
38
|
+
u.protected.should == false
|
39
|
+
u.followers_count.should == '2889'
|
40
|
+
u.status.text.should == '@5dots Yes. Give me about 8 hours. *sigh*'
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
desc 'Preps the gem for a new release'
|
2
|
+
task :prep_for_release do
|
3
|
+
require 'rio'
|
4
|
+
Rake::Task['manifest:refresh'].invoke
|
5
|
+
gemspec = %x[rake debug_gem]
|
6
|
+
lines = gemspec.split("\n")
|
7
|
+
rio('twitter.gemspec') < lines[1, lines.length-1].join("\n")
|
8
|
+
end
|
9
|
+
|
10
|
+
desc 'Release the website and new gem version'
|
11
|
+
task :deploy => [:check_version, :website, :release] do
|
12
|
+
puts "Remember to create SVN tag:"
|
13
|
+
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
14
|
+
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
|
15
|
+
puts "Suggested comment:"
|
16
|
+
puts "Tagging release #{CHANGES}"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
|
20
|
+
task :local_deploy => [:website_generate, :install_gem]
|
21
|
+
|
22
|
+
task :check_version do
|
23
|
+
unless ENV['VERSION']
|
24
|
+
puts 'Must pass a VERSION=x.y.z release version'
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
unless ENV['VERSION'] == VERS
|
28
|
+
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
29
|
+
exit
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
|
34
|
+
task :install_gem_no_doc => [:clean, :package] do
|
35
|
+
sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
|
36
|
+
end
|
37
|
+
|
38
|
+
namespace :manifest do
|
39
|
+
desc 'Recreate Manifest.txt to include ALL files'
|
40
|
+
task :refresh do
|
41
|
+
`rake check_manifest | patch -p0 > Manifest.txt`
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
namespace :files do
|
46
|
+
task :copy do
|
47
|
+
files = File.read(File.join(File.dirname(__FILE__), '..', 'Manifest.txt')).split("\n")
|
48
|
+
%x[echo '#{files.inspect}' | pbcopy]
|
49
|
+
end
|
50
|
+
end
|
data/tasks/website.rake
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
desc 'Generate website files'
|
2
|
+
task :website_generate => :ruby_env do
|
3
|
+
(Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
|
4
|
+
sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
desc 'Upload website files to rubyforge'
|
9
|
+
task :website_upload do
|
10
|
+
host = "#{rubyforge_username}@rubyforge.org"
|
11
|
+
remote_dir = "/var/www/gforge-projects/#{PATH}/"
|
12
|
+
local_dir = 'website'
|
13
|
+
sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate and upload website files'
|
17
|
+
task :website => [:website_upload, :publish_docs]
|
data/twitter.gemspec
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{twitter}
|
3
|
+
s.version = "0.3.7.1"
|
4
|
+
|
5
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
|
+
s.authors = ["John Nunemaker"]
|
7
|
+
s.date = %q{2008-08-26}
|
8
|
+
s.default_executable = %q{twitter}
|
9
|
+
s.description = %q{a command line interface for twitter, also a library which wraps the twitter api}
|
10
|
+
s.email = %q{nunemaker@gmail.com}
|
11
|
+
s.executables = ["twitter"]
|
12
|
+
s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.txt"]
|
13
|
+
s.files = ["History.txt", "License.txt", "Manifest.txt", "README.txt", "Rakefile", "bin/twitter", "config/hoe.rb", "config/requirements.rb", "examples/blocks.rb", "examples/direct_messages.rb", "examples/favorites.rb", "examples/friends_followers.rb", "examples/friendships.rb", "examples/identica_timeline.rb", "examples/location.rb", "examples/posting.rb", "examples/replies.rb", "examples/search.rb", "examples/sent_messages.rb", "examples/timeline.rb", "examples/twitter.rb", "examples/verify_credentials.rb", "lib/twitter.rb", "lib/twitter/base.rb", "lib/twitter/cli.rb", "lib/twitter/cli/config.rb", "lib/twitter/cli/helpers.rb", "lib/twitter/cli/migrations/20080722194500_create_accounts.rb", "lib/twitter/cli/migrations/20080722194508_create_tweets.rb", "lib/twitter/cli/migrations/20080722214605_add_account_id_to_tweets.rb", "lib/twitter/cli/migrations/20080722214606_create_configurations.rb", "lib/twitter/cli/models/account.rb", "lib/twitter/cli/models/configuration.rb", "lib/twitter/cli/models/tweet.rb", "lib/twitter/direct_message.rb", "lib/twitter/easy_class_maker.rb", "lib/twitter/rate_limit_status.rb", "lib/twitter/search.rb", "lib/twitter/status.rb", "lib/twitter/user.rb", "lib/twitter/version.rb", "script/destroy", "script/generate", "script/txt2html", "setup.rb", "spec/base_spec.rb", "spec/cli/helper_spec.rb", "spec/direct_message_spec.rb", "spec/fixtures/followers.xml", "spec/fixtures/friends.xml", "spec/fixtures/friends_for.xml", "spec/fixtures/friends_lite.xml", "spec/fixtures/friends_timeline.xml", "spec/fixtures/public_timeline.xml", "spec/fixtures/rate_limit_status.xml", "spec/fixtures/search_results.json", "spec/fixtures/status.xml", "spec/fixtures/user.xml", "spec/fixtures/user_timeline.xml", "spec/search_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/status_spec.rb", "spec/user_spec.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/website.rake", "twitter.gemspec", "website/css/common.css", "website/images/terminal_output.png", "website/index.html"]
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.homepage = %q{http://twitter.rubyforge.org}
|
16
|
+
s.rdoc_options = ["--main", "README.txt"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{twitter}
|
19
|
+
s.rubygems_version = %q{1.2.0}
|
20
|
+
s.summary = %q{a command line interface for twitter, also a library which wraps the twitter api}
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
+
s.specification_version = 2
|
25
|
+
|
26
|
+
if current_version >= 3 then
|
27
|
+
s.add_runtime_dependency(%q<hpricot>, [">= 0.6"])
|
28
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.1"])
|
29
|
+
s.add_runtime_dependency(%q<main>, [">= 2.8.2"])
|
30
|
+
s.add_runtime_dependency(%q<highline>, [">= 1.4.0"])
|
31
|
+
s.add_runtime_dependency(%q<activerecord>, [">= 2.1"])
|
32
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0.1.0"])
|
33
|
+
else
|
34
|
+
s.add_dependency(%q<hpricot>, [">= 0.6"])
|
35
|
+
s.add_dependency(%q<activesupport>, [">= 2.1"])
|
36
|
+
s.add_dependency(%q<main>, [">= 2.8.2"])
|
37
|
+
s.add_dependency(%q<highline>, [">= 1.4.0"])
|
38
|
+
s.add_dependency(%q<activerecord>, [">= 2.1"])
|
39
|
+
s.add_dependency(%q<httparty>, [">= 0.1.0"])
|
40
|
+
end
|
41
|
+
else
|
42
|
+
s.add_dependency(%q<hpricot>, [">= 0.6"])
|
43
|
+
s.add_dependency(%q<activesupport>, [">= 2.1"])
|
44
|
+
s.add_dependency(%q<main>, [">= 2.8.2"])
|
45
|
+
s.add_dependency(%q<highline>, [">= 1.4.0"])
|
46
|
+
s.add_dependency(%q<activerecord>, [">= 2.1"])
|
47
|
+
s.add_dependency(%q<httparty>, [">= 0.1.0"])
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
@media screen, projection {
|
2
|
+
/*
|
3
|
+
Copyright (c) 2007, Yahoo! Inc. All rights reserved.
|
4
|
+
Code licensed under the BSD License:
|
5
|
+
http://developer.yahoo.net/yui/license.txt
|
6
|
+
version: 2.2.0
|
7
|
+
*/
|
8
|
+
body {font:13px arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}table {font-size:inherit;font:100%;}select, input, textarea {font:99% arial,helvetica,clean,sans-serif;}pre, code {font:115% monospace;*font-size:100%;}body * {line-height:1.22em;}
|
9
|
+
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}/*ol,ul {list-style:none;}*/caption,th {text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym {border:0;}
|
10
|
+
/* end of yahoo reset and fonts */
|
11
|
+
|
12
|
+
body {color:#333; background:#4b1a1a; line-height:1.3;}
|
13
|
+
p {margin:0 0 20px;}
|
14
|
+
a {color:#4b1a1a;}
|
15
|
+
a:hover {text-decoration:none;}
|
16
|
+
strong {font-weight:bold;}
|
17
|
+
em {font-style:italics;}
|
18
|
+
h1,h2,h3,h4,h5,h6 {font-weight:bold;}
|
19
|
+
h1 {font-size:197%; margin:30px 0; color:#4b1a1a;}
|
20
|
+
h2 {font-size:174%; margin:20px 0; color:#b8111a;}
|
21
|
+
h3 {font-size:152%; margin:10px 0;}
|
22
|
+
h4 {font-size:129%; margin:10px 0;}
|
23
|
+
pre {background:#eee; margin:0 0 20px; padding:20px; border:1px solid #ccc; font-size:100%; overflow:auto;}
|
24
|
+
code {font-size:100%; margin:0; padding:0;}
|
25
|
+
ul, ol {margin:10px 0 10px 25px;}
|
26
|
+
ol li {margin:0 0 10px;}
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
div#wrapper {background:#fff; width:560px; margin:0 auto; padding:20px; border:10px solid #bc8c46; border-width:0 10px;}
|
33
|
+
div#header {position:relative; border-bottom:1px dotted; margin:0 0 10px; padding:0 0 10px;}
|
34
|
+
div#header p {margin:0; padding:0;}
|
35
|
+
div#header h1 {margin:0; padding:0;}
|
36
|
+
ul#nav {position:absolute; top:0; right:0; list-style:none; margin:0; padding:0;}
|
37
|
+
ul#nav li {display:inline; padding:0 0 0 5px;}
|
38
|
+
ul#nav li a {}
|
39
|
+
div#content {}
|
40
|
+
div#footer {margin:40px 0 0; border-top:1px dotted; padding:10px 0 0;}
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
}
|
Binary file
|
data/website/index.html
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
5
|
+
<title>Ruby Twitter Gem by John Nunemaker</title>
|
6
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" />
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
|
10
|
+
<div id="wrapper">
|
11
|
+
<div id="header">
|
12
|
+
<h1>Twitter</h1>
|
13
|
+
<p>command line tweets and an api wrapper</p>
|
14
|
+
|
15
|
+
<ul id="nav">
|
16
|
+
<li><a href="rdoc/">Docs</a></li>
|
17
|
+
<li><a href="http://github.com/jnunemaker/twitter">Github</a></li>
|
18
|
+
<li><a href="http://jnunemaker.lighthouseapp.com/projects/14843-twitter-gem/overview">Lighthouse</a></li>
|
19
|
+
<li><a href="http://rubyforge.org/projects/twitter/">Rubyforge</a></li>
|
20
|
+
</ul>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<div id="content">
|
24
|
+
<h2>Install</h2>
|
25
|
+
<pre><code>$ sudo gem install twitter</code></pre>
|
26
|
+
<p><small>note: the twitter gem now works with hpricot 0.5+</small></p>
|
27
|
+
|
28
|
+
<h2>API Wrapping</h2>
|
29
|
+
<p>I do my best to keep it easy to use. Below are some code samples showing a few of the methods.</p>
|
30
|
+
|
31
|
+
<pre><code>twit = twit
|
32
|
+
twit.update('watching veronica mars')
|
33
|
+
|
34
|
+
puts "Public Timeline", "=" * 50
|
35
|
+
twit.timeline(:public).each do |s|
|
36
|
+
puts s.text, s.user.name
|
37
|
+
puts
|
38
|
+
end
|
39
|
+
|
40
|
+
puts '', "Friends Timeline", "=" * 50
|
41
|
+
twit.timeline(:friends).each do |s|
|
42
|
+
puts s.text, s.user.name
|
43
|
+
puts
|
44
|
+
end
|
45
|
+
|
46
|
+
puts '', "You and Your Friends Timeline", "=" * 50
|
47
|
+
twit.timeline(:user).each do |s|
|
48
|
+
puts s.text, s.user.name
|
49
|
+
puts
|
50
|
+
end
|
51
|
+
|
52
|
+
puts '', "Your Friends", "=" * 50
|
53
|
+
twit.friends.each do |u|
|
54
|
+
puts u.name, u.status.text
|
55
|
+
puts
|
56
|
+
end
|
57
|
+
|
58
|
+
puts '', "jnunemaker's Friends", "=" * 50
|
59
|
+
twit.friends_for('jnunemaker').each do |u|
|
60
|
+
puts u.name
|
61
|
+
puts
|
62
|
+
end
|
63
|
+
|
64
|
+
puts '', "Your Followers", "=" * 50
|
65
|
+
twit.followers.each do |u|
|
66
|
+
puts u.name
|
67
|
+
puts
|
68
|
+
end
|
69
|
+
</code></pre>
|
70
|
+
|
71
|
+
<h2>Search API Examples</h2>
|
72
|
+
|
73
|
+
<pre><code>#searches all tweets for httparty
|
74
|
+
Twitter::Search.new('httparty').each { |r| puts r.inspect }
|
75
|
+
|
76
|
+
# searches all of jnunemaker's tweets for httparty
|
77
|
+
Twitter::Search.new('httparty').from('jnunemaker').each { |r| puts r.inspect }
|
78
|
+
|
79
|
+
# searches all tweets from jnunemaker to oaknd1
|
80
|
+
Twitter::Search.new.from('jnunemaker').to('oaknd1').each { |r| puts r.inspect }
|
81
|
+
|
82
|
+
# you can also use fetch to actually just get the parsed response
|
83
|
+
Twitter::Search.new.from('jnunemaker').to('oaknd1').fetch()
|
84
|
+
</code></pre>
|
85
|
+
|
86
|
+
<h2>Command Line</h2>
|
87
|
+
|
88
|
+
<p><img src="images/terminal_output.png" alt="Terminal Output" style="width:560px;" /></p>
|
89
|
+
|
90
|
+
<p><strong>Note: If you want to use twitter from the command line be sure that sqlite3 and the sqlite3-ruby gem are installed.</strong> I removed the sqlite3-ruby gem as a dependency because you shouldn't need that to just use the API wrapper. Eventually I'll move the CLI interface into another gem.</p>
|
91
|
+
|
92
|
+
<p>The first thing you'll want to do is install the database so your account(s) can be stored.</p>
|
93
|
+
|
94
|
+
<pre><code>$ twitter install</code></pre>
|
95
|
+
|
96
|
+
<p>You can always uninstall twitter like this:</p>
|
97
|
+
|
98
|
+
<pre><code>$ twitter uninstall</code></pre>
|
99
|
+
|
100
|
+
<p>Once the twitter database is installed and migrated, you can add accounts like this:</p>
|
101
|
+
|
102
|
+
<pre><code>$ twitter add
|
103
|
+
Add New Account:
|
104
|
+
Username: jnunemaker
|
105
|
+
Password (won't be displayed):
|
106
|
+
Account added.</code></pre>
|
107
|
+
|
108
|
+
<p>You can also list all the accounts you've added.</p>
|
109
|
+
|
110
|
+
<pre><code>$ twitter list
|
111
|
+
Account List
|
112
|
+
* jnunemaker
|
113
|
+
snitch_test</code></pre>
|
114
|
+
|
115
|
+
<p>The * means denotes the account that will be used when posting, befriending, defriending, following, leaving or viewing a timeline.</p>
|
116
|
+
|
117
|
+
<p>To post using the account marked with the *, simply type the following:</p>
|
118
|
+
|
119
|
+
<pre><code>$ twitter post "releasing my new twitter gem"</code></pre>
|
120
|
+
|
121
|
+
<p>That is about it. You can do pretty much anything that you can do with twitter from the command line interface.</p>
|
122
|
+
|
123
|
+
<pre><code>$ twitter</code></pre>
|
124
|
+
|
125
|
+
<p>Will give you a list of all the commands. You can get the help for each command by running twitter [command] -h. </p>
|
126
|
+
|
127
|
+
|
128
|
+
<h2>Support</h2>
|
129
|
+
<p>Conversations welcome in the <a href="http://groups.google.com/group/ruby-twitter-gem">google group</a> and bugs/features over at <a href="http://jnunemaker.lighthouseapp.com/projects/14843-twitter-gem/overview">lighthouse</a></p>
|
130
|
+
|
131
|
+
<h2>Uses</h2>
|
132
|
+
<ul>
|
133
|
+
<li><a href="http://snitch.rubyforge.org">Snitch</a></li>
|
134
|
+
<li><a href="http://al3x.net/entries/766">Growl + Twitter</a></li>
|
135
|
+
<li><a href="http://snippets.dzone.com/posts/show/3714">Twitter Woot Bot</a> (<a href="http://soylentfoo.jnewland.com/articles/2007/03/22/woot-twitter-bot-now-official">more here</a>)</li>
|
136
|
+
<li><a href="http://soylentfoo.jnewland.com/articles/2007/01/22/tweet-update-twitter-via-quicksilver">Tweet Quicksilver Action</a></li>
|
137
|
+
<li><a href="http://blog.evanweaver.com/articles/2007/02/09/log-system-security-events-to-twitter">logging security events to twitter</a></li>
|
138
|
+
<li><a href="http://shareomatic.com/">Shareomatic</a> is using it for their <a href="http://twitter.com/shareomatic">twitter account</a></li>
|
139
|
+
</ul>
|
140
|
+
|
141
|
+
<p>Using the twitter gem for something, <a href="mailto:nunemaker@gmail.com">let me know</a> and I'll add you above.</p>
|
142
|
+
</div>
|
143
|
+
|
144
|
+
<div id="footer">
|
145
|
+
<p>Created by <a href="http://addictedtonew.com/about/">John Nunemaker</a></p>
|
146
|
+
</div>
|
147
|
+
</div>
|
148
|
+
|
149
|
+
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
|
150
|
+
<script type="text/javascript">_uacct = "UA-85301-9"; urchinTracker();</script>
|
151
|
+
|
152
|
+
<!-- 103bees.com 'bee' code v1.11 - please do not make any changes! -->
|
153
|
+
<script type="text/javascript" src="http://103bees.com/bees/?bee=3672&fid=5643"></script>
|
154
|
+
<!-- 103bees.com 'bee' code -->
|
155
|
+
</body>
|
156
|
+
</html>
|