trans-api 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
- !binary "U0hBMQ==":
2
+ SHA1:
3
3
  metadata.gz: !binary |-
4
- OWZiMWExZjAyYjVmNDFiZDY1NTFiMzdlMDM1OGQyNGZkZjQyNTdmYQ==
4
+ YTE4YzBlYmRjN2Q1ZDQwZWYwNWM0MjA4ZDE2YmE0ZjNmNmYzMGI5MQ==
5
5
  data.tar.gz: !binary |-
6
- YmIyZjRkNTM3MWQ3Y2U1MDNjZTQ5Y2I5NWQ0ZTBkZDAyMDk0NjE5Yg==
7
- !binary "U0hBNTEy":
6
+ NDZhNjBkNTZjYmYyMjM4NDU5NzJmMDBmZWQzMzMwMjYwNTNmYjExYg==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- MmRkYTc1ODczMDFlYzJiMGY1ODBlYTk1NjI1MzUwMmRlMGJmNmY5MDQwMzM1
10
- ZDI3ZGEwYzg5MjgzMTVlZWQxYWUzNTQ0ZmZjNzg3N2MwOTE1MzE3NTQ0YTA4
11
- MzU3NzQ2ZGE1YzQ0ZTkzNDM4NjYzZjk3YWZjY2FiZGIxNWVkZTg=
9
+ YWJkNjJiZTdlNzE4NjgxZDc2YjE0MWQzZGI1NzY5N2EzZjY3MDhiYWNjZjlh
10
+ YTdjYTEwMTg5NGU2NjZkZDJjNTE4NjdkN2EzZmRiMTAzODljZTM3ZjZlNDlm
11
+ YjY3ZTRlMTgzNjlhOWNkOThmMTViMzdhZGU2ZTY3ZmQ5YjMyZDc=
12
12
  data.tar.gz: !binary |-
13
- OTJhZTgyZTIwZjBkZGEzZjBkNjc0NzRmYzAzYmEyMWE2ZTQxY2JiMjVjN2Ex
14
- OTk1NjRkMzY1YmFiZjJiNmJlMmJmODRiNGVjMmVhZDNmZTg5ODk2ZGEyOTg1
15
- ZjE3N2ZlMzRmNDgxM2QwZGRiN2ZiZWNiNzllZGVjMmIwZGM1NDM=
13
+ NDY5MjgyOGZmODQ1N2ZiYWNhMmMyMjUwMzg3MTMxYWU3OTRjNTJlMzYzMTUy
14
+ ZWZiYjI0NmZjYjZjMDljNDgzNDVkZmZlYWQ1N2FlZmEzMmY3NzNkMWNmNGJm
15
+ YjNiYTFiMjQ0N2UyNzhkYTVhNDNlM2VjNWYzODM1Nzc0YTU3Zjk=
data/Gemfile.lock CHANGED
@@ -9,10 +9,13 @@ GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  json (1.7.5)
12
+ json (1.7.5-java)
12
13
  nokogiri (1.5.5)
14
+ nokogiri (1.5.5-java)
13
15
  test-unit (2.5.2)
14
16
 
15
17
  PLATFORMS
18
+ java
16
19
  ruby
17
20
 
18
21
  DEPENDENCIES
@@ -18,6 +18,7 @@ module Trans
18
18
 
19
19
  class << self
20
20
  def config=(config = {})
21
+ config[:port] = config[:port].to_i if config.include? :port
21
22
  @@config = config
22
23
  end
23
24
  end
@@ -27,6 +27,9 @@ module Trans
27
27
  :ids, :location, :peer_limit, :priority_high, :priority_low, :priority_normal, :queuePosition, :seedIdleLimit,
28
28
  :seedIdleMode, :seedRatioLimit, :seedRatioMode, :trackerAdd, :trackerRemove, :trackerReplace, :uploadLimit, :uploadLimited ]
29
29
 
30
+ CONTROL = [:start!, :start_now!, :stop!, :verify!, :reannounce!, :set_location!, :delete!, :queue_top!, :queue_bottom!,
31
+ :queue_up!, :queue_down!]
32
+
30
33
  # torrent add fields
31
34
  ADD = [ :cookies, :download_dir, :filename, :metainfo, :paused, :peer_limit, :bandwidthPriority, :files_wanted,
32
35
  :files_unwanted, :priority_high, :priority_low, :priority_normal ]
@@ -80,11 +83,10 @@ module Trans
80
83
  # files wrapped by an File object
81
84
  def files_objects
82
85
  ret = []
83
- # i = -1
84
86
  torrent = @client.connect.torrent_get([:files, :fileStats], [self.id]).first
85
87
  @fields[:files] = torrent[:files]
86
88
  @fields[:fileStatus] = torrent[:fileStats]
87
- self.files.each_with_index{ |f,i| ret << Trans::Api::File.new( torrent: self, fields: @fields,
89
+ @fields[:files].each_with_index{ |f,i| ret << Trans::Api::File.new( torrent: self, fields: @fields,
88
90
  file: f.merge(id: i).merge(fileStat: torrent[:fileStats][i])) }
89
91
  ret
90
92
  end
@@ -204,6 +206,14 @@ module Trans
204
206
  Torrent.new torrent: torrent
205
207
  end
206
208
 
209
+ def add_metainfo(metainfo, options={})
210
+ options[:metainfo] = metainfo
211
+ client = Client.new
212
+ torrent = client.connect.torrent_add options
213
+ torrent = client.connect.torrent_get( @@default_fields, [torrent[:id]]).first
214
+ Torrent.new torrent: torrent
215
+ end
216
+
207
217
  def default_fields=(list=[])
208
218
  @@default_fields << :id unless list.include? :id
209
219
  @@default_fields |= list
@@ -1,5 +1,5 @@
1
1
  module Trans
2
2
  module Api
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -13,7 +13,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../../lib/trans-api")
13
13
 
14
14
  class TransTorrentObject < Test::Unit::TestCase
15
15
 
16
- CONFIG = { host: "localhost", port: 9091, user: "admin", pass: "admin", path: "/transmission/rpc" }
16
+ CONFIG = { host: "localhost", port: 8078, user: "pinguin", pass: "100110", path: "/transmission/rpc" }
17
17
 
18
18
  def setup
19
19
  Trans::Api::Client.config = CONFIG
@@ -337,6 +337,24 @@ class TransTorrentObject < Test::Unit::TestCase
337
337
 
338
338
  end
339
339
 
340
+
341
+ def test_torrent_add_by_base
342
+ file = File.expand_path(File.dirname(__FILE__) + "/torrents/debian-6.0.6-amd64-CD-5.iso.torrent")
343
+
344
+ metainfo = ""
345
+ File.open(file, 'r') do |file|
346
+ tmp = file.read
347
+ metainfo += Base64.encode64 tmp
348
+ end
349
+
350
+ torrent = Trans::Api::Torrent.add_metainfo(metainfo, paused: true)
351
+ assert torrent.name == "debian-6.0.6-amd64-CD-5.iso"
352
+ torrent.delete!
353
+
354
+ end
355
+
356
+
357
+
340
358
  protected
341
359
 
342
360
 
data/trans-api.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Trans::Api::VERSION
9
9
  gem.authors = ["Dennis Blommesteijn"]
10
10
  gem.email = ["dennis@blommesteijn.com"]
11
- gem.description = %q{transmission torrent client rpc interface library}
12
- gem.summary = %q{transmission torrent client rpc interface library}
11
+ gem.description = %q{Transmission RPC API for Ruby on Rails (gem).}
12
+ gem.summary = %q{Transmission RPC API for Ruby on Rails (gem)}
13
13
  gem.homepage = ""
14
14
 
15
15
  # dependencies
metadata CHANGED
@@ -1,65 +1,65 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trans-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Blommesteijn
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-01 00:00:00.000000000 Z
11
+ date: 2013-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
15
20
  requirement: !ruby/object:Gem::Requirement
16
21
  requirements:
17
- - - ! '>='
22
+ - - ">="
18
23
  - !ruby/object:Gem::Version
19
24
  version: '0'
20
- type: :runtime
21
25
  prerelease: false
26
+ type: :runtime
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
22
29
  version_requirements: !ruby/object:Gem::Requirement
23
30
  requirements:
24
- - - ! '>='
31
+ - - ">="
25
32
  - !ruby/object:Gem::Version
26
33
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: json
29
34
  requirement: !ruby/object:Gem::Requirement
30
35
  requirements:
31
- - - ! '>='
36
+ - - ">="
32
37
  - !ruby/object:Gem::Version
33
38
  version: '0'
34
- type: :runtime
35
39
  prerelease: false
40
+ type: :runtime
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
36
43
  version_requirements: !ruby/object:Gem::Requirement
37
44
  requirements:
38
- - - ! '>='
45
+ - - ">="
39
46
  - !ruby/object:Gem::Version
40
47
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: test-unit
43
48
  requirement: !ruby/object:Gem::Requirement
44
49
  requirements:
45
- - - ! '>='
50
+ - - ">="
46
51
  - !ruby/object:Gem::Version
47
52
  version: '0'
48
- type: :development
49
53
  prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- description: transmission torrent client rpc interface library
54
+ type: :development
55
+ description: Transmission RPC API for Ruby on Rails (gem).
56
56
  email:
57
57
  - dennis@blommesteijn.com
58
58
  executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - .gitignore
62
+ - ".gitignore"
63
63
  - Gemfile
64
64
  - Gemfile.lock
65
65
  - LICENSE.txt
@@ -89,26 +89,26 @@ files:
89
89
  homepage: ''
90
90
  licenses: []
91
91
  metadata: {}
92
- post_install_message:
92
+ post_install_message:
93
93
  rdoc_options: []
94
94
  require_paths:
95
95
  - lib
96
96
  required_ruby_version: !ruby/object:Gem::Requirement
97
97
  requirements:
98
- - - ! '>='
98
+ - - ">="
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - ! '>='
103
+ - - ">="
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 2.0.0
109
- signing_key:
107
+ rubyforge_project:
108
+ rubygems_version: 2.0.3
109
+ signing_key:
110
110
  specification_version: 4
111
- summary: transmission torrent client rpc interface library
111
+ summary: Transmission RPC API for Ruby on Rails (gem)
112
112
  test_files:
113
113
  - test/test_helper.rb
114
114
  - test/unit/torrents/debian-6.0.6-amd64-CD-1.iso.torrent
@@ -121,4 +121,3 @@ test_files:
121
121
  - test/unit/trans_connect.rb
122
122
  - test/unit/trans_session_object.rb
123
123
  - test/unit/trans_torrent_object.rb
124
- has_rdoc: