rubytter 0.4.5 → 0.4.6

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 CHANGED
@@ -0,0 +1,2 @@
1
+ - 0.4.6
2
+ - Change to able to specify header as option at initialize.
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = rubytter
2
2
 
3
- http://github.com/jugyo/rubytter
3
+ http://wiki.github.com/jugyo/rubytter
4
4
 
5
5
  == DESCRIPTION:
6
6
 
@@ -42,6 +42,7 @@ implemented API methods:
42
42
  - /notifications/leave/id
43
43
  - /blocks/create/id
44
44
  - /blocks/destroy/id
45
+ - (search.twitter.com)/search
45
46
 
46
47
  == SYNOPSIS:
47
48
 
@@ -59,6 +60,10 @@ get friends timeline
59
60
 
60
61
  == REQUIREMENTS:
61
62
 
63
+ * json_pure
64
+
65
+ or
66
+
62
67
  * json
63
68
 
64
69
  == INSTALL:
data/lib/rubytter.rb CHANGED
@@ -10,13 +10,17 @@ class Rubytter
10
10
  class APIError < StandardError; end
11
11
 
12
12
  APP_NAME = 'Rubytter'
13
- VERSION = '0.4.5'
13
+ VERSION = '0.4.6'
14
14
  HOMEPAGE = 'http://github.com/jugyo/rubytter'
15
15
 
16
+ attr_reader :login
17
+ attr_accessor :host, :header
18
+
16
19
  def initialize(login, password, options = {})
17
20
  @login = login
18
21
  @password = password
19
22
  @host = options[:host] || 'twitter.com'
23
+ @header = options[:header] || {'User-Agent', "#{APP_NAME}/#{VERSION} (#{HOMEPAGE})"}
20
24
  @connection = Connection.new(options)
21
25
  end
22
26
 
@@ -131,7 +135,7 @@ class Rubytter
131
135
  end
132
136
 
133
137
  def create_request(req)
134
- req.add_field('User-Agent', "#{APP_NAME} #{HOMEPAGE}")
138
+ @header.each {|k, v| req.add_field(k, v) }
135
139
  req.basic_auth(@login, @password)
136
140
  req
137
141
  end
@@ -137,7 +137,11 @@ class Rubytter
137
137
  end
138
138
 
139
139
  it 'should respond to to_param_str' do
140
- @rubytter.to_param_str(:page => 2, :foo => 'bar').should == 'foo=bar&page=2'
140
+ param_str = @rubytter.to_param_str(:page => 2, :foo => 'bar')
141
+ p param_str
142
+ param_str.should =~ /^.+?=.+?&.+?=.+?$/
143
+ param_str.should =~ /page=2/
144
+ param_str.should =~ /foo=bar/
141
145
  end
142
146
 
143
147
  it 'should raise when call to_param_str with invalid arg' do
@@ -146,6 +150,22 @@ class Rubytter
146
150
  lambda { @rubytter.to_param_str(:bar) }.should raise_error ArgumentError
147
151
  end
148
152
 
153
+ it 'should set default header' do
154
+ rubytter = Rubytter.new('test', 'test')
155
+ rubytter.header.should == {'User-Agent', "#{APP_NAME}/#{VERSION} (#{HOMEPAGE})"}
156
+ end
157
+
158
+ it 'should able to set custom header' do
159
+ rubytter = Rubytter.new('test', 'test',
160
+ {
161
+ :header => {
162
+ 'User-Agent' => 'foo'
163
+ }
164
+ }
165
+ )
166
+ rubytter.header.should == {'User-Agent' => 'foo'}
167
+ end
168
+
149
169
  it 'should create struct from json' do
150
170
  hash = {
151
171
  :a => 'a',
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.4.5
4
+ version: 0.4.6
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-02-15 00:00:00 +09:00
12
+ date: 2009-02-22 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency