fogbugz 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/bin/fogbugz-new CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rubygems'
4
- require 'typhoeus'
5
- require 'xml'
4
+ require 'net/https'
5
+ require 'uri'
6
+ require 'rexml/document'
6
7
  require 'tempfile'
7
8
  require 'optparse'
8
9
  require 'yaml'
@@ -15,7 +16,7 @@ unless api_url
15
16
  end
16
17
 
17
18
  api_token = ENV['FOGBUGZ_API_TOKEN']
18
- unless api_url
19
+ unless api_token
19
20
  puts "Environment variable FOGBUGZ_API_TOKEN must be set."
20
21
  exit 1
21
22
  end
@@ -26,11 +27,6 @@ options = {}
26
27
  optparse = OptionParser.new do |opts|
27
28
  opts.banner = "usage: #{File::basename(__FILE__)} [options] [-|files]"
28
29
 
29
- options[:verbose] = false
30
- opts.on('-v', '--verbose', 'Output verbose debugging information.') do
31
- options[:verbose] = true
32
- end
33
-
34
30
  opts.on_tail('-h', '--help') do
35
31
  puts optparse.help
36
32
  exit 1
@@ -134,32 +130,35 @@ if not data or data.empty?
134
130
  exit 1
135
131
  end
136
132
 
137
- response = Typhoeus::Request.get(api_url,
138
- :verbose => options[:verbose],
139
- :params => {
140
- :cmd => 'new',
141
- :token => api_token,
142
- :sTitle => data['title'],
143
- :ixBugParent => data['parent'],
144
- :sTags => data['tags'] ? data['tags'].join(',') : nil,
145
- :sProject => data['project'],
146
- :sArea => data['area'],
147
- :sFixFor => data['milestone'],
148
- :sCategory => data['category'],
149
- :sPersonAssignedTo => data['assignee'],
150
- :sPriority => data['priority'],
151
- :hrsCurrEst => data['estimate'],
152
- :sEvent => data['body'] })
153
- if response.code != 200
133
+ uri = URI format("#{api_url}?cmd=new&token=%s&%s%s%s%s%s%s%s%s%s%s%s",
134
+ URI.escape(api_token),
135
+ data['title'] ? URI.escape(data['title'].to_s) : '',
136
+ data['parent'] ? URI.escape(data['parent'].to_s) : '',
137
+ data['tags'] ? URI.escape(data['tags'].join(',')) : '',
138
+ data['project'] ? URI.escape(data['project'].to_s) : '',
139
+ data['area'] ? URI.escape(data['area'].to_s) : '',
140
+ data['milestone'] ? URI.escape(data['milestone'].to_s) : '',
141
+ data['category'] ? URI.escape(data['category'].to_s) : '',
142
+ data['assignee'] ? URI.escape(data['assignee'].to_s) : '',
143
+ data['priority'] ? URI.escape(data['priority'].to_s) : '',
144
+ data['estimate'] ? URI.escape(data['estimate'].to_s) : '',
145
+ data['body'] ? URI.escape(data['body'].to_s) : '')
146
+ http = Net::HTTP.new(uri.host, uri.port)
147
+ if uri.scheme == 'https'
148
+ http.use_ssl = true
149
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
150
+ end
151
+ response = http.start { |h| h.request Net::HTTP::Get.new(uri.request_uri) }
152
+ if response.code != '200'
154
153
  puts "HTTP request to #{api_url} failed with code #{response.code}."
155
154
  exit 1
156
155
  end
157
156
 
158
- result = XML::Parser.string(response.body).parse
159
- error = result.find_first('/response/error')
157
+ result = REXML::Document.new(response.body)
158
+ error = result.elements['/response/error']
160
159
  if error
161
- puts "Failed with error: #{error.content}."
160
+ puts "Failed with error: #{error.text}."
162
161
  exit 1
163
162
  end
164
163
 
165
- puts "Case #{result.find_first('/response/case')['ixBug']} created."
164
+ puts "Case #{result.elements['/response/case'].attributes['ixBug']} created."
data/bin/fogbugz-people CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rubygems'
4
- require 'typhoeus'
5
- require 'xml'
4
+ require 'net/https'
5
+ require 'uri'
6
+ require 'rexml/document'
6
7
  require 'optparse'
7
8
 
8
9
  api_url = ENV['FOGBUGZ_API_URL']
@@ -12,7 +13,7 @@ unless api_url
12
13
  end
13
14
 
14
15
  api_token = ENV['FOGBUGZ_API_TOKEN']
15
- unless api_url
16
+ unless api_token
16
17
  puts "Environment variable FOGBUGZ_API_TOKEN must be set."
17
18
  exit 1
18
19
  end
@@ -21,11 +22,6 @@ options = {}
21
22
  optparse = OptionParser.new do |opts|
22
23
  opts.banner = "usage: #{File::basename(__FILE__)} [options]"
23
24
 
24
- options[:verbose] = false
25
- opts.on('-v', '--verbose', 'Output verbose debugging information') do
26
- options[:verbose] = true
27
- end
28
-
29
25
  opts.on_tail('-h', '--help') do
30
26
  puts optparse.help
31
27
  exit 1
@@ -33,25 +29,27 @@ optparse = OptionParser.new do |opts|
33
29
  end
34
30
  optparse.parse!
35
31
 
36
- response = Typhoeus::Request.get(api_url,
37
- :verbose => options[:verbose],
38
- :params => {
39
- :cmd => 'listPeople',
40
- :token => api_token })
41
- if response.code != 200
32
+ uri = URI format("#{api_url}?cmd=listPeople&token=%s", URI.escape(api_token))
33
+ http = Net::HTTP.new(uri.host, uri.port)
34
+ if uri.scheme == 'https'
35
+ http.use_ssl = true
36
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
37
+ end
38
+ response = http.start { |h| h.request Net::HTTP::Get.new(uri.request_uri) }
39
+ if response.code != '200'
42
40
  puts "HTTP request to #{api_url} failed with code #{response.code}."
43
41
  exit 1
44
42
  end
45
43
 
46
- result = XML::Parser.string(response.body).parse
47
- error = result.find_first('/response/error')
44
+ result = REXML::Document.new(response.body)
45
+ error = result.elements['/response/error']
48
46
  if error
49
- puts "Failed with error: #{error.content}."
47
+ puts "Failed with error: #{error.text}."
50
48
  exit 1
51
49
  end
52
50
 
53
- result.find('/response/people/person').each do |status|
51
+ result.elements.each('/response/people/person') do |person|
54
52
  puts format("%-30.30s %s\n",
55
- status.find_first('sFullName').content,
56
- status.find_first('sEmail').content).strip!
53
+ person.elements['sFullName'].text,
54
+ person.elements['sEmail'].text).strip!
57
55
  end
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rubygems'
4
- require 'typhoeus'
5
- require 'xml'
4
+ require 'net/https'
5
+ require 'uri'
6
+ require 'rexml/document'
6
7
  require 'optparse'
7
8
 
8
9
  api_url = ENV['FOGBUGZ_API_URL']
@@ -12,7 +13,7 @@ unless api_url
12
13
  end
13
14
 
14
15
  api_token = ENV['FOGBUGZ_API_TOKEN']
15
- unless api_url
16
+ unless api_token
16
17
  puts "Environment variable FOGBUGZ_API_TOKEN must be set."
17
18
  exit 1
18
19
  end
@@ -21,11 +22,6 @@ options = {}
21
22
  optparse = OptionParser.new do |opts|
22
23
  opts.banner = "usage: #{File::basename(__FILE__)} [options]"
23
24
 
24
- options[:verbose] = false
25
- opts.on('-v', '--verbose', 'Output verbose debugging information') do
26
- options[:verbose] = true
27
- end
28
-
29
25
  opts.on_tail('-h', '--help') do
30
26
  puts optparse.help
31
27
  exit 1
@@ -33,23 +29,26 @@ optparse = OptionParser.new do |opts|
33
29
  end
34
30
  optparse.parse!
35
31
 
36
- response = Typhoeus::Request.get(api_url,
37
- :verbose => options[:verbose],
38
- :params => {
39
- :cmd => 'listPriorities',
40
- :token => api_token })
41
- if response.code != 200
32
+ uri = URI format("#{api_url}?cmd=listPriorities&token=%s",
33
+ URI.escape(api_token))
34
+ http = Net::HTTP.new(uri.host, uri.port)
35
+ if uri.scheme == 'https'
36
+ http.use_ssl = true
37
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
38
+ end
39
+ response = http.start { |h| h.request Net::HTTP::Get.new(uri.request_uri) }
40
+ if response.code != '200'
42
41
  puts "HTTP request to #{api_url} failed with code #{response.code}."
43
42
  exit 1
44
43
  end
45
44
 
46
- result = XML::Parser.string(response.body).parse
47
- error = result.find_first('/response/error')
45
+ result = REXML::Document.new(response.body)
46
+ error = result.elements['/response/error']
48
47
  if error
49
- puts "Failed with error: #{error.content}."
48
+ puts "Failed with error: #{error.text}."
50
49
  exit 1
51
50
  end
52
51
 
53
- result.find('/response/priorities/priority').each do |status|
54
- puts status.find_first('sPriority').content
52
+ result.elements.each('/response/priorities/priority') do |priority|
53
+ puts priority.elements['sPriority'].text
55
54
  end
data/bin/fogbugz-projects CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rubygems'
4
- require 'typhoeus'
5
- require 'xml'
4
+ require 'net/https'
5
+ require 'uri'
6
+ require 'rexml/document'
6
7
  require 'optparse'
7
8
 
8
9
  api_url = ENV['FOGBUGZ_API_URL']
@@ -12,7 +13,7 @@ unless api_url
12
13
  end
13
14
 
14
15
  api_token = ENV['FOGBUGZ_API_TOKEN']
15
- unless api_url
16
+ unless api_token
16
17
  puts "Environment variable FOGBUGZ_API_TOKEN must be set."
17
18
  exit 1
18
19
  end
@@ -21,11 +22,6 @@ options = {}
21
22
  optparse = OptionParser.new do |opts|
22
23
  opts.banner = "usage: #{File::basename(__FILE__)} [options]"
23
24
 
24
- options[:verbose] = false
25
- opts.on('-v', '--verbose', 'Output verbose debugging information') do
26
- options[:verbose] = true
27
- end
28
-
29
25
  opts.on_tail('-h', '--help') do
30
26
  puts optparse.help
31
27
  exit 1
@@ -33,25 +29,27 @@ optparse = OptionParser.new do |opts|
33
29
  end
34
30
  optparse.parse!
35
31
 
36
- response = Typhoeus::Request.get(api_url,
37
- :verbose => options[:verbose],
38
- :params => {
39
- :cmd => 'listProjects',
40
- :token => api_token })
41
- if response.code != 200
32
+ uri = URI format("#{api_url}?cmd=listProjects&token=%s", URI.escape(api_token))
33
+ http = Net::HTTP.new(uri.host, uri.port)
34
+ if uri.scheme == 'https'
35
+ http.use_ssl = true
36
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
37
+ end
38
+ response = http.start { |h| h.request Net::HTTP::Get.new(uri.request_uri) }
39
+ if response.code != '200'
42
40
  puts "HTTP request to #{api_url} failed with code #{response.code}."
43
41
  exit 1
44
42
  end
45
43
 
46
- result = XML::Parser.string(response.body).parse
47
- error = result.find_first('/response/error')
44
+ result = REXML::Document.new(response.body)
45
+ error = result.elements['/response/error']
48
46
  if error
49
- puts "Failed with error: #{error.content}."
47
+ puts "Failed with error: #{error.text}."
50
48
  exit 1
51
49
  end
52
50
 
53
- result.find('/response/projects/project').each do |status|
51
+ result.elements.each('/response/projects/project') do |project|
54
52
  puts format("%-20.20s %s\n",
55
- status.find_first('sPersonOwner').content,
56
- status.find_first('sProject').content).strip!
53
+ project.elements['sPersonOwner'].text,
54
+ project.elements['sProject'].text).strip!
57
55
  end
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rubygems'
4
- require 'typhoeus'
5
- require 'xml'
4
+ require 'net/https'
5
+ require 'uri'
6
+ require 'rexml/document'
6
7
  require 'optparse'
7
8
 
8
9
  api_url = ENV['FOGBUGZ_API_URL']
@@ -12,7 +13,7 @@ unless api_url
12
13
  end
13
14
 
14
15
  api_token = ENV['FOGBUGZ_API_TOKEN']
15
- unless api_url
16
+ unless api_token
16
17
  puts "Environment variable FOGBUGZ_API_TOKEN must be set."
17
18
  exit 1
18
19
  end
@@ -21,11 +22,6 @@ options = {}
21
22
  optparse = OptionParser.new do |opts|
22
23
  opts.banner = "usage: #{File::basename(__FILE__)} [options] <case>"
23
24
 
24
- options[:verbose] = false
25
- opts.on('-v', '--verbose', 'Output verbose debugging information.') do
26
- options[:verbose] = true
27
- end
28
-
29
25
  opts.on_tail('-h', '--help') do
30
26
  puts optparse.help
31
27
  exit 1
@@ -37,20 +33,22 @@ unless ARGV[0]
37
33
  exit 1
38
34
  end
39
35
 
40
- response = Typhoeus::Request.get(api_url,
41
- :verbose => options[:verbose],
42
- :params => {
43
- :cmd => 'reactivate',
44
- :token => api_token,
45
- :ixBug => ARGV[0] })
46
- if response.code != 200
36
+ uri = URI format("#{api_url}?cmd=reactivate&token=%s&ixBug=%s",
37
+ URI.escape(api_token), URI.escape(ARGV[0]))
38
+ http = Net::HTTP.new(uri.host, uri.port)
39
+ if uri.scheme == 'https'
40
+ http.use_ssl = true
41
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
42
+ end
43
+ response = http.start { |h| h.request Net::HTTP::Get.new(uri.request_uri) }
44
+ if response.code != '200'
47
45
  puts "HTTP request to #{api_url} failed with code #{response.code}."
48
46
  exit 1
49
47
  end
50
48
 
51
- result = XML::Parser.string(response.body).parse
52
- error = result.find_first('/response/error')
49
+ result = REXML::Document.new(response.body)
50
+ error = result.elements['/response/error']
53
51
  if error
54
- puts "Failed with error: #{error.content}."
52
+ puts "Failed with error: #{error.text}."
55
53
  exit 1
56
54
  end
data/bin/fogbugz-reopen CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rubygems'
4
- require 'typhoeus'
5
- require 'xml'
4
+ require 'net/https'
5
+ require 'uri'
6
+ require 'rexml/document'
6
7
  require 'optparse'
7
8
 
8
9
  api_url = ENV['FOGBUGZ_API_URL']
@@ -12,7 +13,7 @@ unless api_url
12
13
  end
13
14
 
14
15
  api_token = ENV['FOGBUGZ_API_TOKEN']
15
- unless api_url
16
+ unless api_token
16
17
  puts "Environment variable FOGBUGZ_API_TOKEN must be set."
17
18
  exit 1
18
19
  end
@@ -21,11 +22,6 @@ options = {}
21
22
  optparse = OptionParser.new do |opts|
22
23
  opts.banner = "usage: #{File::basename(__FILE__)} [options] <case>"
23
24
 
24
- options[:verbose] = false
25
- opts.on('-v', '--verbose', 'Output verbose debugging information.') do
26
- options[:verbose] = true
27
- end
28
-
29
25
  opts.on_tail('-h', '--help') do
30
26
  puts optparse.help
31
27
  exit 1
@@ -37,20 +33,22 @@ unless ARGV[0]
37
33
  exit 1
38
34
  end
39
35
 
40
- response = Typhoeus::Request.get(api_url,
41
- :verbose => options[:verbose],
42
- :params => {
43
- :cmd => 'reopen',
44
- :token => api_token,
45
- :ixBug => ARGV[0] })
46
- if response.code != 200
36
+ uri = URI format("#{api_url}?cmd=reopen&token=%s&ixBug=%s",
37
+ URI.escape(api_token), URI.escape(ARGV[0]))
38
+ http = Net::HTTP.new(uri.host, uri.port)
39
+ if uri.scheme == 'https'
40
+ http.use_ssl = true
41
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
42
+ end
43
+ response = http.start { |h| h.request Net::HTTP::Get.new(uri.request_uri) }
44
+ if response.code != '200'
47
45
  puts "HTTP request to #{api_url} failed with code #{response.code}."
48
46
  exit 1
49
47
  end
50
48
 
51
- result = XML::Parser.string(response.body).parse
52
- error = result.find_first('/response/error')
49
+ result = REXML::Document.new(response.body)
50
+ error = result.elements['/response/error']
53
51
  if error
54
- puts "Failed with error: #{error.content}."
52
+ puts "Failed with error: #{error.text}."
55
53
  exit 1
56
54
  end
data/bin/fogbugz-resolve CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rubygems'
4
- require 'typhoeus'
5
- require 'xml'
4
+ require 'net/https'
5
+ require 'uri'
6
+ require 'rexml/document'
6
7
  require 'optparse'
7
8
 
8
9
  api_url = ENV['FOGBUGZ_API_URL']
@@ -12,7 +13,7 @@ unless api_url
12
13
  end
13
14
 
14
15
  api_token = ENV['FOGBUGZ_API_TOKEN']
15
- unless api_url
16
+ unless api_token
16
17
  puts "Environment variable FOGBUGZ_API_TOKEN must be set."
17
18
  exit 1
18
19
  end
@@ -21,11 +22,6 @@ options = {}
21
22
  optparse = OptionParser.new do |opts|
22
23
  opts.banner = "usage: #{File::basename(__FILE__)} [options] <case> <status>"
23
24
 
24
- options[:verbose] = false
25
- opts.on('-v', '--verbose', 'Output verbose debugging information.') do
26
- options[:verbose] = true
27
- end
28
-
29
25
  opts.on_tail('-h', '--help') do
30
26
  puts optparse.help
31
27
  exit 1
@@ -37,46 +33,50 @@ unless ARGV.length == 2
37
33
  exit 1
38
34
  end
39
35
 
40
- response = Typhoeus::Request.get(api_url,
41
- :verbose => options[:verbose],
42
- :params => {
43
- :cmd => 'listStatuses',
44
- :token => api_token,
45
- :fResolved => 1 })
46
- if response.code != 200
36
+ uri = URI format("#{api_url}?cmd=listStatuses&token=%s&fResolved=1",
37
+ URI.escape(api_token))
38
+ http = Net::HTTP.new(uri.host, uri.port)
39
+ if uri.scheme == 'https'
40
+ http.use_ssl = true
41
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
42
+ end
43
+ response = http.start { |h| h.request Net::HTTP::Get.new(uri.request_uri) }
44
+ if response.code != '200'
47
45
  puts "HTTP request to #{api_url} failed with code #{response.code}."
48
46
  exit 1
49
47
  end
50
48
 
51
- result = XML::Parser.string(response.body).parse
52
- error = result.find_first('/response/error')
49
+ result = REXML::Document.new(response.body)
50
+ error = result.elements['/response/error']
53
51
  if error
54
- puts "Failed with error: #{error.content}."
52
+ puts "Failed with error: #{error.text}."
55
53
  exit 1
56
54
  end
57
55
 
58
- status = result.find_first("/response/statuses/status[sStatus='#{ARGV[1]}']")
56
+ status = result.elements["/response/statuses/status[sStatus='#{ARGV[1]}']"]
59
57
 
60
58
  unless status
61
59
  puts "#{ARGV[1]} is not a resolved status."
62
60
  exit 1
63
61
  end
64
62
 
65
- response = Typhoeus::Request.get(api_url,
66
- :verbose => options[:verbose],
67
- :params => {
68
- :cmd => 'resolve',
69
- :token => api_token,
70
- :ixBug => ARGV[0],
71
- :ixStatus => status.find_first('ixStatus').content })
72
- if response.code != 200
63
+ uri = URI format("#{api_url}?cmd=resolve&token=%s&ixBug=%s&ixStatus=%s",
64
+ URI.escape(api_token), URI.escape(ARGV[0]),
65
+ URI.escape(status.elements['ixStatus'].text))
66
+ http = Net::HTTP.new(uri.host, uri.port)
67
+ if uri.scheme == 'https'
68
+ http.use_ssl = true
69
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
70
+ end
71
+ response = http.start { |h| h.request Net::HTTP::Get.new(uri.request_uri) }
72
+ if response.code != '200'
73
73
  puts "HTTP request to #{api_url} failed with code #{response.code}."
74
74
  exit 1
75
75
  end
76
76
 
77
- result = XML::Parser.string(response.body).parse
78
- error = result.find_first('/response/error')
77
+ result = REXML::Document.new(response.body)
78
+ error = result.elements['/response/error']
79
79
  if error
80
- puts "Failed with error: #{error.content}."
80
+ puts "Failed with error: #{error.text}."
81
81
  exit 1
82
82
  end