hot-coffee-twitter-ruby 0.1.3 → 0.1.4

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/twitter.rb +1 -1
  2. data/lib/twitter/rest_api.rb +19 -9
  3. metadata +1 -1
@@ -1,5 +1,5 @@
1
1
  require 'twitter/rest_api'
2
2
 
3
3
  module Twitter
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
@@ -17,13 +17,6 @@ module Twitter
17
17
  @proxy_user = options[:proxy_user]
18
18
  @proxy_pass = options[:proxy_pass]
19
19
 
20
- @http = Net::HTTP.new(API_ADDRESS, @port,
21
- @proxy_addr, @proxy_port, @proxy_user, @proxy_pass)
22
- @https = Net::HTTP.new(API_ADDRESS, @ssl_port,
23
- @proxy_addr, @proxy_port, @proxy_user, @proxy_pass)
24
- @https.use_ssl = true
25
- @https.verify_mode = OpenSSL::SSL::VERIFY_NONE
26
-
27
20
  @header = {'User-Agent' => "twitter-ruby/#{Twitter::VERSION}"}
28
21
  @header.merge! options[:header] if options[:header]
29
22
  end
@@ -65,9 +58,9 @@ module Twitter
65
58
  private
66
59
  def http_request(req, require_auth)
67
60
  if require_auth
68
- res = @https.request(req)
61
+ res = https.request(req)
69
62
  else
70
- res = @http.request(req)
63
+ res = http.request(req)
71
64
  end
72
65
  data = JSON.parse(res.body)
73
66
 
@@ -78,5 +71,22 @@ module Twitter
78
71
  raise Twitter::ResponseError.new(data['error'], res)
79
72
  end
80
73
  end
74
+
75
+ def http
76
+ Net::HTTP.new(
77
+ API_ADDRESS, @port,
78
+ @proxy_addr, @proxy_port, @proxy_user, @proxy_pass
79
+ )
80
+ end
81
+
82
+ def https
83
+ https = Net::HTTP.new(
84
+ API_ADDRESS, @ssl_port,
85
+ @proxy_addr, @proxy_port, @proxy_user, @proxy_pass
86
+ )
87
+ https.use_ssl = true
88
+ https.verify_mode = OpenSSL::SSL::VERIFY_NONE
89
+ https
90
+ end
81
91
  end
82
92
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hot-coffee-twitter-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - hot_coffee