ruby-fogbugz 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/fogbugz.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'ruby_fogbugz/adapters/http/typhoeus'
1
+ require 'ruby_fogbugz/adapters/http/net_http'
2
2
  require 'ruby_fogbugz/adapters/xml/cracker'
3
3
  require 'ruby_fogbugz/interface'
4
4
 
@@ -9,6 +9,6 @@ module Fogbugz
9
9
 
10
10
  self.adapter = {
11
11
  :xml => Adapter::XML::Cracker,
12
- :http => Adapter::HTTP::Typhoeuser
12
+ :http => Adapter::HTTP::NetHttp
13
13
  }
14
14
  end
@@ -0,0 +1,32 @@
1
+ require 'cgi'
2
+ require 'net/https'
3
+
4
+ module Fogbugz
5
+ module Adapter
6
+ module HTTP
7
+ class NetHttp
8
+ attr_accessor :root_url, :requester
9
+
10
+ def initialize(options = {})
11
+ @root_url = options[:uri]
12
+ end
13
+
14
+ def request(action, options)
15
+ # Convert the hash key/values to key=value&key2=value2 strings - CGI escaping along the way
16
+ options_string = options[:params].map{ |k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&')
17
+
18
+ url_string = "#{@root_url}/api.asp?cmd=#{action}&#{options_string}"
19
+ url = URI.parse(url_string)
20
+
21
+ request = Net::HTTP::Get.new(url_string, {"Content-Type"=>"text/xml"})
22
+
23
+ http = Net::HTTP.new(url.host, url.port)
24
+ http.use_ssl = @root_url.start_with? 'https'
25
+
26
+ response = http.start {|http| http.request(request) }
27
+ response.body
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -20,8 +20,17 @@ module Fogbugz
20
20
  :password => @options[:password]
21
21
  }
22
22
  }
23
-
24
- @token ||= @xml.parse(response)["token"]
23
+ begin
24
+ @token ||= @xml.parse(response)["token"]
25
+ if @token.nil? || @token == ''
26
+ throw Fogbugz::AuthenticationException.new(@xml.parse(response)["error"])
27
+ end
28
+ rescue REXML::ParseException => e
29
+ # Probably an issue with the auth information
30
+ # p response
31
+ throw Fogbugz::AuthenticationException.new("Looks like there was an issue with authentication (to #{@options[:uri]} as #{@options[:email]}) - probably the host/url.")
32
+ end
33
+ @token
25
34
  end
26
35
 
27
36
  def command(action, parameters = {})
@@ -35,4 +44,7 @@ module Fogbugz
35
44
  @xml.parse(response)
36
45
  end
37
46
  end
47
+
48
+ class AuthenticationException < Exception
49
+ end
38
50
  end
@@ -1,3 +1,3 @@
1
1
  module Fogbugz
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
data/ruby-fogbugz.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = "ruby-fogbugz"
16
16
 
17
- s.add_dependency('typhoeus')
17
+ # s.add_dependency('typhoeus')
18
18
  s.add_dependency('crack')
19
19
 
20
20
  s.add_development_dependency('minitest')
metadata CHANGED
@@ -1,94 +1,62 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ruby-fogbugz
3
- version: !ruby/object:Gem::Version
4
- hash: 23
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 4
10
- version: 0.0.4
11
6
  platform: ruby
12
- authors:
13
- - "Simon H\xC3\xB8rup Eskildsen"
7
+ authors:
8
+ - Simon Hørup Eskildsen
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-07-01 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: typhoeus
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
33
- type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
12
+ date: 2011-12-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
36
15
  name: crack
37
- prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
16
+ requirement: &70263146086620 !ruby/object:Gem::Requirement
39
17
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
47
22
  type: :runtime
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: minitest
51
23
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
24
+ version_requirements: *70263146086620
25
+ - !ruby/object:Gem::Dependency
26
+ name: minitest
27
+ requirement: &70263146102500 !ruby/object:Gem::Requirement
53
28
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
61
33
  type: :development
62
- version_requirements: *id003
63
- - !ruby/object:Gem::Dependency
64
- name: mocha
65
34
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
35
+ version_requirements: *70263146102500
36
+ - !ruby/object:Gem::Dependency
37
+ name: mocha
38
+ requirement: &70263146101820 !ruby/object:Gem::Requirement
67
39
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
75
44
  type: :development
76
- version_requirements: *id004
45
+ prerelease: false
46
+ version_requirements: *70263146101820
77
47
  description: A simple Ruby wrapper for the Fogbugz XML API
78
- email:
48
+ email:
79
49
  - sirup@sirupsen.com
80
50
  executables: []
81
-
82
51
  extensions: []
83
-
84
52
  extra_rdoc_files: []
85
-
86
- files:
53
+ files:
87
54
  - .gitignore
88
55
  - Gemfile
89
56
  - README.md
90
57
  - Rakefile
91
58
  - lib/fogbugz.rb
59
+ - lib/ruby_fogbugz/adapters/http/net_http.rb
92
60
  - lib/ruby_fogbugz/adapters/http/typhoeus.rb
93
61
  - lib/ruby_fogbugz/adapters/xml/cracker.rb
94
62
  - lib/ruby_fogbugz/interface.rb
@@ -98,41 +66,31 @@ files:
98
66
  - test/adapters/xml/crack_test.rb
99
67
  - test/interface_test.rb
100
68
  - test/test_helper.rb
101
- has_rdoc: true
102
- homepage: ""
69
+ homepage: ''
103
70
  licenses: []
104
-
105
71
  post_install_message:
106
72
  rdoc_options: []
107
-
108
- require_paths:
73
+ require_paths:
109
74
  - lib
110
- required_ruby_version: !ruby/object:Gem::Requirement
75
+ required_ruby_version: !ruby/object:Gem::Requirement
111
76
  none: false
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- hash: 3
116
- segments:
117
- - 0
118
- version: "0"
119
- required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
82
  none: false
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- hash: 3
125
- segments:
126
- - 0
127
- version: "0"
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
128
87
  requirements: []
129
-
130
88
  rubyforge_project: ruby-fogbugz
131
- rubygems_version: 1.5.2
89
+ rubygems_version: 1.8.11
132
90
  signing_key:
133
91
  specification_version: 3
134
92
  summary: Ruby wrapper for the Fogbugz API
135
- test_files:
93
+ test_files:
136
94
  - test/adapters/http/typhoeus_test.rb
137
95
  - test/adapters/xml/crack_test.rb
138
96
  - test/interface_test.rb