Sutto-SABnzbd 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/LICENSE +20 -0
  2. data/README +9 -0
  3. data/SABnzbd.gemspec +24 -5
  4. data/VERSION.yml +1 -1
  5. data/lib/sabnzbd.rb +18 -9
  6. metadata +16 -10
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Darcy Laycock
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,9 @@
1
+ SABnzbd
2
+ =======
3
+
4
+ Ruby interface / api to SABnzbd
5
+
6
+ COPYRIGHT
7
+ =========
8
+
9
+ Copyright (c) 2008 Darcy Laycock. See LICENSE for details.
data/SABnzbd.gemspec CHANGED
@@ -1,23 +1,42 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{SABnzbd}
5
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Darcy Laycock"]
9
- s.date = %q{2009-01-08}
12
+ s.date = %q{2009-08-07}
10
13
  s.description = %q{Ruby interface to the SABnzbd usenet client}
11
14
  s.email = %q{sutto@sutto.net}
12
- s.files = ["SABnzbd.gemspec", "VERSION.yml", "example/simple.rb", "lib/sabnzbd.rb", "test/sabnzbd_test.rb", "test/test_helper.rb"]
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README"
18
+ ]
19
+ s.files = [
20
+ "SABnzbd.gemspec",
21
+ "VERSION.yml",
22
+ "example/simple.rb",
23
+ "lib/sabnzbd.rb",
24
+ "test/sabnzbd_test.rb",
25
+ "test/test_helper.rb"
26
+ ]
13
27
  s.homepage = %q{http://github.com/Sutto/SABnzbd}
28
+ s.rdoc_options = ["--charset=UTF-8"]
14
29
  s.require_paths = ["lib"]
15
- s.rubygems_version = %q{1.3.1}
30
+ s.rubygems_version = %q{1.3.5}
16
31
  s.summary = %q{Ruby interface to the SABnzbd usenet client}
32
+ s.test_files = [
33
+ "test/sabnzbd_test.rb",
34
+ "test/test_helper.rb"
35
+ ]
17
36
 
18
37
  if s.respond_to? :specification_version then
19
38
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
20
- s.specification_version = 2
39
+ s.specification_version = 3
21
40
 
22
41
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
23
42
  s.add_runtime_dependency(%q<httparty>, [">= 0"])
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  patch: 0
3
3
  major: 0
4
- minor: 2
4
+ minor: 3
data/lib/sabnzbd.rb CHANGED
@@ -57,15 +57,17 @@ class SABnzbd
57
57
  include HTTParty
58
58
  base_uri 'localhost:8080'
59
59
 
60
- def initialize(username = '', password = '')
61
- login(username, password)
60
+ def initialize(auth = {})
61
+ @auth_params = {}
62
+ login(auth)
62
63
  end
63
64
 
64
- def login(username, password)
65
+ def login(auth = {})
65
66
  opts = {}
66
- opts[:ma_username] = username unless username.blank?
67
- opts[:ma_password] = password unless password.blank?
68
- self.class.default_params(opts)
67
+ opts[:ma_username] = auth[:username] if auth.has_key?(:username)
68
+ opts[:ma_password] = auth[:password] if auth.has_key?(:password)
69
+ opts[:apikey] = auth[:api_key] if auth.has_key?(:api_key)
70
+ @auth_params = opts
69
71
  end
70
72
 
71
73
  def status
@@ -109,8 +111,9 @@ class SABnzbd
109
111
  end
110
112
 
111
113
  def api_call(mode, opts = {})
112
- opts.merge!(:mode => mode.to_s)
113
- return self.class.get("/sabnzbd/api", :query => opts)
114
+ opts = opts.merge(:mode => mode.to_s).merge(@auth_params)
115
+ result = self.class.get("/sabnzbd/api", :query => opts)
116
+ return result
114
117
  end
115
118
 
116
119
  def verify(text)
@@ -140,7 +143,13 @@ class SABnzbd
140
143
  def local
141
144
  s = self.settings
142
145
  base_uri "#{s["misc"]["host"]}:#{s["misc"]["port"]}"
143
- self.new(s["misc"]["username"], s["misc"]["password"])
146
+ use_api_key = s["misc"]["disable_api_key"] == "0"
147
+ opts = {
148
+ :username => s["misc"]["username"],
149
+ :password => s["misc"]["password"],
150
+ }
151
+ opts.merge!(:api_key => s["misc"]["api_key"]) unless s["misc"]["disable_api_key"] == "1"
152
+ self.new(opts)
144
153
  end
145
154
 
146
155
  protected
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Sutto-SABnzbd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darcy Laycock
@@ -9,11 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-08 00:00:00 -08:00
12
+ date: 2009-08-07 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
@@ -27,8 +28,9 @@ executables: []
27
28
 
28
29
  extensions: []
29
30
 
30
- extra_rdoc_files: []
31
-
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README
32
34
  files:
33
35
  - SABnzbd.gemspec
34
36
  - VERSION.yml
@@ -36,11 +38,14 @@ files:
36
38
  - lib/sabnzbd.rb
37
39
  - test/sabnzbd_test.rb
38
40
  - test/test_helper.rb
41
+ - LICENSE
42
+ - README
39
43
  has_rdoc: false
40
44
  homepage: http://github.com/Sutto/SABnzbd
45
+ licenses:
41
46
  post_install_message:
42
- rdoc_options: []
43
-
47
+ rdoc_options:
48
+ - --charset=UTF-8
44
49
  require_paths:
45
50
  - lib
46
51
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -58,9 +63,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
63
  requirements: []
59
64
 
60
65
  rubyforge_project:
61
- rubygems_version: 1.2.0
66
+ rubygems_version: 1.3.5
62
67
  signing_key:
63
- specification_version: 2
68
+ specification_version: 3
64
69
  summary: Ruby interface to the SABnzbd usenet client
65
- test_files: []
66
-
70
+ test_files:
71
+ - test/sabnzbd_test.rb
72
+ - test/test_helper.rb