rubytter 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +44 -38
- data/lib/rubytter/connection.rb +9 -9
- data/lib/rubytter.rb +20 -6
- data/spec/rubytter_spec.rb +20 -0
- metadata +36 -20
data/Rakefile
CHANGED
@@ -1,45 +1,51 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'rubytter'
|
4
|
-
require 'spec/rake/spectask'
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
5
3
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "rubytter"
|
8
|
+
gem.summary = %Q{Simple twitter client.}
|
9
|
+
gem.description = %Q{Rubytter is a simple twitter client.}
|
10
|
+
gem.email = "jugyo.org@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/jugyo/rubytter"
|
12
|
+
gem.authors = ["jugyo"]
|
13
|
+
gem.files = FileList['lib/**/*.rb', 'README.rdoc', 'History.txt', 'Rakefile', 'spec/**/*.rb', 'spec/**/*.json', 'examples/**/*.rb']
|
14
|
+
gem.add_dependency("json_pure", ">= 1.1.3")
|
15
|
+
gem.add_development_dependency "rspec"
|
16
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
+
end
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
10
20
|
end
|
11
21
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
s.name = 'rubytter'
|
18
|
-
s.version = '#{Rubytter::VERSION}'
|
19
|
-
s.summary = "Simple twitter client."
|
20
|
-
s.description = "Rubytter is a simple twitter client."
|
21
|
-
s.files = %w( #{Dir['lib/**/*.rb'].join(' ')}
|
22
|
-
#{Dir['spec/**/*.rb'].join(' ')}
|
23
|
-
#{Dir['spec/**/*.json'].join(' ')}
|
24
|
-
#{Dir['examples/**/*.rb'].join(' ')}
|
25
|
-
README.rdoc
|
26
|
-
History.txt
|
27
|
-
Rakefile )
|
28
|
-
s.add_dependency("json_pure", ">= 1.1.3")
|
29
|
-
s.author = 'jugyo'
|
30
|
-
s.email = 'jugyo.org@gmail.com'
|
31
|
-
s.homepage = 'http://github.com/jugyo/rubytter'
|
32
|
-
s.rubyforge_project = 'rubytter'
|
33
|
-
s.has_rdoc = true
|
34
|
-
s.rdoc_options = ["--main", "README.rdoc", "--exclude", "spec"]
|
35
|
-
s.extra_rdoc_files = ["README.rdoc", "History.txt"]
|
22
|
+
require 'spec/rake/spectask'
|
23
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
+
spec.libs << 'lib' << 'spec'
|
25
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
|
+
spec.spec_opts = ['-c']
|
36
27
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
28
|
+
|
29
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
30
|
+
spec.libs << 'lib' << 'spec'
|
31
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
32
|
+
spec.rcov = true
|
40
33
|
end
|
41
34
|
|
42
|
-
|
43
|
-
|
44
|
-
|
35
|
+
task :spec => :check_dependencies
|
36
|
+
|
37
|
+
task :default => :spec
|
38
|
+
|
39
|
+
require 'rake/rdoctask'
|
40
|
+
Rake::RDocTask.new do |rdoc|
|
41
|
+
if File.exist?('VERSION')
|
42
|
+
version = File.read('VERSION')
|
43
|
+
else
|
44
|
+
version = ""
|
45
|
+
end
|
46
|
+
|
47
|
+
rdoc.rdoc_dir = 'rdoc'
|
48
|
+
rdoc.title = "rubytter #{version}"
|
49
|
+
rdoc.rdoc_files.include('README*')
|
50
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
51
|
end
|
data/lib/rubytter/connection.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
class Rubytter
|
3
3
|
class Connection
|
4
|
-
attr_reader :protocol, :port, :proxy_uri
|
4
|
+
attr_reader :protocol, :port, :proxy_uri, :enable_ssl
|
5
5
|
|
6
6
|
def initialize(options = {})
|
7
7
|
@proxy_host = options[:proxy_host]
|
@@ -11,14 +11,6 @@ class Rubytter
|
|
11
11
|
@proxy_uri = nil
|
12
12
|
@enable_ssl = options[:enable_ssl]
|
13
13
|
|
14
|
-
if @proxy_host
|
15
|
-
@http_class = Net::HTTP::Proxy(@proxy_host, @proxy_port,
|
16
|
-
@proxy_user, @proxy_password)
|
17
|
-
@proxy_uri = "http://" + @proxy_host + ":" + @proxy_port.to_s + "/"
|
18
|
-
else
|
19
|
-
@http_class = Net::HTTP
|
20
|
-
end
|
21
|
-
|
22
14
|
if @enable_ssl
|
23
15
|
@protocol = "https"
|
24
16
|
@port = 443
|
@@ -26,6 +18,14 @@ class Rubytter
|
|
26
18
|
@protocol = "http"
|
27
19
|
@port = 80
|
28
20
|
end
|
21
|
+
|
22
|
+
if @proxy_host
|
23
|
+
@http_class = Net::HTTP::Proxy(@proxy_host, @proxy_port,
|
24
|
+
@proxy_user, @proxy_password)
|
25
|
+
@proxy_uri = "#{@protocol}://" + @proxy_host + ":" + @proxy_port.to_s + "/"
|
26
|
+
else
|
27
|
+
@http_class = Net::HTTP
|
28
|
+
end
|
29
29
|
end
|
30
30
|
|
31
31
|
def start(host, port = nil, &block)
|
data/lib/rubytter.rb
CHANGED
@@ -8,9 +8,6 @@ require 'rubytter/connection'
|
|
8
8
|
require 'rubytter/oauth_rubytter'
|
9
9
|
|
10
10
|
class Rubytter
|
11
|
-
|
12
|
-
VERSION = '0.9.2'
|
13
|
-
|
14
11
|
class APIError < StandardError
|
15
12
|
attr_reader :response
|
16
13
|
def initialize(msg, response = nil)
|
@@ -30,6 +27,7 @@ class Rubytter
|
|
30
27
|
@header.merge!(options[:header]) if options[:header]
|
31
28
|
@app_name = options[:app_name]
|
32
29
|
@connection = Connection.new(options)
|
30
|
+
@connection_for_search = Connection.new(options.merge({:enable_ssl => false}))
|
33
31
|
end
|
34
32
|
|
35
33
|
def self.api_settings
|
@@ -40,6 +38,7 @@ class Rubytter
|
|
40
38
|
public_timeline /statuses/public_timeline
|
41
39
|
friends_timeline /statuses/friends_timeline
|
42
40
|
replies /statuses/replies
|
41
|
+
mentions /statuses/mentions
|
43
42
|
user_timeline /statuses/user_timeline/%s
|
44
43
|
show /statuses/show/%s
|
45
44
|
friends /statuses/friends/%s
|
@@ -67,6 +66,13 @@ class Rubytter
|
|
67
66
|
disable_notification /notifications/leave/%s post
|
68
67
|
block /blocks/create/%s post
|
69
68
|
unblock /blocks/destroy/%s delete
|
69
|
+
block_exists /blocks/exists/%s get
|
70
|
+
blocking /blocks/blocking get
|
71
|
+
blocking_ids /blocks/blocking/ids get
|
72
|
+
saved_searches /saved_searches get
|
73
|
+
saved_search /saved_searches/show/%s get
|
74
|
+
create_saved_search /saved_searches/create post
|
75
|
+
remove_saved_search /saved_searches/destroy/%s delete
|
70
76
|
".strip.split("\n").map{|line| line.strip.split(/\s+/)}
|
71
77
|
end
|
72
78
|
|
@@ -94,6 +100,12 @@ class Rubytter
|
|
94
100
|
__update_status(params)
|
95
101
|
end
|
96
102
|
|
103
|
+
alias_method :__create_saved_search, :create_saved_search
|
104
|
+
def create_saved_search(arg)
|
105
|
+
arg = {:query => arg} if arg.kind_of?(String)
|
106
|
+
__create_saved_search(arg)
|
107
|
+
end
|
108
|
+
|
97
109
|
def update(status, params = {})
|
98
110
|
update_status(params.merge({:status => status}))
|
99
111
|
end
|
@@ -123,7 +135,8 @@ class Rubytter
|
|
123
135
|
param_str = '?' + self.class.to_param_str(params.merge({:q => query}))
|
124
136
|
path = path + param_str unless param_str.empty?
|
125
137
|
req = create_request(Net::HTTP::Get.new(path), false)
|
126
|
-
|
138
|
+
|
139
|
+
json_data = http_request("search.#{@host}", req, nil, @connection_for_search)
|
127
140
|
self.class.structize(
|
128
141
|
json_data['results'].map do |result|
|
129
142
|
self.class.search_result_to_hash(result)
|
@@ -149,8 +162,9 @@ class Rubytter
|
|
149
162
|
}
|
150
163
|
end
|
151
164
|
|
152
|
-
def http_request(host, req, param_str = nil)
|
153
|
-
|
165
|
+
def http_request(host, req, param_str = nil, connection = nil)
|
166
|
+
connection ||= @connection
|
167
|
+
res = connection.start(host) do |http|
|
154
168
|
if param_str
|
155
169
|
http.request(req, param_str)
|
156
170
|
else
|
data/spec/rubytter_spec.rb
CHANGED
@@ -358,5 +358,25 @@ class Rubytter
|
|
358
358
|
end
|
359
359
|
o
|
360
360
|
end
|
361
|
+
|
362
|
+
describe 'spec for ssl' do
|
363
|
+
before do
|
364
|
+
@ssl_rubytter = Rubytter.new('foo', 'bar', {:enable_ssl => true})
|
365
|
+
end
|
366
|
+
|
367
|
+
it 'connection is enabled ssl' do
|
368
|
+
@ssl_rubytter.instance_eval{@connection.enable_ssl}.should == true
|
369
|
+
end
|
370
|
+
|
371
|
+
it 'connection_for_search is not ever ssl' do
|
372
|
+
connection_for_search = @ssl_rubytter.instance_eval{@connection_for_search}
|
373
|
+
connection_for_search.enable_ssl.should == false
|
374
|
+
|
375
|
+
@ssl_rubytter.should_receive(:http_request).
|
376
|
+
with('search.twitter.com', anything, nil, connection_for_search).
|
377
|
+
and_return({'results' => []})
|
378
|
+
@ssl_rubytter.search('rubytter')
|
379
|
+
end
|
380
|
+
end
|
361
381
|
end
|
362
382
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubytter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jugyo
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-30 00:00:00 +09:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,6 +22,16 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: 1.1.3
|
24
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
25
35
|
description: Rubytter is a simple twitter client.
|
26
36
|
email: jugyo.org@gmail.com
|
27
37
|
executables: []
|
@@ -30,14 +40,10 @@ extensions: []
|
|
30
40
|
|
31
41
|
extra_rdoc_files:
|
32
42
|
- README.rdoc
|
33
|
-
- History.txt
|
34
43
|
files:
|
35
|
-
-
|
36
|
-
-
|
37
|
-
-
|
38
|
-
- spec/rubytter_spec.rb
|
39
|
-
- spec/spec_helper.rb
|
40
|
-
- spec/search.json
|
44
|
+
- History.txt
|
45
|
+
- README.rdoc
|
46
|
+
- Rakefile
|
41
47
|
- examples/direct_message.rb
|
42
48
|
- examples/favorite.rb
|
43
49
|
- examples/follow.rb
|
@@ -47,19 +53,19 @@ files:
|
|
47
53
|
- examples/search.rb
|
48
54
|
- examples/update_status.rb
|
49
55
|
- examples/user.rb
|
50
|
-
-
|
51
|
-
-
|
52
|
-
-
|
56
|
+
- lib/rubytter.rb
|
57
|
+
- lib/rubytter/connection.rb
|
58
|
+
- lib/rubytter/oauth_rubytter.rb
|
59
|
+
- spec/rubytter_spec.rb
|
60
|
+
- spec/search.json
|
61
|
+
- spec/spec_helper.rb
|
53
62
|
has_rdoc: true
|
54
63
|
homepage: http://github.com/jugyo/rubytter
|
55
64
|
licenses: []
|
56
65
|
|
57
66
|
post_install_message:
|
58
67
|
rdoc_options:
|
59
|
-
- --
|
60
|
-
- README.rdoc
|
61
|
-
- --exclude
|
62
|
-
- spec
|
68
|
+
- --charset=UTF-8
|
63
69
|
require_paths:
|
64
70
|
- lib
|
65
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -76,10 +82,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
82
|
version:
|
77
83
|
requirements: []
|
78
84
|
|
79
|
-
rubyforge_project:
|
80
|
-
rubygems_version: 1.3.
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.3.5
|
81
87
|
signing_key:
|
82
88
|
specification_version: 3
|
83
89
|
summary: Simple twitter client.
|
84
|
-
test_files:
|
85
|
-
|
90
|
+
test_files:
|
91
|
+
- spec/rubytter_spec.rb
|
92
|
+
- spec/spec_helper.rb
|
93
|
+
- examples/direct_message.rb
|
94
|
+
- examples/favorite.rb
|
95
|
+
- examples/follow.rb
|
96
|
+
- examples/friends_timeline.rb
|
97
|
+
- examples/limit.rb
|
98
|
+
- examples/replies.rb
|
99
|
+
- examples/search.rb
|
100
|
+
- examples/update_status.rb
|
101
|
+
- examples/user.rb
|