Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update for API-compat with 0.4.9 onwards

  • Loading branch information...
commit 94967740fcd21f178904ce03bfb984af2da8afc9 1 parent 33accfa
@Sutto authored
Showing with 43 additions and 24 deletions.
  1. +0 −9 Rakefile
  2. +24 −5 SABnzbd.gemspec
  3. +1 −1  VERSION.yml
  4. +18 −9 lib/sabnzbd.rb
View
9 Rakefile
@@ -1,7 +1,6 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
-require 'rcov/rcovtask'
begin
require 'jeweler'
@@ -32,11 +31,3 @@ Rake::RDocTask.new do |rdoc|
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
-
-Rcov::RcovTask.new do |t|
- t.libs << "test"
- t.test_files = FileList['test/**/*_test.rb']
- t.verbose = true
-end
-
-task :default => :rcov
View
29 SABnzbd.gemspec
@@ -1,23 +1,42 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE
+# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{SABnzbd}
- s.version = "0.2.0"
+ s.version = "0.3.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Darcy Laycock"]
- s.date = %q{2009-01-08}
+ s.date = %q{2009-08-07}
s.description = %q{Ruby interface to the SABnzbd usenet client}
s.email = %q{sutto@sutto.net}
- s.files = ["SABnzbd.gemspec", "VERSION.yml", "example/simple.rb", "lib/sabnzbd.rb", "test/sabnzbd_test.rb", "test/test_helper.rb"]
+ s.extra_rdoc_files = [
+ "LICENSE",
+ "README"
+ ]
+ s.files = [
+ "SABnzbd.gemspec",
+ "VERSION.yml",
+ "example/simple.rb",
+ "lib/sabnzbd.rb",
+ "test/sabnzbd_test.rb",
+ "test/test_helper.rb"
+ ]
s.homepage = %q{http://github.com/Sutto/SABnzbd}
+ s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.1}
+ s.rubygems_version = %q{1.3.5}
s.summary = %q{Ruby interface to the SABnzbd usenet client}
+ s.test_files = [
+ "test/sabnzbd_test.rb",
+ "test/test_helper.rb"
+ ]
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 2
+ s.specification_version = 3
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<httparty>, [">= 0"])
View
2  VERSION.yml
@@ -1,4 +1,4 @@
---
patch: 0
major: 0
-minor: 2
+minor: 3
View
27 lib/sabnzbd.rb
@@ -57,15 +57,17 @@ def parse_time(hash)
include HTTParty
base_uri 'localhost:8080'
- def initialize(username = '', password = '')
- login(username, password)
+ def initialize(auth = {})
+ @auth_params = {}
+ login(auth)
end
- def login(username, password)
+ def login(auth = {})
opts = {}
- opts[:ma_username] = username unless username.blank?
- opts[:ma_password] = password unless password.blank?
- self.class.default_params(opts)
+ opts[:ma_username] = auth[:username] if auth.has_key?(:username)
+ opts[:ma_password] = auth[:password] if auth.has_key?(:password)
+ opts[:apikey] = auth[:api_key] if auth.has_key?(:api_key)
+ @auth_params = opts
end
def status
@@ -109,8 +111,9 @@ def add_newzbin(id, category = nil, job_options = nil, script = nil)
end
def api_call(mode, opts = {})
- opts.merge!(:mode => mode.to_s)
- return self.class.get("/sabnzbd/api", :query => opts)
+ opts = opts.merge(:mode => mode.to_s).merge(@auth_params)
+ result = self.class.get("/sabnzbd/api", :query => opts)
+ return result
end
def verify(text)
@@ -140,7 +143,13 @@ def settings
def local
s = self.settings
base_uri "#{s["misc"]["host"]}:#{s["misc"]["port"]}"
- self.new(s["misc"]["username"], s["misc"]["password"])
+ use_api_key = s["misc"]["disable_api_key"] == "0"
+ opts = {
+ :username => s["misc"]["username"],
+ :password => s["misc"]["password"],
+ }
+ opts.merge!(:api_key => s["misc"]["api_key"]) unless s["misc"]["disable_api_key"] == "1"
+ self.new(opts)
end
protected
Please sign in to comment.
Something went wrong with that request. Please try again.