transmission-rpc-ruby 0.3.1 → 0.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65cb225f8fd39304893c5f15257ba7259da35372
4
- data.tar.gz: d0f892cbc9a74e75a474397b4b7a4fa191973e37
3
+ metadata.gz: 36f7ba02b6c73c6470c5325c3d9beb46a018715a
4
+ data.tar.gz: a6831e5413f25ba30f9a86ffc277dd0340452665
5
5
  SHA512:
6
- metadata.gz: 044eaf5d91f98ae775a39dcaf0422b9cadcc8722b61739b52ac94e1d4db6a8a98a6a965bf37095702d0d31d0f73837e858a6ef4cd50fb7c35ffc59071884bdbf
7
- data.tar.gz: 364f786d1559d480be7f897f38c8d54b6d02012e431c11ac8242fc8c141d974ea8b599df17716b684a7166959e133a53a5952f6f7c6e6a16b4ecf90bb539af86
6
+ metadata.gz: f5dceb327feb0da37fe6df7d430fe2ca822a8e9f14f4f077e3b64b784fdd7c94bb5ab67d4c2ce48b2ab8d9bad496ddfaf1cc7a7b3247c97a1455c7bd28418562
7
+ data.tar.gz: 2fd940b6a973a647d856d936c082da43a3970110eba5b9281f6fdb950ba05673070084b7f8bd944ffea2749305fcb3ab50b34fa030af979cf5d569f9601959fe
@@ -1,3 +1,9 @@
1
+ ## v0.4.0 (2015-05-09)
2
+
3
+ Features:
4
+
5
+ - Added `set_location` method to torrent model (thanks @balinez)
6
+
1
7
  ## v0.3.1 (2015-04-03)
2
8
 
3
9
  Bugfixes:
data/README.md CHANGED
@@ -123,6 +123,17 @@ The `save!` method will update the torrent on your remote transmission daemon.
123
123
 
124
124
  To find all the torrent [accessors](https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt#L127) & [mutators](https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt#L90) visit [spec](https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt)
125
125
 
126
+ #### Change torrent location
127
+
128
+ id = 1
129
+ torrent = Transmission::Model::Torrent.find(id)
130
+
131
+ # Copies torrent to new location
132
+ torrent.set_location '/some/new/path'
133
+
134
+ # Moves torrent to new location
135
+ torrent.set_location '/some/new/path', true
136
+
126
137
  #### Start & Stop all torrents
127
138
 
128
139
  You can also start and stop all torrents
@@ -223,6 +234,12 @@ For more methods check out `lib/transmission/rpc.rb`
223
234
 
224
235
  ## Changelog
225
236
 
237
+ ### v0.4.0 (2015-05-09)
238
+
239
+ Features:
240
+
241
+ - Added `set_location` method to torrent model (thanks @balinez)
242
+
226
243
  ### v0.3.1 (2015-04-03)
227
244
 
228
245
  Bugfixes:
@@ -1,6 +1,7 @@
1
1
  require File.join(File.dirname(__FILE__), 'arguments', 'torrent_add')
2
2
  require File.join(File.dirname(__FILE__), 'arguments', 'torrent_set')
3
3
  require File.join(File.dirname(__FILE__), 'arguments', 'session_set')
4
+ require File.join(File.dirname(__FILE__), 'arguments', 'location_set')
4
5
  require File.join(File.dirname(__FILE__), 'utils')
5
6
 
6
7
  module Transmission
@@ -0,0 +1,13 @@
1
+ module Transmission
2
+ class Arguments
3
+ class LocationSet < Transmission::Arguments
4
+
5
+ ATTRIBUTES = [
6
+ {field: 'ids'},
7
+ {field: 'location'},
8
+ {field: 'move'}
9
+ ]
10
+
11
+ end
12
+ end
13
+ end
@@ -67,6 +67,10 @@ module Transmission
67
67
  connector.re_announce_torrent @ids
68
68
  end
69
69
 
70
+ def set_location(new_location, move = false)
71
+ connector.torrent_set_location @ids, location: new_location, move: move
72
+ end
73
+
70
74
  def is_multi?
71
75
  @ids.size > 1
72
76
  end
@@ -60,6 +60,12 @@ module Transmission
60
60
  @connector.post method: 'torrent-add', arguments: arguments.to_arguments
61
61
  end
62
62
 
63
+ def torrent_set_location(ids, arguments)
64
+ arguments[:ids] = ids
65
+ arguments = Transmission::Arguments::LocationSet.new(arguments)
66
+ @connector.post method: 'torrent-set-location', arguments: arguments.to_arguments
67
+ end
68
+
63
69
  def remove_torrent(ids, delete_local_data = false)
64
70
  @connector.post method: 'torrent-remove', arguments: {ids: ids, 'delete-local-data' => delete_local_data}
65
71
  end
@@ -20,6 +20,12 @@ module Stubs
20
20
  .to_return(successful_response)
21
21
  end
22
22
 
23
+ def stub_set_location_torrent(body)
24
+ stub_rpc_request
25
+ .with(body: torrent_set_location_body(body))
26
+ .to_return(successful_response)
27
+ end
28
+
23
29
  def torrent_get_body(arguments = {})
24
30
  args = {fields: Transmission::Fields::TorrentGet.new.to_fields}.merge(arguments)
25
31
  {method: 'torrent-get', arguments: args}.to_json
@@ -37,6 +43,10 @@ module Stubs
37
43
  {method: 'torrent-set', arguments: arguments}.to_json
38
44
  end
39
45
 
46
+ def torrent_set_location_body(arguments = {})
47
+ {method: 'torrent-set-location', arguments: arguments}.to_json
48
+ end
49
+
40
50
  def torrent_method_body(method, arguments)
41
51
  {method: method, arguments: arguments}.to_json
42
52
  end
@@ -148,6 +148,19 @@ describe Transmission::Model::Torrent do
148
148
  end
149
149
  end
150
150
 
151
+ describe '#set_location' do
152
+ before :each do
153
+ Transmission::Config.set
154
+ stub_get_torrent({ids: [1]}, [{id: 1}])
155
+ stub_set_location_torrent({location: '/some/location', move: false, ids: [1]})
156
+ end
157
+
158
+ it 'should set a new location' do
159
+ torrent = Transmission::Model::Torrent.find 1
160
+ torrent.set_location '/some/location'
161
+ end
162
+ end
163
+
151
164
  describe '#delete!' do
152
165
 
153
166
  describe 'with configuration' do
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'transmission-rpc-ruby'
3
- s.version = '0.3.1'
4
- s.date = '2015-04-03'
3
+ s.version = '0.4.0'
4
+ s.date = '2015-05-09'
5
5
  s.summary = "Transmission RPC wrapper in Ruby"
6
6
  s.description = "A new transmission RPC wrapper for Ruby. All object oriented for controlling remote transmission daemons."
7
7
  s.authors = ["Max Hoffmann"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transmission-rpc-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Hoffmann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-03 00:00:00.000000000 Z
11
+ date: 2015-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -84,6 +84,7 @@ files:
84
84
  - Rakefile
85
85
  - lib/transmission.rb
86
86
  - lib/transmission/arguments.rb
87
+ - lib/transmission/arguments/location_set.rb
87
88
  - lib/transmission/arguments/session_set.rb
88
89
  - lib/transmission/arguments/torrent_add.rb
89
90
  - lib/transmission/arguments/torrent_set.rb