rubytter 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/rubytter.rb +10 -5
  2. data/spec/rubytter_spec.rb +4 -4
  3. metadata +2 -2
data/lib/rubytter.rb CHANGED
@@ -16,7 +16,7 @@ class Rubytter
16
16
  end
17
17
  end
18
18
 
19
- VERSION = '0.6.4'
19
+ VERSION = '0.6.5'
20
20
 
21
21
  attr_reader :login
22
22
  attr_accessor :host, :header
@@ -125,16 +125,16 @@ class Rubytter
125
125
  json_data = http_request("search.#{@host}", req)
126
126
  self.class.json_to_struct(
127
127
  json_data['results'].map do |result|
128
- search_result_to_struct(result)
128
+ self.class.search_result_to_hash(result)
129
129
  end
130
130
  )
131
131
  end
132
132
 
133
- def search_result_to_struct(json)
133
+ def self.search_result_to_hash(json)
134
134
  {
135
135
  'id' => json['id'],
136
136
  'text' => json['text'],
137
- 'source' => CGI.unescapeHTML(json['source']),
137
+ 'source' => json['source'],
138
138
  'created_at' => json['created_at'],
139
139
  'in_reply_to_user_id' => json['to_usre_id'],
140
140
  'in_reply_to_screen_name' => json['to_usre'],
@@ -189,7 +189,12 @@ class Rubytter
189
189
  nil
190
190
  end
191
191
  else
192
- json
192
+ case json
193
+ when String
194
+ CGI.unescapeHTML(json)
195
+ else
196
+ json
197
+ end
193
198
  end
194
199
  end
195
200
 
@@ -178,7 +178,7 @@ class Rubytter
178
178
  nil => nil,
179
179
  :c => {:a => 1, :b => 2},
180
180
  :d => {:a => {:a => 1, :b => 2}, :b => 1},
181
- :e => [{:a => 1, :b => 2}, {:c => 3}]
181
+ :e => [{:a => 1, :b => 2}, {:c => '"<>&'}]
182
182
  }
183
183
  struct = Rubytter.json_to_struct(hash)
184
184
  struct.a.should == 'a'
@@ -188,7 +188,7 @@ class Rubytter
188
188
  struct.d.a.a.should == 1
189
189
  struct.e[0].a.should == 1
190
190
  struct.e[0].b.should == 2
191
- struct.e[1].c.should == 3
191
+ struct.e[1].c.should == '"<>&'
192
192
  lambda {struct.x}.should raise_error(NoMethodError)
193
193
  lambda {struct.regex}.should raise_error(NoMethodError)
194
194
  end
@@ -218,11 +218,11 @@ class Rubytter
218
218
  'profile_image_url' => 'http://s3.amazonaws.com/twitter_production/profile_images/63467667/megane2_normal.png'
219
219
  }
220
220
  rubytter = Rubytter.new('test', 'teat')
221
- result = rubytter.search_result_to_struct(json_data)
221
+ result = Rubytter.search_result_to_hash(json_data)
222
222
  result['id'].should == '123'
223
223
  result['text'].should == 'foo foo bar bar'
224
224
  result['created_at'].should == 'Sat, 21 Mar 2009 09:48:20 +0000'
225
- result['source'].should == "<a href=\"http:\\/\\/twitter.com\\/\">web<\\/a>"
225
+ result['source'].should == '&lt;a href=&quot;http:\/\/twitter.com\/&quot;&gt;web&lt;\/a&gt;'
226
226
  result['in_reply_to_user_id'].should == '20660692'
227
227
  result['in_reply_to_screen_name'].should == 'jugyo_test'
228
228
  result['user']['id'].should == '3748631'
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.6.4
4
+ version: 0.6.5
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-03-22 00:00:00 +09:00
12
+ date: 2009-03-25 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency