Skip to content

Commit

Permalink
added release 0.0.5; cleaned up some code and such, made the docs wor…
Browse files Browse the repository at this point in the history
…k a bit better

git-svn-id: http://svn.addictedtonew.com/public/gems/twitter@32 fe7eae16-9a24-0410-a59d-9e59979e88be
  • Loading branch information
jnunemaker committed Mar 13, 2007
1 parent bd748d6 commit abd6eb3
Show file tree
Hide file tree
Showing 48 changed files with 2,472 additions and 506 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0.0.5 - just a bit of code cleanup
0.0.4 - added :location, :description, :url, :profile_image_url to user class (Alex Payne)
0.0.3 - added a bit more informative message when things go wrong
0.0.2 - added the command line options i forgot to add (friend and follower); improved some docs
Expand Down
7 changes: 4 additions & 3 deletions Manifest.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
README
README.txt
CHANGELOG
Rakefile
setup.rb
bin/twitter
lib/twitter.rb
lib/twitter/base.rb
lib/twitter/command.rb
lib/twitter/easy_class_maker.rb
lib/twitter/status.rb
lib/twitter/user.rb
lib/twitter/version.rb
lib/twitter/version.rb
examples/twitter.rb
bin/twitter
46 changes: 0 additions & 46 deletions README

This file was deleted.

44 changes: 44 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
= addicted to twitter

... a sweet little diddy that helps you twitter your life away

== Command Line Use

$ twitter

That will show the commands and each command will either run or show you the options it needs to run

$ twitter post "releasing my new twitter gem"

That will post a status update to your twitter

== Examples

Twitter::Base.new('your email', 'your password').update('watching veronica mars')

# or you can use post
Twitter::Base.new('your email', 'your password').post('post works too')

puts "Public Timeline", "=" * 50
Twitter::Base.new('your email', 'your password').timeline(:public).each do |s|
puts s.text, s.user.name
puts
end

puts '', "Friends Timeline", "=" * 50
Twitter::Base.new('your email', 'your password').timeline.each do |s|
puts s.text, s.user.name
puts
end

puts '', "Friends", "=" * 50
Twitter::Base.new('your email', 'your password').friends.each do |u|
puts u.name, u.status.text
puts
end

puts '', "Followers", "=" * 50
Twitter::Base.new('your email', 'your password').followers.each do |u|
puts u.name, u.status.text
puts
end
22 changes: 11 additions & 11 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+
VERS = ENV['VERSION'] || (Twitter::VERSION::STRING + (REV ? ".#{REV}" : ""))
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
RDOC_OPTS = ['--quiet', '--title', "twitter documentation",
"--opname", "index.html",
"--line-numbers",
"--main", "README",
"--inline-source"]
"--opname", "index.html",
"--line-numbers",
"--main", "README",
"--inline-source"]

# Generate all the Rake tasks
# Run 'rake -T' to see list of generated tasks (from gem root directory)
hoe = Hoe.new(GEM_NAME, VERS) do |p|
p.author = AUTHOR
p.description = DESCRIPTION
p.email = EMAIL
p.summary = DESCRIPTION
p.url = HOMEPATH
p.author = AUTHOR
p.description = DESCRIPTION
p.email = EMAIL
p.summary = DESCRIPTION
p.url = HOMEPATH
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
p.test_globs = ["test/**/*_test.rb"]
p.clean_globs = CLEAN #An array of file patterns to delete on clean.
p.test_globs = ["test/**/*_test.rb"]
p.clean_globs = CLEAN #An array of file patterns to delete on clean.

# == Optional
#p.changes - A description of the release's latest changes.
Expand Down
39 changes: 0 additions & 39 deletions lib/twitter.rb
Original file line number Diff line number Diff line change
@@ -1,42 +1,3 @@
# = addicted to twitter
#
# ... a sweet little diddy that helps you twitter your life away
#
#
# == Install
#
# $ sudo gem install twitter
#
# == Examples
#
# Twitter::Base.new('your email', 'your password').update('watching veronica mars')
#
# # or you can use post
# Twitter::Base.new('your email', 'your password').post('post works too')
#
# puts "Public Timeline", "=" * 50
# Twitter::Base.new('your email', 'your password').timeline(:public).each do |s|
# puts s.text, s.user.name
# puts
# end
#
# puts '', "Friends Timeline", "=" * 50
# Twitter::Base.new('your email', 'your password').timeline.each do |s|
# puts s.text, s.user.name
# puts
# end
#
# puts '', "Friends", "=" * 50
# Twitter::Base.new('your email', 'your password').friends.each do |u|
# puts u.name, u.status.text
# puts
# end
#
# puts '', "Followers", "=" * 50
# Twitter::Base.new('your email', 'your password').followers.each do |u|
# puts u.name, u.status.text
# puts
# end
%w(uri net/http yaml rubygems hpricot).each { |f| require f }

require 'twitter/version'
Expand Down
25 changes: 7 additions & 18 deletions lib/twitter/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,38 +52,27 @@ def post(status)
req.basic_auth(@config[:email], @config[:password])
req.set_form_data({'status' => status})

res = Net::HTTP.new(url.host, url.port).start { |http| http.request(req) }
Status.new_from_xml(Hpricot.parse(res.body).at('status'))
result = Net::HTTP.new(url.host, url.port).start { |http| http.request(req) }
Status.new_from_xml(Hpricot.XML(result.body).at('status'))
end
alias :update :post

private
# Converts xml to an array of statuses
def statuses(res)
statuses = []
doc = Hpricot.parse(res)
(doc/:status).each do |status|
statuses << Status.new_from_xml(status)
end
statuses
def statuses(doc)
(doc/:status).inject([]) { |statuses, status| statuses << Status.new_from_xml(status); statuses }
end

# Converts xml to an array of users
def users(res)
users = []
doc = Hpricot.parse(res)
(doc/:user).each do |user|
users << User.new_from_xml(user)
end
users
def users(doc)
(doc/:user).inject([]) { |users, user| users << User.new_from_xml(user); users }
end

# Calls whatever api method requested
#
# ie: call(:public_timeline, :auth => false)
def call(method, arg_options={})
options = { :auth => true }.merge(arg_options)

path = "/statuses/#{method.to_s}.xml"
headers = { "User-Agent" => @config[:email] }

Expand All @@ -95,7 +84,7 @@ def call(method, arg_options={})
end

raise BadResponse unless response.message == 'OK'
response.body
Hpricot.XML(response.body)
rescue
raise CantConnect
end
Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Twitter #:nodoc:
module VERSION #:nodoc:
MAJOR = 0
MINOR = 0
TINY = 4
TINY = 5

STRING = [MAJOR, MINOR, TINY].join('.')
end
Expand Down
1 change: 1 addition & 0 deletions pkg/twitter-0.0.1/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0.0.5 - just a bit of code cleanup
0.0.4 - added :location, :description, :url, :profile_image_url to user class (Alex Payne)
0.0.3 - added a bit more informative message when things go wrong
0.0.2 - added the command line options i forgot to add (friend and follower); improved some docs
Expand Down
56 changes: 28 additions & 28 deletions pkg/twitter-0.0.1/README
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@ That will post a status update to your twitter

== Examples

Twitter::Base.new('your email', 'your password').update('watching veronica mars')

# or you can use post
Twitter::Base.new('your email', 'your password').post('post works too')
puts "Public Timeline", "=" * 50
Twitter::Base.new('your email', 'your password').timeline(:public).each do |s|
puts s.text, s.user.name
puts
end

puts '', "Friends Timeline", "=" * 50
Twitter::Base.new('your email', 'your password').timeline.each do |s|
puts s.text, s.user.name
puts
end

puts '', "Friends", "=" * 50
Twitter::Base.new('your email', 'your password').friends.each do |u|
puts u.name, u.status.text
puts
end

puts '', "Followers", "=" * 50
Twitter::Base.new('your email', 'your password').followers.each do |u|
puts u.name, u.status.text
puts
end
Twitter::Base.new('your email', 'your password').update('watching veronica mars')

# or you can use post
Twitter::Base.new('your email', 'your password').post('post works too')

puts "Public Timeline", "=" * 50
Twitter::Base.new('your email', 'your password').timeline(:public).each do |s|
puts s.text, s.user.name
puts
end

puts '', "Friends Timeline", "=" * 50
Twitter::Base.new('your email', 'your password').timeline.each do |s|
puts s.text, s.user.name
puts
end

puts '', "Friends", "=" * 50
Twitter::Base.new('your email', 'your password').friends.each do |u|
puts u.name, u.status.text
puts
end

puts '', "Followers", "=" * 50
Twitter::Base.new('your email', 'your password').followers.each do |u|
puts u.name, u.status.text
puts
end
22 changes: 11 additions & 11 deletions pkg/twitter-0.0.1/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+
VERS = ENV['VERSION'] || (Twitter::VERSION::STRING + (REV ? ".#{REV}" : ""))
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
RDOC_OPTS = ['--quiet', '--title', "twitter documentation",
"--opname", "index.html",
"--line-numbers",
"--main", "README",
"--inline-source"]
"--opname", "index.html",
"--line-numbers",
"--main", "README",
"--inline-source"]

# Generate all the Rake tasks
# Run 'rake -T' to see list of generated tasks (from gem root directory)
hoe = Hoe.new(GEM_NAME, VERS) do |p|
p.author = AUTHOR
p.description = DESCRIPTION
p.email = EMAIL
p.summary = DESCRIPTION
p.url = HOMEPATH
p.author = AUTHOR
p.description = DESCRIPTION
p.email = EMAIL
p.summary = DESCRIPTION
p.url = HOMEPATH
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
p.test_globs = ["test/**/*_test.rb"]
p.clean_globs = CLEAN #An array of file patterns to delete on clean.
p.test_globs = ["test/**/*_test.rb"]
p.clean_globs = CLEAN #An array of file patterns to delete on clean.

# == Optional
#p.changes - A description of the release's latest changes.
Expand Down
Loading

0 comments on commit abd6eb3

Please sign in to comment.