webco-tuiter 0.0.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/AUTHORS +14 -0
- data/CHANGELOG +3 -0
- data/LICENSE +20 -0
- data/README.markdown +16 -0
- data/Rakefile +110 -0
- data/examples/basic_example.rb +8 -0
- data/lib/tuiter/client.rb +189 -0
- data/lib/tuiter/data/rate_limit.rb +22 -0
- data/lib/tuiter/data/status.rb +44 -0
- data/lib/tuiter/data/user.rb +83 -0
- data/lib/tuiter/version.rb +16 -0
- data/lib/tuiter.rb +11 -0
- metadata +77 -0
data/AUTHORS
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Tuiter was design and developed by Manoel Lemos (manoel@lemos.net), to provide
|
|
2
|
+
basic access to the Twitter API. It was developed for the experimental project
|
|
3
|
+
called Tuitersfera Brasil (http://tuitersfera.com.br), an application to
|
|
4
|
+
monitor the Twitter usage in Brazil.
|
|
5
|
+
|
|
6
|
+
Both projects were latter adopted by WebCo Internet (http://webcointernet.com).
|
|
7
|
+
|
|
8
|
+
The authors and contributors of Tuiter are:
|
|
9
|
+
|
|
10
|
+
* Manoel Lemos (manoel@lemos.net)
|
|
11
|
+
* Luiz Rocha (lsdr@lsdr.net)
|
|
12
|
+
* Luis Cipriani (lfcipriani@talleye.com)
|
|
13
|
+
* Lucas HĂșngaro (lucashungaro@gmail.com)
|
|
14
|
+
|
data/CHANGELOG
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2009, Manoel Lemos
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
|
20
|
+
|
data/README.markdown
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Tuiter #
|
|
2
|
+
|
|
3
|
+
Tuiter was design and developed by Manoel Lemos (manoel@lemos.net), to provide access to the Twitter API. It was developed for the experimental project called [Tuitersfera Brasil](http://tuitersfera.com.br), an application to monitor the Twitter usage in Brazil.
|
|
4
|
+
|
|
5
|
+
# Basic Usage #
|
|
6
|
+
|
|
7
|
+
require 'tuiter'
|
|
8
|
+
client = Tuiter::Client.new(:username => '<twitter_login>', :password => '<twitter_pwd>')
|
|
9
|
+
client.update('Hey Ho, Twitters!')
|
|
10
|
+
|
|
11
|
+
# Current Status #
|
|
12
|
+
|
|
13
|
+
Tuiter is currently being extracted from Tuitersfera and transformed into a full-fledged Ruby library.
|
|
14
|
+
|
|
15
|
+
Stay in tune for updates!
|
|
16
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "rake"
|
|
4
|
+
require "rake/testtask"
|
|
5
|
+
require "rake/rdoctask"
|
|
6
|
+
|
|
7
|
+
require "lib/tuiter/version"
|
|
8
|
+
|
|
9
|
+
desc "Run test suite"
|
|
10
|
+
Rake::TestTask.new do |t|
|
|
11
|
+
t.libs << "test"
|
|
12
|
+
t.pattern = "test/**/*_test.rb"
|
|
13
|
+
t.verbose = false
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc "Report code statistics (KLOCs, etc) from the library"
|
|
17
|
+
task "stats" do
|
|
18
|
+
require "code_statistics"
|
|
19
|
+
::CodeStatistics::TEST_TYPES << "Tests"
|
|
20
|
+
::CodeStatistics.new(["Libraries", "lib"], ["Tests", "test"]).to_s
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
desc "List the names of the test methods"
|
|
24
|
+
task "list" do
|
|
25
|
+
$LOAD_PATH.unshift("test")
|
|
26
|
+
$LOAD_PATH.unshift("lib")
|
|
27
|
+
require "test/unit"
|
|
28
|
+
Test::Unit.run = true
|
|
29
|
+
test_files = Dir.glob(File.join('test', '**/*_test.rb'))
|
|
30
|
+
test_files.each do |file|
|
|
31
|
+
load file
|
|
32
|
+
klass = File.basename(file, '.rb').classify.constantize
|
|
33
|
+
puts klass.name.gsub('Test', '')
|
|
34
|
+
test_methods = klass.instance_methods.grep(/^test/).map {|s| s.gsub(/^test: /, '')}.sort
|
|
35
|
+
test_methods.each {|m| puts " " + m }
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def spec_files
|
|
40
|
+
%w( Rakefile AUTHORS CHANGELOG LICENSE README.markdown ) + Dir["{lib,examples,test}/**/*"]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def spec
|
|
44
|
+
spec = Gem::Specification.new do |s|
|
|
45
|
+
s.name = "tuiter"
|
|
46
|
+
s.version = Tuiter::VERSION::STRING
|
|
47
|
+
s.summary = "Yet another Twitter API wrapper library in Ruby"
|
|
48
|
+
s.authors = ["Manoel Lemos", "WebCo Internet"]
|
|
49
|
+
s.email = "opensource@webcointernet.com"
|
|
50
|
+
s.homepage = "http://github.com/webco/tuiter"
|
|
51
|
+
s.description = "Yet another Twitter API wrapper library in Ruby"
|
|
52
|
+
s.has_rdoc = false
|
|
53
|
+
s.files = spec_files
|
|
54
|
+
|
|
55
|
+
# Dependencies
|
|
56
|
+
s.add_dependency "json", ">= 1.1"
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
desc "Creates the gemspec"
|
|
61
|
+
task "gemify" do
|
|
62
|
+
skip_fields = %w(new_platform original_platform specification_version loaded required_ruby_version rubygems_version platform bindir )
|
|
63
|
+
|
|
64
|
+
result = "# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!\n"
|
|
65
|
+
result << "# RUN : 'rake gem:update_gemspec'\n\n"
|
|
66
|
+
result << "Gem::Specification.new do |s|\n"
|
|
67
|
+
|
|
68
|
+
spec.instance_variables.each do |ivar|
|
|
69
|
+
value = spec.instance_variable_get(ivar)
|
|
70
|
+
name = ivar.split("@").last
|
|
71
|
+
value = Time.now if name == "date"
|
|
72
|
+
|
|
73
|
+
next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
|
|
74
|
+
if name == "dependencies"
|
|
75
|
+
value.each do |d|
|
|
76
|
+
dep, *ver = d.to_s.split(" ")
|
|
77
|
+
result << " s.add_dependency #{dep.inspect}, #{ver.join(" ").inspect.gsub(/[()]/, "").gsub(", runtime", "")}\n"
|
|
78
|
+
end
|
|
79
|
+
else
|
|
80
|
+
case value
|
|
81
|
+
when Array
|
|
82
|
+
value = name != "files" ? value.inspect : value.inspect.split(",").join(",\n")
|
|
83
|
+
when FalseClass
|
|
84
|
+
when TrueClass
|
|
85
|
+
when Fixnum
|
|
86
|
+
when String
|
|
87
|
+
value = value.inspect
|
|
88
|
+
else
|
|
89
|
+
value = value.to_s.inspect
|
|
90
|
+
end
|
|
91
|
+
result << " s.#{name} = #{value}\n"
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
result << "end"
|
|
96
|
+
File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w"){|f| f << result}
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
desc "Build the gem"
|
|
100
|
+
task "build" => "gemify" do
|
|
101
|
+
sh "gem build #{spec.name}.gemspec"
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
desc "Install the gem locally"
|
|
105
|
+
task "install" => "build" do
|
|
106
|
+
sh "gem install #{spec.name}-#{spec.version}.gem && rm -r *.gem *.gemspec"
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
task :default => ["test"]
|
|
110
|
+
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
module Tuiter
|
|
2
|
+
|
|
3
|
+
class Client
|
|
4
|
+
attr_accessor :username, :password
|
|
5
|
+
|
|
6
|
+
def initialize(options = {})
|
|
7
|
+
@pid = Process.pid
|
|
8
|
+
@logger = options[:logger] || Logger.new('tuiter.log')
|
|
9
|
+
@username = options[:username]
|
|
10
|
+
@password = options[:password]
|
|
11
|
+
log("initialize()")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def update(status, in_reply_to_status_id = nil)
|
|
15
|
+
log("update() sending: #{status}")
|
|
16
|
+
url = URI.parse('http://twitter.com/statuses/update.json')
|
|
17
|
+
req = Net::HTTP::Post.new(url.path)
|
|
18
|
+
req.basic_auth @username, @password
|
|
19
|
+
req.set_form_data({'status'=>status, 'in_reply_to_status_id'=>in_reply_to_status_id })
|
|
20
|
+
res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
|
|
21
|
+
case res
|
|
22
|
+
when Net::HTTPSuccess, Net::HTTPRedirection
|
|
23
|
+
log("update() success: OK")
|
|
24
|
+
return res # OK
|
|
25
|
+
else
|
|
26
|
+
log("update() error: #{res.error!}")
|
|
27
|
+
res.error!
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def direct_new(user, text)
|
|
32
|
+
log("direct_new() sending: #{text} to #{user}")
|
|
33
|
+
url = URI.parse('http://twitter.com/direct_messages/new.json')
|
|
34
|
+
req = Net::HTTP::Post.new(url.path)
|
|
35
|
+
req.basic_auth @username, @password
|
|
36
|
+
req.set_form_data({'user'=>user, 'text'=>text })
|
|
37
|
+
res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
|
|
38
|
+
case res
|
|
39
|
+
when Net::HTTPSuccess, Net::HTTPRedirection
|
|
40
|
+
log("direct_new() success: OK")
|
|
41
|
+
return res # OK
|
|
42
|
+
else
|
|
43
|
+
log("direct_new() error: #{res.error!}")
|
|
44
|
+
res.error!
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def friendship_new(user, follow = nil)
|
|
49
|
+
log("friendship_new() following: #{user}")
|
|
50
|
+
url = URI.parse("http://twitter.com/friendships/create/#{user}.json")
|
|
51
|
+
req = Net::HTTP::Post.new(url.path)
|
|
52
|
+
req.basic_auth @username, @password
|
|
53
|
+
req.set_form_data({'follow'=>"true"}) if follow
|
|
54
|
+
res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
|
|
55
|
+
case res
|
|
56
|
+
when Net::HTTPSuccess, Net::HTTPRedirection
|
|
57
|
+
log("friendship_new() success: OK")
|
|
58
|
+
return res # OK
|
|
59
|
+
else
|
|
60
|
+
log("friendship_new() error: #{res.error!}")
|
|
61
|
+
res.error!
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def verify_credentials?
|
|
66
|
+
if res = request("http://twitter.com/account/verify_credentials.json")
|
|
67
|
+
return Tuiter::UserExtended.new(JSON.parse(res))
|
|
68
|
+
else
|
|
69
|
+
return nil
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def get_followers(options = {})
|
|
74
|
+
if options[:id]
|
|
75
|
+
query = "http://twitter.com/statuses/followers/#{options[:id]}.json"
|
|
76
|
+
else
|
|
77
|
+
query = "http://twitter.com/statuses/followers.json"
|
|
78
|
+
end
|
|
79
|
+
if options[:page]
|
|
80
|
+
params = "?page=#{options[:page]}"
|
|
81
|
+
else
|
|
82
|
+
params = ""
|
|
83
|
+
end
|
|
84
|
+
if res = request(query+params)
|
|
85
|
+
data = JSON.parse(res)
|
|
86
|
+
return data.map { |d| User.new(d) }
|
|
87
|
+
else
|
|
88
|
+
return nil
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def get_replies(options = {})
|
|
93
|
+
query = "http://twitter.com/statuses/replies.json"
|
|
94
|
+
if options[:since]
|
|
95
|
+
params = "?since=#{options[:since]}"
|
|
96
|
+
elsif options[:since_id]
|
|
97
|
+
params = "?since_id=#{options[:since_id]}"
|
|
98
|
+
else
|
|
99
|
+
params = ""
|
|
100
|
+
end
|
|
101
|
+
if options[:page]
|
|
102
|
+
if params == ""
|
|
103
|
+
params = "?page=#{options[:page]}"
|
|
104
|
+
else
|
|
105
|
+
params = params + "&" + "page=#{options[:page]}"
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
if res = request(query+params)
|
|
109
|
+
data = JSON.parse(res)
|
|
110
|
+
return data.map { |d| Tuiter::Status.new(d) }
|
|
111
|
+
else
|
|
112
|
+
return nil
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def get_client
|
|
117
|
+
if res = request("http://twitter.com/users/show/#{@username}.json")
|
|
118
|
+
return Tuiter::UserExtended.new(JSON.parse(res))
|
|
119
|
+
else
|
|
120
|
+
return nil
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def get_user(id)
|
|
125
|
+
if res = request("http://twitter.com/users/show/#{id}.json")
|
|
126
|
+
return Tuiter::UserExtended.new(JSON.parse(res))
|
|
127
|
+
else
|
|
128
|
+
return nil
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def get_status(id)
|
|
133
|
+
if res = request("http://twitter.com/statuses/show/#{id}.json")
|
|
134
|
+
return Tuiter::Status.new(JSON.parse(res))
|
|
135
|
+
else
|
|
136
|
+
return nil
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def rate_limit
|
|
141
|
+
if res = request("http://twitter.com/account/rate_limit_status.json")
|
|
142
|
+
return Tuiter::RateLimit.new(JSON.parse(res))
|
|
143
|
+
else
|
|
144
|
+
return nil
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def follows_me?(id)
|
|
149
|
+
if res = request("http://twitter.com/friendships/exists.json?user_a=#{id}&user_b=#{@username}")
|
|
150
|
+
return true if res == "true"
|
|
151
|
+
return false
|
|
152
|
+
else
|
|
153
|
+
return nil
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
private
|
|
158
|
+
|
|
159
|
+
def request(url)
|
|
160
|
+
http = nil
|
|
161
|
+
status = Timeout::timeout(10) do
|
|
162
|
+
log("request() query: #{url}")
|
|
163
|
+
http = open(url, :http_basic_authentication=>[@username, @password])
|
|
164
|
+
log("request() debug: http status is #{http.status.join(' ')}")
|
|
165
|
+
if http.status == ["200", "OK"]
|
|
166
|
+
res = http.read
|
|
167
|
+
return res
|
|
168
|
+
end
|
|
169
|
+
return nil
|
|
170
|
+
end
|
|
171
|
+
rescue Timeout::Error
|
|
172
|
+
log("request() error: timeout error")
|
|
173
|
+
return nil
|
|
174
|
+
rescue OpenURI::HTTPError => e
|
|
175
|
+
log("request() http error: #{e.message} in #{e.backtrace.first.to_s}")
|
|
176
|
+
return nil
|
|
177
|
+
rescue Exception => e
|
|
178
|
+
log("request() error: #{e.message} in #{e.backtrace.first.to_s}")
|
|
179
|
+
return nil
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def log(message)
|
|
183
|
+
@logger.info "[Tuiter:#{@pid}] #{Time.now.to_s} : #{message}"
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
end
|
|
189
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Tuiter
|
|
2
|
+
|
|
3
|
+
class RateLimit
|
|
4
|
+
attr_accessor :reset_time
|
|
5
|
+
attr_accessor :reset_time_in_seconds
|
|
6
|
+
attr_accessor :reset_window
|
|
7
|
+
attr_accessor :remaining_hits
|
|
8
|
+
attr_accessor :hourly_limit
|
|
9
|
+
|
|
10
|
+
def initialize(data = nil)
|
|
11
|
+
unless data.nil?
|
|
12
|
+
@reset_time_in_seconds = Time.at(data["reset_time_in_seconds"].to_i)
|
|
13
|
+
@reset_time = Time.parse(data["reset_time"])
|
|
14
|
+
@reset_window = @reset_time - Time.now
|
|
15
|
+
@remaining_hits = data["remaining_hits"].to_i
|
|
16
|
+
@hourly_limit = data["hourly_limit"].to_i
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module Tuiter
|
|
2
|
+
|
|
3
|
+
class StatusBasic
|
|
4
|
+
attr_accessor :created_at
|
|
5
|
+
attr_accessor :id
|
|
6
|
+
attr_accessor :text
|
|
7
|
+
attr_accessor :source
|
|
8
|
+
attr_accessor :truncated
|
|
9
|
+
attr_accessor :in_reply_to_status_id
|
|
10
|
+
attr_accessor :in_reply_to_user_id
|
|
11
|
+
attr_accessor :favorited
|
|
12
|
+
attr_accessor :in_reply_to_screen_name
|
|
13
|
+
|
|
14
|
+
def initialize(data = nil)
|
|
15
|
+
unless data.nil?
|
|
16
|
+
@created_at = Time.parse(data["created_at"])
|
|
17
|
+
@id = data["id"]
|
|
18
|
+
@text = data["text"]
|
|
19
|
+
@source = data["source"]
|
|
20
|
+
@truncated = data["truncated"]
|
|
21
|
+
@in_reply_to_status_id = data["in_reply_to_status_id"]
|
|
22
|
+
@in_reply_to_user_id = data["in_reply_to_user_id"]
|
|
23
|
+
@favorited = data["favorited"]
|
|
24
|
+
@in_reply_to_screen_name = data["in_reply_to_screen_name"]
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class Status < StatusBasic
|
|
32
|
+
attr_accessor :user
|
|
33
|
+
|
|
34
|
+
def initialize(data=nil)
|
|
35
|
+
unless data.nil?
|
|
36
|
+
super(data)
|
|
37
|
+
@user = Tuiter::UserBasic.new(data["user"])
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
module Tuiter
|
|
2
|
+
|
|
3
|
+
class UserBasic
|
|
4
|
+
attr_accessor :id
|
|
5
|
+
attr_accessor :name
|
|
6
|
+
attr_accessor :screen_name
|
|
7
|
+
attr_accessor :location
|
|
8
|
+
attr_accessor :description
|
|
9
|
+
attr_accessor :profile_image_url
|
|
10
|
+
attr_accessor :url
|
|
11
|
+
attr_accessor :protected
|
|
12
|
+
attr_accessor :followers_count
|
|
13
|
+
|
|
14
|
+
def initialize(data = nil)
|
|
15
|
+
unless data.nil?
|
|
16
|
+
@id = data["id"]
|
|
17
|
+
@name = data["name"]
|
|
18
|
+
@screen_name = data["screen_name"]
|
|
19
|
+
@location = data["location"]
|
|
20
|
+
@description = data["description"]
|
|
21
|
+
@profile_image_url = data["profile_image_url"]
|
|
22
|
+
@url = data["url"]
|
|
23
|
+
@protected = data["protected"]
|
|
24
|
+
@followers_count = data["followers_count"]
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class UserExtended < UserBasic
|
|
31
|
+
attr_accessor :profile_background_color
|
|
32
|
+
attr_accessor :profile_text_color
|
|
33
|
+
attr_accessor :profile_link_color
|
|
34
|
+
attr_accessor :profile_sidebar_fill_color
|
|
35
|
+
attr_accessor :profile_sidebar_border_color
|
|
36
|
+
attr_accessor :friends_count
|
|
37
|
+
attr_accessor :created_at
|
|
38
|
+
attr_accessor :favourites_count
|
|
39
|
+
attr_accessor :utc_offset
|
|
40
|
+
attr_accessor :time_zone
|
|
41
|
+
attr_accessor :profile_background_image_url
|
|
42
|
+
attr_accessor :profile_background_tile
|
|
43
|
+
attr_accessor :following
|
|
44
|
+
attr_accessor :notifications
|
|
45
|
+
attr_accessor :statuses_count
|
|
46
|
+
|
|
47
|
+
def initialize(data = nil)
|
|
48
|
+
unless data.nil?
|
|
49
|
+
super(data)
|
|
50
|
+
@profile_background_color = data["profile_background_color"]
|
|
51
|
+
@profile_text_color = data["profile_text_color"]
|
|
52
|
+
@profile_link_color = data["profile_link_color"]
|
|
53
|
+
@profile_sidebar_fill_color = data["profile_sidebar_fill_color"]
|
|
54
|
+
@profile_sidebar_border_color = data["profile_sidebar_border_color"]
|
|
55
|
+
@friends_count = data["friends_count"].to_i
|
|
56
|
+
@created_at = Time.parse(data["created_at"])
|
|
57
|
+
@favourites_count = data["favourites_count"].to_i
|
|
58
|
+
@utc_offset = data["utc_offset"]
|
|
59
|
+
@time_zone = data["time_zone"]
|
|
60
|
+
@profile_background_image_url = data["profile_background_image_url"]
|
|
61
|
+
@profile_background_tile = data["profile_background_tile"]
|
|
62
|
+
@following = data["following"]
|
|
63
|
+
@notifications = data["notifications"]
|
|
64
|
+
@statuses_count = data["statuses_count"].to_i
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
class User < UserBasic
|
|
71
|
+
attr_accessor :status
|
|
72
|
+
|
|
73
|
+
def initialize(data=nil)
|
|
74
|
+
unless data.nil?
|
|
75
|
+
super(data)
|
|
76
|
+
@status = Tuiter::StatusBasic.new(data["status"])
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
end
|
|
83
|
+
|
data/lib/tuiter.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: webco-tuiter
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Manoel Lemos
|
|
8
|
+
- WebCo Internet
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
|
|
13
|
+
date: 2009-02-25 00:00:00 -08:00
|
|
14
|
+
default_executable:
|
|
15
|
+
dependencies:
|
|
16
|
+
- !ruby/object:Gem::Dependency
|
|
17
|
+
name: json
|
|
18
|
+
type: :runtime
|
|
19
|
+
version_requirement:
|
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
21
|
+
requirements:
|
|
22
|
+
- - ">="
|
|
23
|
+
- !ruby/object:Gem::Version
|
|
24
|
+
version: "1.1"
|
|
25
|
+
version:
|
|
26
|
+
description: Yet another Twitter API wrapper library in Ruby
|
|
27
|
+
email: opensource@webcointernet.com
|
|
28
|
+
executables: []
|
|
29
|
+
|
|
30
|
+
extensions: []
|
|
31
|
+
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
|
|
34
|
+
files:
|
|
35
|
+
- Rakefile
|
|
36
|
+
- AUTHORS
|
|
37
|
+
- CHANGELOG
|
|
38
|
+
- LICENSE
|
|
39
|
+
- README.markdown
|
|
40
|
+
- lib/tuiter
|
|
41
|
+
- lib/tuiter/client.rb
|
|
42
|
+
- lib/tuiter/data
|
|
43
|
+
- lib/tuiter/data/rate_limit.rb
|
|
44
|
+
- lib/tuiter/data/status.rb
|
|
45
|
+
- lib/tuiter/data/user.rb
|
|
46
|
+
- lib/tuiter/version.rb
|
|
47
|
+
- lib/tuiter.log
|
|
48
|
+
- lib/tuiter.rb
|
|
49
|
+
- examples/basic_example.rb
|
|
50
|
+
has_rdoc: false
|
|
51
|
+
homepage: http://github.com/webco/tuiter
|
|
52
|
+
post_install_message:
|
|
53
|
+
rdoc_options: []
|
|
54
|
+
|
|
55
|
+
require_paths:
|
|
56
|
+
- lib
|
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: "0"
|
|
62
|
+
version:
|
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: "0"
|
|
68
|
+
version:
|
|
69
|
+
requirements: []
|
|
70
|
+
|
|
71
|
+
rubyforge_project:
|
|
72
|
+
rubygems_version: 1.2.0
|
|
73
|
+
signing_key:
|
|
74
|
+
specification_version: 2
|
|
75
|
+
summary: Yet another Twitter API wrapper library in Ruby
|
|
76
|
+
test_files: []
|
|
77
|
+
|