transmission-connect 0.2.1 → 0.2.2

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -20,6 +20,10 @@ module Transmission
20
20
  def initialize(host = '127.0.0.1', port = 9091, username = nil, password = nil)
21
21
  @header = username.nil? ? {} : {'Authorization' => Base64.encode64("#{username}:#{password}")}
22
22
  @uri = URI.parse("http://#{host}:#{port}/#{RPC_PATH}")
23
+ new_connection
24
+ end
25
+
26
+ def new_connection
23
27
  @connection = Net::HTTP.start(@uri.host, @uri.port)
24
28
  end
25
29
 
@@ -53,13 +57,20 @@ module Transmission
53
57
  private
54
58
  def request(method, args)
55
59
  post_data = build_json method, args
56
- result = @connection.post2(@uri.path, post_data, @header)
60
+ begin
61
+ result = @connection.post2(@uri.path, post_data, @header)
62
+ rescue
63
+ new_connection
64
+ return request method, args
65
+ end
57
66
  case result
58
67
  when Net::HTTPSuccess
59
68
  JSON.parse(result.read_body)['arguments']
60
69
  when Net::HTTPConflict
61
70
  @header = @header.merge("x-transmission-session-id" => result.header["x-transmission-session-id"])
62
71
  request(method, args)
72
+ when Net::HTTPBadResponse
73
+ request(method, args)
63
74
  else
64
75
  raise Exception
65
76
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{transmission-connect}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dmitry Brazhkin"]
12
- s.date = %q{2011-04-11}
12
+ s.date = %q{2011-04-12}
13
13
  s.description = %q{Simple connector to transmission bittorrent client by HTTP-RPC}
14
14
  s.email = %q{dbrazhkin@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
34
34
  s.homepage = %q{http://github.com/Daem0n/transmission-connect}
35
35
  s.licenses = ["MIT"]
36
36
  s.require_paths = ["lib"]
37
- s.rubygems_version = %q{1.7.1}
37
+ s.rubygems_version = %q{1.7.2}
38
38
  s.summary = %q{Simple connector to transmission bittorrent client}
39
39
  s.test_files = [
40
40
  "test/helper.rb",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transmission-connect
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dmitry Brazhkin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-11 00:00:00 Z
18
+ date: 2011-04-12 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  requirements: []
144
144
 
145
145
  rubyforge_project:
146
- rubygems_version: 1.7.1
146
+ rubygems_version: 1.7.2
147
147
  signing_key:
148
148
  specification_version: 3
149
149
  summary: Simple connector to transmission bittorrent client