kyototycoon 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
data/Changes.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v0.5.2
2
+
3
+ * fixed encoded response handling
4
+ * fixed miss named method
5
+
1
6
  ## v0.5.1
2
7
 
3
8
  * changing server dicision logic
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010 uu59<a@tt25.org>
1
+ Copyright (c) 2011 uu59<a@tt25.org>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
data/kyototycoon.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{kyototycoon}
8
- s.version = "0.5.1"
8
+ s.version = "0.5.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["uu59"]
12
- s.date = %q{2010-12-23}
12
+ s.date = %q{2011-01-03}
13
13
  s.description = %q{KyotoTycoon client for Ruby}
14
14
  s.email = %q{a@tt25.org}
15
15
  s.extra_rdoc_files = [
@@ -22,18 +22,25 @@ class KyotoTycoon
22
22
  status = first_line[9, 3]
23
23
  bodylen = 0
24
24
  body = ""
25
+ colenc = nil
25
26
  loop do
26
27
  line = @sock.gets
28
+ if line['Content-Type'] && line['colenc=']
29
+ colenc = line.match(/colenc=([A-Z])/).to_a[1]
30
+ next
31
+ end
32
+
27
33
  if line['Content-Length']
28
34
  bodylen = line.match(/[0-9]+/)[0].to_i
29
35
  next
30
36
  end
37
+
31
38
  if line == "\r\n"
32
39
  break
33
40
  end
34
41
  end
35
42
  body = @sock.read(bodylen)
36
- [status.to_i, body]
43
+ [status.to_i, Tsvrpc.decode_responce_body(body, colenc)]
37
44
  end
38
45
 
39
46
  def start
@@ -35,5 +35,24 @@ class KyotoTycoon
35
35
  end
36
36
  query
37
37
  end
38
+
39
+ def self.decode_responce_body(body, colenc)
40
+ case colenc
41
+ when "B"
42
+ body.split("\n").map{|row|
43
+ row.split("\t").map{|col| Base64.decode64(col)}.join("\t")
44
+ }.join("\n")
45
+ when "U"
46
+ body.split("\n").map{|row|
47
+ row.split("\t").map{|col|
48
+ CGI.unescape(col)
49
+ }.join("\t")
50
+ }.join("\n")
51
+ when nil
52
+ body
53
+ else
54
+ raise "Unknown colenc(response) '#{colenc}'"
55
+ end
56
+ end
38
57
  end
39
58
  end
data/lib/kyototycoon.rb CHANGED
@@ -281,7 +281,7 @@ class KyotoTycoon
281
281
  }
282
282
  if @checked_servers.nil?
283
283
  msg = "alived server not exists"
284
- @logger.crit(msg)
284
+ @logger.fatal(msg)
285
285
  raise msg
286
286
  end
287
287
  @checked_servers
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 1
9
- version: 0.5.1
8
+ - 2
9
+ version: 0.5.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - uu59
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-23 00:00:00 +09:00
17
+ date: 2011-01-03 00:00:00 +09:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency