sabnzbd 0.1.1 → 0.2.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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -0,0 +1,117 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:8080/api?apikey=valid_key&mode=qstatus&output=json
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Date:
16
+ - Wed, 19 Dec 2012 10:23:37 GMT
17
+ Content-Length:
18
+ - '425'
19
+ Content-Type:
20
+ - application/json;charset=UTF-8
21
+ Pragma:
22
+ - no-cache
23
+ Server:
24
+ - CherryPy/3.2.0
25
+ body:
26
+ encoding: US-ASCII
27
+ string: ! '{"have_warnings":"1","jobs":[{"timeleft":"0:00:00","mb":23749.483629,"msgid":"","filename":"a_big_legal_file","mbleft":22281.559650,"id":"SABnzbd_nzo_k92LC_"}],"noofslots":1,"paused":true,"pause_int":"0","mbleft":22281.559650,"diskspace2":70.699986,"diskspace1":70.699986,"speed":"0
28
+ ","timeleft":"0:00:00","mb":23749.483629,"state":"PAUSED","loadavg":"","kbpersec":0.000000}'
29
+ http_version:
30
+ recorded_at: Wed, 19 Dec 2012 10:23:37 GMT
31
+ - request:
32
+ method: get
33
+ uri: http://localhost:8080/api?apikey=valid_key&mode=qstatus&output=json
34
+ body:
35
+ encoding: US-ASCII
36
+ string: ''
37
+ headers: {}
38
+ response:
39
+ status:
40
+ code: 200
41
+ message: OK
42
+ headers:
43
+ Date:
44
+ - Wed, 19 Dec 2012 10:34:06 GMT
45
+ Content-Length:
46
+ - '425'
47
+ Content-Type:
48
+ - application/json;charset=UTF-8
49
+ Pragma:
50
+ - no-cache
51
+ Server:
52
+ - CherryPy/3.2.0
53
+ body:
54
+ encoding: US-ASCII
55
+ string: ! '{"have_warnings":"7","jobs":[{"timeleft":"0:00:00","mb":23749.483629,"msgid":"","filename":"a_big_legal_file","mbleft":22281.559650,"id":"SABnzbd_nzo_k92LC_"}],"noofslots":1,"paused":true,"pause_int":"0","mbleft":22281.559650,"diskspace2":70.698376,"diskspace1":70.698376,"speed":"0
56
+ ","timeleft":"0:00:00","mb":23749.483629,"state":"PAUSED","loadavg":"","kbpersec":0.000000}'
57
+ http_version:
58
+ recorded_at: Wed, 19 Dec 2012 10:34:06 GMT
59
+ - request:
60
+ method: get
61
+ uri: http://localhost:8080/api?apikey=valid_key&mode=qstatus&output=json
62
+ body:
63
+ encoding: US-ASCII
64
+ string: ''
65
+ headers: {}
66
+ response:
67
+ status:
68
+ code: 200
69
+ message: OK
70
+ headers:
71
+ Date:
72
+ - Wed, 19 Dec 2012 14:48:51 GMT
73
+ Content-Length:
74
+ - '425'
75
+ Content-Type:
76
+ - application/json;charset=UTF-8
77
+ Pragma:
78
+ - no-cache
79
+ Server:
80
+ - CherryPy/3.2.0
81
+ body:
82
+ encoding: US-ASCII
83
+ string: ! '{"have_warnings":"0","jobs":[{"timeleft":"0:00:00","mb":23749.483629,"msgid":"","filename":"a_big_legal_file","mbleft":13414.808467,"id":"SABnzbd_nzo_k92LC_"}],"noofslots":1,"paused":true,"pause_int":"0","mbleft":13414.808467,"diskspace2":62.491737,"diskspace1":62.491737,"speed":"0
84
+ ","timeleft":"0:00:00","mb":23749.483629,"state":"PAUSED","loadavg":"","kbpersec":0.000000}'
85
+ http_version:
86
+ recorded_at: Wed, 19 Dec 2012 14:48:51 GMT
87
+ - request:
88
+ method: get
89
+ uri: http://localhost:8080/api?apikey=valid_key&limit=LIMIT&mode=queue&output=json&start=START
90
+ body:
91
+ encoding: US-ASCII
92
+ string: ''
93
+ headers: {}
94
+ response:
95
+ status:
96
+ code: 200
97
+ message: OK
98
+ headers:
99
+ Date:
100
+ - Wed, 19 Dec 2012 14:49:03 GMT
101
+ Content-Length:
102
+ - '1555'
103
+ Content-Type:
104
+ - application/json;charset=UTF-8
105
+ Pragma:
106
+ - no-cache
107
+ Server:
108
+ - CherryPy/3.2.0
109
+ body:
110
+ encoding: US-ASCII
111
+ string: ! '{"queue":{"active_lang":"en","session":"valid_key","slots":[{"status":"Queued","index":0,"eta":"unknown","missing":0,"avg_age":"57d","script":"None","msgid":"","verbosity":"","mb":"23749.48","sizeleft":"13.1
112
+ GB","filename":"a_big_legal_file","priority":"Normal","cat":"*","mbleft":"13414.81","timeleft":"0:00:00","percentage":"43","nzo_id":"SABnzbd_nzo_k92LC_","unpackopts":"3","size":"23.2
113
+ GB"}],"speed":"0 ","size":"23.2 GB","limit":0,"start":0,"diskspacetotal2":"232.44","darwin":true,"last_warning":"","have_warnings":"0","noofslots":1,"newzbin_url":"www.newzbin2.es","pause_int":"0","categories":["*","anime","apps","books","consoles","emulation","games","misc","movies","music","pda","resources","tv","unknown"],"diskspacetotal1":"232.44","mb":"23749.48","loadavg":"","cache_max":"0","speedlimit":"","webdir":"/Applications/SABnzbd.app/Contents/Resources/interfaces/Plush/templates","paused":true,"isverbose":false,"restart_req":false,"power_options":true,"helpuri":"http://wiki.sabnzbd.org/","uptime":"4d","refresh_rate":"","version":"0.6.15","color_scheme":"gold","new_release":"0.7.6","nt":false,"status":"Paused","finish":0,"cache_art":"0","paused_all":false,"finishaction":null,"sizeleft":"13.1
114
+ GB","cache_size":"0 B","mbleft":"13414.81","diskspace2":"62.49","diskspace1":"62.49","scripts":[],"timeleft":"0:00:00","nzb_quota":"","eta":"unknown","kbpersec":"0.00","new_rel_url":"http://sourceforge.net/projects/sabnzbdplus/files/sabnzbdplus/0.7.6/","queue_details":"0"}}'
115
+ http_version:
116
+ recorded_at: Wed, 19 Dec 2012 14:49:03 GMT
117
+ recorded_with: VCR 2.3.0
@@ -0,0 +1,35 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:8080/api?apikey=valid_key&limit=LIMIT&mode=queue&output=json&start=START
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Date:
16
+ - Mon, 24 Dec 2012 10:15:55 GMT
17
+ Content-Length:
18
+ - '1952'
19
+ Content-Type:
20
+ - application/json;charset=UTF-8
21
+ Pragma:
22
+ - no-cache
23
+ Server:
24
+ - CherryPy/3.2.0
25
+ body:
26
+ encoding: US-ASCII
27
+ string: ! '{"queue":{"active_lang":"en","session":"valid_key","slots":[{"status":"Queued","index":0,"eta":"unknown","missing":0,"avg_age":"62d","script":"None","msgid":"","verbosity":"","mb":"15136.44","sizeleft":"12.9
28
+ GB","filename":"a_big_legal_file","priority":"High","cat":"*","mbleft":"13260.72","timeleft":"0:00:00","percentage":"12","nzo_id":"id_1","unpackopts":"3","size":"14.8
29
+ GB"},{"status":"Queued","index":1,"eta":"unknown","missing":0,"avg_age":"7h","script":"None","msgid":"","verbosity":"","mb":"103.92","sizeleft":"104
30
+ MB","filename":"a_smaller_legal_file","priority":"High","cat":"tv","mbleft":"103.92","timeleft":"0:00:00","percentage":"0","nzo_id":"id_2","unpackopts":"3","size":"104
31
+ MB"}],"speed":"0 ","size":"14.9 GB","limit":0,"start":0,"diskspacetotal2":"232.44","darwin":true,"last_warning":"","have_warnings":"1","noofslots":2,"newzbin_url":"www.newzbin2.es","pause_int":"0","categories":["*","anime","apps","books","consoles","emulation","games","misc","movies","music","pda","resources","tv","unknown"],"diskspacetotal1":"232.44","mb":"15240.36","loadavg":"","cache_max":"0","speedlimit":"","webdir":"/Applications/SABnzbd.app/Contents/Resources/interfaces/Plush/templates","paused":true,"isverbose":false,"restart_req":false,"power_options":true,"helpuri":"http://wiki.sabnzbd.org/","uptime":"8d","refresh_rate":"","version":"0.6.15","color_scheme":"gold","new_release":"0.7.7","nt":false,"status":"Paused","finish":0,"cache_art":"0","paused_all":false,"finishaction":null,"sizeleft":"13.1
32
+ GB","cache_size":"0 B","mbleft":"13364.64","diskspace2":"48.77","diskspace1":"48.77","scripts":[],"timeleft":"0:00:00","nzb_quota":"","eta":"unknown","kbpersec":"0.00","new_rel_url":"http://sourceforge.net/projects/sabnzbdplus/files/sabnzbdplus/0.7.7/","queue_details":"0"}}'
33
+ http_version:
34
+ recorded_at: Mon, 24 Dec 2012 10:15:55 GMT
35
+ recorded_with: VCR 2.3.0
@@ -0,0 +1,98 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:8080/api?apikey=valid_key&limit=LIMIT&mode=queue&output=json&start=START
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers: {}
10
+ response:
11
+ status:
12
+ code: 200
13
+ message: OK
14
+ headers:
15
+ Date:
16
+ - Mon, 24 Dec 2012 10:48:02 GMT
17
+ Content-Length:
18
+ - '1952'
19
+ Content-Type:
20
+ - application/json;charset=UTF-8
21
+ Pragma:
22
+ - no-cache
23
+ Server:
24
+ - CherryPy/3.2.0
25
+ body:
26
+ encoding: US-ASCII
27
+ string: ! '{"queue":{"active_lang":"en","session":"valid_key","slots":[{"status":"Queued","index":0,"eta":"unknown","missing":0,"avg_age":"62d","script":"None","msgid":"","verbosity":"","mb":"15136.44","sizeleft":"12.9
28
+ GB","filename":"a_big_legal_file","priority":"High","cat":"*","mbleft":"13260.72","timeleft":"0:00:00","percentage":"12","nzo_id":"id_1","unpackopts":"3","size":"14.8
29
+ GB"},{"status":"Queued","index":1,"eta":"unknown","missing":0,"avg_age":"8h","script":"None","msgid":"","verbosity":"","mb":"103.92","sizeleft":"104
30
+ MB","filename":"a_smaller_legal_file","priority":"High","cat":"tv","mbleft":"103.92","timeleft":"0:00:00","percentage":"0","nzo_id":"id_2","unpackopts":"3","size":"104
31
+ MB"}],"speed":"0 ","size":"14.9 GB","limit":0,"start":0,"diskspacetotal2":"232.44","darwin":true,"last_warning":"","have_warnings":"0","noofslots":2,"newzbin_url":"www.newzbin2.es","pause_int":"0","categories":["*","anime","apps","books","consoles","emulation","games","misc","movies","music","pda","resources","tv","unknown"],"diskspacetotal1":"232.44","mb":"15240.36","loadavg":"","cache_max":"0","speedlimit":"","webdir":"/Applications/SABnzbd.app/Contents/Resources/interfaces/Plush/templates","paused":true,"isverbose":false,"restart_req":false,"power_options":true,"helpuri":"http://wiki.sabnzbd.org/","uptime":"8d","refresh_rate":"","version":"0.6.15","color_scheme":"gold","new_release":"0.7.7","nt":false,"status":"Paused","finish":0,"cache_art":"0","paused_all":false,"finishaction":null,"sizeleft":"13.1
32
+ GB","cache_size":"0 B","mbleft":"13364.64","diskspace2":"48.77","diskspace1":"48.77","scripts":[],"timeleft":"0:00:00","nzb_quota":"","eta":"unknown","kbpersec":"0.00","new_rel_url":"http://sourceforge.net/projects/sabnzbdplus/files/sabnzbdplus/0.7.7/","queue_details":"0"}}'
33
+ http_version:
34
+ recorded_at: Mon, 24 Dec 2012 10:48:02 GMT
35
+ - request:
36
+ method: get
37
+ uri: http://localhost:8080/api?apikey=valid_key&mode=switch&value=id_1&value2=id_2
38
+ body:
39
+ encoding: US-ASCII
40
+ string: ''
41
+ headers: {}
42
+ response:
43
+ status:
44
+ code: 200
45
+ message: OK
46
+ headers:
47
+ Date:
48
+ - Mon, 24 Dec 2012 10:48:02 GMT
49
+ Content-Length:
50
+ - '4'
51
+ Content-Type:
52
+ - text/plain;charset=utf-8
53
+ Pragma:
54
+ - no-cache
55
+ Server:
56
+ - CherryPy/3.2.0
57
+ body:
58
+ encoding: US-ASCII
59
+ string: ! '1 1
60
+
61
+ '
62
+ http_version:
63
+ recorded_at: Mon, 24 Dec 2012 10:48:02 GMT
64
+ - request:
65
+ method: get
66
+ uri: http://localhost:8080/api?apikey=valid_key&limit=LIMIT&mode=queue&output=json&start=START
67
+ body:
68
+ encoding: US-ASCII
69
+ string: ''
70
+ headers: {}
71
+ response:
72
+ status:
73
+ code: 200
74
+ message: OK
75
+ headers:
76
+ Date:
77
+ - Mon, 24 Dec 2012 10:48:02 GMT
78
+ Content-Length:
79
+ - '1952'
80
+ Content-Type:
81
+ - application/json;charset=UTF-8
82
+ Pragma:
83
+ - no-cache
84
+ Server:
85
+ - CherryPy/3.2.0
86
+ body:
87
+ encoding: US-ASCII
88
+ string: ! '{"queue":{"active_lang":"en","session":"valid_key","slots":[{"status":"Queued","index":0,"eta":"unknown","missing":0,"avg_age":"8h","script":"None","msgid":"","verbosity":"","mb":"103.92","sizeleft":"104
89
+ MB","filename":"a_smaller_legal_file","priority":"High","cat":"tv","mbleft":"103.92","timeleft":"0:00:00","percentage":"0","nzo_id":"id_2","unpackopts":"3","size":"104
90
+ MB"},{"status":"Queued","index":1,"eta":"unknown","missing":0,"avg_age":"62d","script":"None","msgid":"","verbosity":"","mb":"15136.44","sizeleft":"12.9
91
+ GB","filename":"a_big_legal_file","priority":"High","cat":"*","mbleft":"13260.72","timeleft":"0:00:00","percentage":"12","nzo_id":"id_1","unpackopts":"3","size":"14.8
92
+ GB"}],"speed":"0 ","size":"14.9 GB","limit":0,"start":0,"diskspacetotal2":"232.44","darwin":true,"last_warning":"2012-12-20
93
+ 13:27:21,632\nWARNING:\nInvalid NZB file bluray.nzb, skipping (reason=unclosed
94
+ token, line=29737)","have_warnings":"0","noofslots":2,"newzbin_url":"www.newzbin2.es","pause_int":"0","categories":["*","anime","apps","books","consoles","emulation","games","misc","movies","music","pda","resources","tv","unknown"],"diskspacetotal1":"232.44","mb":"15240.36","loadavg":"","cache_max":"0","speedlimit":"","webdir":"/Applications/SABnzbd.app/Contents/Resources/interfaces/Plush/templates","paused":true,"isverbose":false,"restart_req":false,"power_options":true,"helpuri":"http://wiki.sabnzbd.org/","uptime":"8d","refresh_rate":"","version":"0.6.15","color_scheme":"gold","new_release":"0.7.7","nt":false,"status":"Paused","finish":0,"cache_art":"0","paused_all":false,"finishaction":null,"sizeleft":"13.1
95
+ GB","cache_size":"0 B","mbleft":"13364.64","diskspace2":"48.77","diskspace1":"48.77","scripts":[],"timeleft":"0:00:00","nzb_quota":"","eta":"unknown","kbpersec":"0.00","new_rel_url":"http://sourceforge.net/projects/sabnzbdplus/files/sabnzbdplus/0.7.7/","queue_details":"0"}}'
96
+ http_version:
97
+ recorded_at: Mon, 24 Dec 2012 10:48:02 GMT
98
+ recorded_with: VCR 2.3.0
@@ -1,18 +1,20 @@
1
1
  require 'httparty'
2
2
  require 'sabnzbd/slot'
3
+ require 'sabnzbd/utils'
3
4
 
4
5
  class Sabnzbd
5
6
  attr_accessor :api_key, :base_uri
6
- attr_reader :slots
7
+ attr_reader :slots, :utils
7
8
  include HTTParty
8
9
 
9
10
  def initialize(args={})
10
11
  @api_key = args[:api_key] || (raise ApiKeyMissing.new, "Api key missing")
11
12
  @base_uri = args[:base_uri] || "localhost:8080"
12
13
  self.class.base_uri @base_uri
14
+ @utils = Sabnzbd::Utils.new(self)
13
15
  end
14
16
 
15
- def simple_queue
17
+ def advanced_queue
16
18
  make_request
17
19
  end
18
20
 
@@ -20,16 +22,20 @@ class Sabnzbd
20
22
  make_request["queue"]["paused"]
21
23
  end
22
24
 
23
- def slots
24
- @slots ||= initialize_slots
25
+ def speed
26
+ make_request["queue"]["speed"].strip
25
27
  end
26
28
 
27
- private
29
+ def slots(refresh=false)
30
+ refresh ? @slots = initialize_slots : @slots ||= initialize_slots
31
+ end
28
32
 
29
33
  def make_request(url = "/api?mode=queue&start=START&limit=LIMIT&output=json&apikey=#{@api_key}")
30
34
  verify_response( self.class.get(url).parsed_response )
31
35
  end
32
36
 
37
+ private
38
+
33
39
  def verify_response response
34
40
  raise ApiKeyInvalid.new, "Api key invalid #{@api_key}" if response["status"] == false && response["error"]
35
41
 
@@ -1,14 +1,26 @@
1
1
  class Sabnzbd
2
2
  class Slot
3
- attr_accessor :time_left, :mb, :msgid, :filename, :mb_left, :id
3
+ attr_accessor :filename, :average_age, :status, :category, :files_missing,
4
+ :position, :priority, :percentage_completed, :time_left, :eta,
5
+ :size, :size_left, :mb, :mb_left, :msgid, :nzo_id
4
6
 
5
7
  def initialize(args={})
6
- @time_left = args["timeleft"] || Time.now
7
- @mb = args["mb"] || 0.00
8
- @msgid = args["msgid"] || nil
9
- @filename = args["filename"] || "No filename"
10
- @mb_left = args["mbleft"] || 0.00
11
- @id = args["id"] || "-"
8
+ @filename = args["filename"] || "No filename"
9
+ @average_age = args["avg_age"] || "-"
10
+ @status = args["status"] || "No status"
11
+ @category = args["cat"] || "-"
12
+ @files_missing = args["missing"] || 0
13
+ @position = args["index"] || 0
14
+ @priority = args["priority"] || "-"
15
+ @percentage_completed = args["percentage"] ||
16
+ @time_left = args["timeleft"] || Time.now
17
+ @eta = args["eta"] || "-"
18
+ @size = args["size"] || "-"
19
+ @size_left = args["sizeleft"] || "-"
20
+ @mb = args["mb"] || 0.00
21
+ @mb_left = args["mbleft"] || 0.00
22
+ @msgid = args["msgid"] || nil
23
+ @nzo_id = args["nzo_id"] || "-"
12
24
  end
13
25
  end
14
26
  end
@@ -0,0 +1,22 @@
1
+ class Sabnzbd
2
+ class Utils
3
+ attr_accessor :sabnzbd
4
+
5
+ def initialize (parent)
6
+ @sabnzbd = parent
7
+ end
8
+
9
+ def slot_positions
10
+ return_hash = {}
11
+ sabnzbd.slots(true).each do |s|
12
+ return_hash[s.position] = s.nzo_id
13
+ end
14
+
15
+ return_hash
16
+ end
17
+
18
+ def switch(slot_a, slot_b)
19
+ sabnzbd.make_request("/api?mode=switch&value=#{slot_a.nzo_id}&value2=#{slot_b.nzo_id}&apikey=#{sabnzbd.api_key}")
20
+ end
21
+ end
22
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "sabnzbd"
8
- s.version = "0.1.1"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Daniel Zwijnenburg"]
12
- s.date = "2012-12-19"
12
+ s.date = "2012-12-24"
13
13
  s.description = "Ruby wrapper for the sabnzbd api. This gem can be used to gather status and download information from your sabnzb instance."
14
14
  s.email = "daniel@danielz.nl"
15
15
  s.extra_rdoc_files = [
@@ -26,16 +26,21 @@ Gem::Specification.new do |s|
26
26
  "README.rdoc",
27
27
  "Rakefile",
28
28
  "VERSION",
29
+ "fixtures/vcr_cassettes/advanced_queue.yml",
29
30
  "fixtures/vcr_cassettes/invalid_key.yml",
31
+ "fixtures/vcr_cassettes/multiple_slots_downloading.yml",
30
32
  "fixtures/vcr_cassettes/paused.yml",
31
33
  "fixtures/vcr_cassettes/simple_queue.yml",
32
34
  "fixtures/vcr_cassettes/slots.yml",
35
+ "fixtures/vcr_cassettes/switch_success.yml",
33
36
  "fixtures/vcr_cassettes/valid_key.yml",
34
37
  "lib/sabnzbd.rb",
35
38
  "lib/sabnzbd/slot.rb",
39
+ "lib/sabnzbd/utils.rb",
36
40
  "sabnzbd.gemspec",
37
41
  "spec/sabnzbd_spec.rb",
38
- "spec/spec_helper.rb"
42
+ "spec/spec_helper.rb",
43
+ "spec/utils_spec.rb"
39
44
  ]
40
45
  s.homepage = "http://github.com/DanielZwijnenburg/sabnzbd"
41
46
  s.licenses = ["MIT"]
@@ -38,7 +38,7 @@ describe "Sabnzbd" do
38
38
  end
39
39
 
40
40
  it "should raise an error" do
41
- expect {sabnzbd.simple_queue}.to raise_error(ApiKeyInvalid)
41
+ expect {sabnzbd.advanced_queue}.to raise_error(ApiKeyInvalid)
42
42
  end
43
43
 
44
44
  after do
@@ -65,14 +65,14 @@ describe "Sabnzbd" do
65
65
  end
66
66
  end
67
67
 
68
- describe "GET simple Queue output" do
68
+ describe "GET advanced Queue output" do
69
69
  let(:sabnzbd) {Sabnzbd.new({base_uri: Base_uri, api_key: "valid_key"})}
70
70
  before do
71
- VCR.insert_cassette 'simple queue', :record => :new_episodes
71
+ VCR.insert_cassette 'advanced queue', :record => :new_episodes
72
72
  end
73
73
 
74
- it "should get the simple queue" do
75
- sabnzbd.simple_queue.should be_an_instance_of(Hash)
74
+ it "should get the advanced queue" do
75
+ sabnzbd.advanced_queue.should be_an_instance_of(Hash)
76
76
  end
77
77
 
78
78
  after do
@@ -88,7 +88,19 @@ describe "Sabnzbd" do
88
88
 
89
89
  it "should have 1 slot that is downloading a_big_legal_file" do
90
90
  sabnzbd.slots.first.filename.should == "a_big_legal_file"
91
- end
91
+ end
92
+
93
+ it "should be queued" do
94
+ sabnzbd.slots.first.status.should == "Queued"
95
+ end
96
+
97
+ it "should have a speed of 0" do
98
+ sabnzbd.speed.should == "0"
99
+ end
100
+
101
+ it "should have a position of 0" do
102
+ sabnzbd.slots.first.position.should == 0
103
+ end
92
104
 
93
105
  after do
94
106
  VCR.eject_cassette
@@ -0,0 +1,37 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ describe "Sabnzbd::Utils" do
3
+ describe "Listing of download positions" do
4
+ let(:sabnzbd) {Sabnzbd.new({base_uri: "localhost:8080", api_key: "valid_key"})}
5
+ before do
6
+ VCR.insert_cassette 'multiple slots downloading', :record => :new_episodes
7
+ end
8
+
9
+ it "should be able to list download positions" do
10
+ sabnzbd.utils.slot_positions.should == {0 => "id_1", 1 => "id_2"}
11
+ end
12
+
13
+ after do
14
+ VCR.eject_cassette
15
+ end
16
+ end
17
+
18
+
19
+ describe "switching of download positions" do
20
+ let(:sabnzbd) {Sabnzbd.new({base_uri: "localhost:8080", api_key: "valid_key"})}
21
+ before do
22
+ VCR.insert_cassette 'switch success', :record => :new_episodes
23
+ end
24
+
25
+ it "should be able to switch download positions" do
26
+ first_slot = sabnzbd.slots.first
27
+ last_slot = sabnzbd.slots.last
28
+ sabnzbd.utils.switch(first_slot, last_slot)
29
+
30
+ sabnzbd.utils.slot_positions.should == {0 => "id_2", 1 => "id_1"}
31
+ end
32
+
33
+ after do
34
+ VCR.eject_cassette
35
+ end
36
+ end
37
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sabnzbd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-19 00:00:00.000000000 Z
12
+ date: 2012-12-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -173,16 +173,21 @@ files:
173
173
  - README.rdoc
174
174
  - Rakefile
175
175
  - VERSION
176
+ - fixtures/vcr_cassettes/advanced_queue.yml
176
177
  - fixtures/vcr_cassettes/invalid_key.yml
178
+ - fixtures/vcr_cassettes/multiple_slots_downloading.yml
177
179
  - fixtures/vcr_cassettes/paused.yml
178
180
  - fixtures/vcr_cassettes/simple_queue.yml
179
181
  - fixtures/vcr_cassettes/slots.yml
182
+ - fixtures/vcr_cassettes/switch_success.yml
180
183
  - fixtures/vcr_cassettes/valid_key.yml
181
184
  - lib/sabnzbd.rb
182
185
  - lib/sabnzbd/slot.rb
186
+ - lib/sabnzbd/utils.rb
183
187
  - sabnzbd.gemspec
184
188
  - spec/sabnzbd_spec.rb
185
189
  - spec/spec_helper.rb
190
+ - spec/utils_spec.rb
186
191
  homepage: http://github.com/DanielZwijnenburg/sabnzbd
187
192
  licenses:
188
193
  - MIT
@@ -198,7 +203,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
198
203
  version: '0'
199
204
  segments:
200
205
  - 0
201
- hash: 3295881341766727851
206
+ hash: -1744786666977324001
202
207
  required_rubygems_version: !ruby/object:Gem::Requirement
203
208
  none: false
204
209
  requirements: