hatenaapigraph 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/CHANGELOG +3 -0
  2. data/README +4 -0
  3. data/lib/hatena/api/graph.rb +9 -4
  4. metadata +2 -2
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ * 0.1.2* (May 29th, 2007)
2
+ add proxy set interface
3
+
1
4
  * 0.1.1* (May 16th, 2007)
2
5
  Multibyte graphname Bug Fix
3
6
  - http://d.hatena.ne.jp/takatoh/20070502/hatenagraph (thanks!)
data/README CHANGED
@@ -9,6 +9,10 @@
9
9
  graph.post('graphname', Time.now, 10.5)
10
10
  graph.post(graphname, timestamp, value)
11
11
 
12
+ # use proxy
13
+ graph.proxy = Net::HTTP::Proxy(proxy_host, proxy_port, proxy_user, proxy_pass)
14
+ graph.post(graphname, timestamp, value)
15
+
12
16
  == Installation
13
17
 
14
18
  # gem install hatenaapigraph
@@ -16,7 +16,9 @@ module Hatena
16
16
  def initialize(username, password)
17
17
  @username = username
18
18
  @password = password
19
+ @proxy = nil
19
20
  end
21
+ attr_accessor :proxy
20
22
 
21
23
  def post(graphname, date, value)
22
24
  value = value.to_f
@@ -40,10 +42,13 @@ module Hatena
40
42
  req = ::Net::HTTP::Post.new(url.path, headers)
41
43
  req.form_data = params
42
44
  req.basic_auth url.user, url.password if url.user
43
- proxy_host, proxy_port = (ENV['HTTP_PROXY'] || '').split(/:/)
44
- ::Net::HTTP::Proxy(proxy_host, proxy_port.to_i).start(url.host, url.port) {|http|
45
- http.request(req)
46
- }
45
+ if @proxy
46
+ proxy = @proxy
47
+ else
48
+ proxy_host, proxy_port = (ENV['HTTP_PROXY'] || '').split(/:/)
49
+ proxy = ::Net::HTTP::Proxy(proxy_host, proxy_port.to_i)
50
+ end
51
+ proxy.start(url.host, url.port) {|http| http.request(req) }
47
52
  end
48
53
 
49
54
  def wsse(username, password)
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.1
3
3
  specification_version: 1
4
4
  name: hatenaapigraph
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.1
7
- date: 2007-05-17 00:00:00 +09:00
6
+ version: 0.1.2
7
+ date: 2007-05-29 00:00:00 +09:00
8
8
  summary: description of gem
9
9
  require_paths:
10
10
  - lib