utorrent-webapi-ruby 0.0.2.1 → 0.0.3.1

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: 00de944a6c2444043494de2a78c55a33bb0eb302
4
- data.tar.gz: c61533c6524a044f02a4f7df686254b40488e63b
3
+ metadata.gz: 64bac2390c6016d08b37b91ea9173b0750a39d6e
4
+ data.tar.gz: 0dbeafe21718f8ab7dfe7b2e324a9c11d8c564c5
5
5
  SHA512:
6
- metadata.gz: 70d2e31e475112a6b18e64ff642048a28df821e274be00872649ccef24c9d207e2149d82d28c842df1c49aa4c9241af4a4e3d8237eafbadcaac6fe105b56a38f
7
- data.tar.gz: e8b9f40417d9a7fb3806a125a7563ce55f7261cd35b93d778cc01c739784991f99ca4832f49b4d368abed9bba25220941025934b27327191adeda9fd47405a76
6
+ metadata.gz: c45bfd09a2a450c8621e5e7041396ad2a6e8fedded98ae22ea051cea2a1860c4af801fcce8c7f4d8ae003bf7f29ba9ecfdce5a1446f9a08548b4baed86265a0a
7
+ data.tar.gz: c6d39fdcf8d191a8ef92cd5668c9ab760e9899d939eb54bafaf75ddb231843ccb3422d16250889a1fee57b58ee4c9c51d90a1afa3ec11635b56cf40e79f05993
data/README.md CHANGED
@@ -10,6 +10,8 @@ Add this line to your application's Gemfile:
10
10
 
11
11
  gem 'utorrent-webapi-ruby', git: 'git@github.com:PeterWuMC/utorrent-webapi-ruby.git'
12
12
 
13
+ require 'u_torrent'
14
+
13
15
  ## Configuration
14
16
 
15
17
  ```ruby
@@ -34,6 +34,10 @@ module UTorrent
34
34
  @raw_array[3]
35
35
  end
36
36
 
37
+ def skip
38
+ send(:priority=, 0)
39
+ end
40
+
37
41
  def priority=(priority)
38
42
  UTorrent::Http.get_with_authentication(
39
43
  action: 'setprio',
@@ -1,3 +1,5 @@
1
+ require 'timeout'
2
+
1
3
  module UTorrent
2
4
  class Torrent
3
5
  STATUSES = {
@@ -21,7 +23,7 @@ module UTorrent
21
23
  :id, nil, :name, :size, nil, :downloaded, :uploaded, :ratio,
22
24
  :upload_speed, :download_speed, :eta, :label, :peers_connected,
23
25
  :peers_in_swarm, :seeds_connected, :seeds_in_swarm, :availability,
24
- :queue_order, :remaining, nil, nil, :status, nil, nil, nil, nil,
26
+ :queue_order, :remaining, :url, nil, :status, nil, nil, nil, nil,
25
27
  :current_directory, nil, nil, nil
26
28
  ]
27
29
 
@@ -40,11 +42,20 @@ module UTorrent
40
42
  def self.add(url)
41
43
  UTorrent::Http.get_with_authentication(
42
44
  action: 'add-url',
43
- s: url
45
+ s: url,
46
+ label: 'foobar'
44
47
  )
45
- all_torrents = UTorrent::Torrent.all
46
- max_queue_order = all_torrents.map(&:queue_order).max
47
- all_torrents.detect { |torrent| torrent.queue_order == max_queue_order }
48
+
49
+ Timeout.timeout(5) do
50
+ while(true) do
51
+ all_torrents = UTorrent::Torrent.all
52
+ matching_torrent = all_torrents.detect do |torrent|
53
+ torrent.url == url
54
+ end
55
+
56
+ return matching_torrent unless matching_torrent.nil?
57
+ end
58
+ end
48
59
  end
49
60
 
50
61
  def statuses
@@ -57,6 +68,16 @@ module UTorrent
57
68
  @raw_array[4].to_f / 10
58
69
  end
59
70
 
71
+ def label=(label)
72
+ UTorrent::Http.get_with_authentication(
73
+ action: 'setprops',
74
+ hash: id,
75
+ s: 'label',
76
+ v: label
77
+ )
78
+ refresh!
79
+ end
80
+
60
81
  def files
61
82
  response = UTorrent::Http.get_with_authentication(action: 'getfiles', hash: id)
62
83
  files_array = JSON.parse(response.body)['files'].last
@@ -1,3 +1,3 @@
1
1
  module UTorrent
2
- VERSION = '0.0.2.1'.freeze
2
+ VERSION = '0.0.3.1'.freeze
3
3
  end
@@ -19,5 +19,6 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ['lib']
21
21
 
22
+ spec.required_ruby_version = '~> 2.0'
22
23
  spec.add_dependency 'nokogiri', '~> 1.6.7.0'
23
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utorrent-webapi-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.1
4
+ version: 0.0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Wu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-29 00:00:00.000000000 Z
11
+ date: 2016-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -53,9 +53,9 @@ require_paths:
53
53
  - lib
54
54
  required_ruby_version: !ruby/object:Gem::Requirement
55
55
  requirements:
56
- - - ">="
56
+ - - "~>"
57
57
  - !ruby/object:Gem::Version
58
- version: '0'
58
+ version: '2.0'
59
59
  required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  requirements:
61
61
  - - ">="