bicho 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -176,12 +176,16 @@ module Bicho
176
176
  case response
177
177
  when Net::HTTPSuccess
178
178
  bugs = []
179
- xml = Nokogiri::XML.parse(response.body)
180
- xml.root.xpath("//xmlns:entry/xmlns:link/@href", xml.root.namespace).each do |attr|
181
- uri = URI.parse attr.value
182
- bugs << uri.query.split("=")[1]
179
+ begin
180
+ xml = Nokogiri::XML.parse(response.body)
181
+ xml.root.xpath("//xmlns:entry/xmlns:link/@href", xml.root.namespace).each do |attr|
182
+ uri = URI.parse attr.value
183
+ bugs << uri.query.split("=")[1]
184
+ end
185
+ return bugs
186
+ rescue Nokogiri::XML::XPath::SyntaxError
187
+ raise "Named query '#{what}' not found"
183
188
  end
184
- return bugs
185
189
  when Net::HTTPRedirect
186
190
  raise "HTTP redirect not supported in named_query"
187
191
  else
@@ -1,6 +1,6 @@
1
1
  #--
2
2
  # Copyright (c) 2011 SUSE LINUX Products GmbH
3
- #
3
+ # =>
4
4
  # Author: Duncan Mac-Vicar P. <dmacvicar@suse.de>
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining
@@ -40,22 +40,34 @@ module Bicho
40
40
  class Novell
41
41
 
42
42
  OSCRC_CREDENTIALS = "https://api.opensuse.org"
43
+ DEFAULT_OSCRC_PATH = File.join(ENV['HOME'], '.oscrc')
44
+
45
+ def self.oscrc_path=(path)
46
+ @oscrc_path = path
47
+ end
48
+
49
+ def self.oscrc_path
50
+ @oscrc_path ||= DEFAULT_OSCRC_PATH
51
+ end
43
52
 
44
53
  def to_s
45
- self.class.to_s
54
+ self.class.to_s
46
55
  end
47
56
 
48
- def self.oscrc_credentials
49
- oscrc = IniFile.new(File.join(ENV['HOME'], '.oscrc'))
50
- if oscrc.has_section?(OSCRC_CREDENTIALS)
51
- user = oscrc[OSCRC_CREDENTIALS]['user']
52
- pass = oscrc[OSCRC_CREDENTIALS]['pass']
53
- if user && pass
54
- return {:user => user, :password => pass}
55
- else
56
- raise "No .oscrc credentials for bnc"
57
+ def self.oscrc_credentials
58
+ oscrc = IniFile.new(oscrc_path)
59
+ urls = [OSCRC_CREDENTIALS]
60
+ urls << "#{OSCRC_CREDENTIALS}/" if not OSCRC_CREDENTIALS.end_with?('/')
61
+ urls.each do |section|
62
+ if oscrc.has_section?(section)
63
+ user = oscrc[section]['user']
64
+ pass = oscrc[section]['pass']
65
+ if user && pass
66
+ return {:user => user, :password => pass}
67
+ end
57
68
  end
58
69
  end
70
+ raise "No valid .oscrc credentials for bnc. #{user} #{pass}"
59
71
  end
60
72
 
61
73
  def transform_api_url_hook(url, logger)
@@ -32,6 +32,8 @@ module Bicho
32
32
  #
33
33
  class Query
34
34
 
35
+ include Enumerable
36
+
35
37
  # Iterates through the result of the current query.
36
38
  #
37
39
  # @note Requires Bicho.client to be set
@@ -1,3 +1,3 @@
1
1
  module Bicho
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require File.join(File.dirname(__FILE__), 'helper')
2
+ require 'bicho/plugins/novell'
2
3
 
3
4
  class NovellPlugin_test < Test::Unit::TestCase
4
5
 
@@ -14,4 +15,13 @@ class NovellPlugin_test < Test::Unit::TestCase
14
15
 
15
16
  end
16
17
 
18
+ def test_oscrc_parsing
19
+ Bicho::Plugins::Novell.oscrc_path = "/space/tmp/oscrc-uwe"
20
+ plugin = Bicho::Plugins::Novell.new
21
+ credentials = Bicho::Plugins::Novell.oscrc_credentials
22
+ assert_not_nil(credentials)
23
+ assert(credentials.has_key?(:user))
24
+ assert(credentials.has_key?(:password))
25
+ end
26
+
17
27
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bicho
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Duncan Mac-Vicar P.
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-02 00:00:00 +01:00
18
+ date: 2012-03-09 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  requirements: []
142
142
 
143
143
  rubyforge_project: bicho
144
- rubygems_version: 1.6.2
144
+ rubygems_version: 1.5.2
145
145
  signing_key:
146
146
  specification_version: 3
147
147
  summary: Library to access bugzilla