fogbugz 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/bin/fogbugz-filter 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] <filter>"
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,42 +33,49 @@ 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 => { :cmd => 'listFilters', :token => api_token })
43
- if response.code != 200
36
+ uri = URI format("#{api_url}?cmd=listFilters&token=%s", URI.escape(api_token))
37
+ http = Net::HTTP.new(uri.host, uri.port)
38
+ if uri.scheme == 'https'
39
+ http.use_ssl = true
40
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
41
+ end
42
+ response = http.start { |h| h.request Net::HTTP::Get.new(uri.request_uri) }
43
+ if response.code != '200'
44
44
  puts "HTTP request to #{api_url} failed with code #{response.code}."
45
45
  exit 1
46
46
  end
47
47
 
48
- result = XML::Parser.string(response.body).parse
49
- error = result.find_first('/response/error')
48
+ result = REXML::Document.new(response.body)
49
+ error = result.elements['/response/error']
50
50
  if error
51
- puts "Failed with error: #{error.content}."
51
+ puts "Failed with error: #{error.text}."
52
52
  exit 1
53
53
  end
54
54
 
55
55
  params = { :cmd => 'setCurrentFilter', :token => api_token }
56
- filter = result.find_first "/response/filters/filter[.='#{ARGV[0]}']"
57
- if filter
58
- params[:sFilter] = filter['sFilter']
59
- else
56
+ filter = result.elements["/response/filters/filter[.='#{ARGV[0]}']"]
57
+ unless filter
60
58
  puts "#{ARGV[0]} is not a valid filter."
61
59
  exit 1
62
60
  end
63
61
 
64
- response = Typhoeus::Request.get(api_url,
65
- :verbose => options[:verbose],
66
- :params => params)
67
-
68
- if response.code != 200
62
+ uri = URI format("#{api_url}?cmd=setCurrentFilter&token=%s&sFilter=%s",
63
+ URI.escape(api_token),
64
+ URI.escape(filter.attributes['sFilter']))
65
+ http = Net::HTTP.new(uri.host, uri.port)
66
+ if uri.scheme == 'https'
67
+ http.use_ssl = true
68
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
69
+ end
70
+ response = http.start { |h| h.request Net::HTTP::Get.new(uri.request_uri) }
71
+ if response.code != '200'
69
72
  puts "HTTP request to #{api_url} failed with code #{response.code}."
70
73
  exit 1
71
74
  end
72
75
 
73
- result = XML::Parser.string(response.body).parse
74
- error = result.find_first('/response/error')
76
+ result = REXML::Document.new(response.body)
77
+ error = result.elements['/response/error']
75
78
  if error
76
- puts "Failed with error: #{error.content}."
79
+ puts "Failed with error: #{error.text}."
77
80
  exit 1
78
81
  end
data/bin/fogbugz-filters CHANGED
@@ -1,9 +1,11 @@
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'
8
+ require 'highline'
7
9
 
8
10
  api_url = ENV['FOGBUGZ_API_URL']
9
11
  unless api_url
@@ -12,7 +14,7 @@ unless api_url
12
14
  end
13
15
 
14
16
  api_token = ENV['FOGBUGZ_API_TOKEN']
15
- unless api_url
17
+ unless api_token
16
18
  puts "Environment variable FOGBUGZ_API_TOKEN must be set."
17
19
  exit 1
18
20
  end
@@ -21,11 +23,6 @@ options = {}
21
23
  optparse = OptionParser.new do |opts|
22
24
  opts.banner = "usage: #{File::basename(__FILE__)} [options]"
23
25
 
24
- options[:verbose] = false
25
- opts.on('-v', '--verbose', 'Output verbose debugging information') do
26
- options[:verbose] = true
27
- end
28
-
29
26
  opts.on_tail('-h', '--help') do
30
27
  puts optparse.help
31
28
  exit 1
@@ -33,21 +30,30 @@ optparse = OptionParser.new do |opts|
33
30
  end
34
31
  optparse.parse!
35
32
 
36
- response = Typhoeus::Request.get(api_url,
37
- :verbose => options[:verbose],
38
- :params => { :cmd => 'listFilters', :token => api_token })
39
- if response.code != 200
33
+ uri = URI format("#{api_url}?cmd=listFilters&token=%s", 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'
40
41
  puts "HTTP request to #{api_url} failed with code #{response.code}."
41
42
  exit 1
42
43
  end
43
44
 
44
- result = XML::Parser.string(response.body).parse
45
- error = result.find_first('/response/error')
45
+ result = REXML::Document.new(response.body)
46
+ error = result.elements['/response/error']
46
47
  if error
47
- puts "Failed with error: #{error.content}."
48
+ puts "Failed with error: #{error.text}."
48
49
  exit 1
49
50
  end
50
51
 
51
- result.find('/response/filters/filter').each do |filter|
52
- puts filter.content
52
+ HighLine.use_color = STDOUT.isatty
53
+ result.elements.each('/response/filters/filter') do |filter|
54
+ if filter.attributes['status'] == 'current'
55
+ puts "* #{HighLine.new.color(filter.text, HighLine::GREEN)}"
56
+ else
57
+ puts " #{filter.text}"
58
+ end
53
59
  end
data/bin/fogbugz-list 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] [query]"
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
@@ -38,32 +34,34 @@ optparse = OptionParser.new do |opts|
38
34
  end
39
35
  optparse.parse!
40
36
 
41
- response = Typhoeus::Request.get(api_url,
42
- :verbose => options[:verbose],
43
- :params => {
44
- :cmd => 'search',
45
- :token => api_token,
46
- :cols => 'ixBug,sPersonAssignedTo,sFixFor,sPriority,sTitle',
47
- :q => ARGV[0],
48
- :max => options[:max] })
49
-
50
- if response.code != 200
37
+ uri = URI format("#{api_url}?cmd=search&token=%s&cols=%s%s%s",
38
+ URI.escape(api_token),
39
+ URI.escape('ixBug,sPersonAssignedTo,sFixFor,sPriority,sTitle'),
40
+ ARGV[0] ? "&q=#{URI.escape(ARGV[0])}" : '',
41
+ options[:max] ? "&max=#{URI.escape(options[:max])}" : '')
42
+ http = Net::HTTP.new(uri.host, uri.port)
43
+ if uri.scheme == 'https'
44
+ http.use_ssl = true
45
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
46
+ end
47
+ response = http.start { |h| h.request Net::HTTP::Get.new(uri.request_uri) }
48
+ if response.code != '200'
51
49
  puts "HTTP request to #{api_url} failed with code #{response.code}."
52
50
  exit 1
53
51
  end
54
52
 
55
- result = XML::Parser.string(response.body).parse
56
- error = result.find_first('/response/error')
53
+ result = REXML::Document.new(response.body)
54
+ error = result.elements['/response/error']
57
55
  if error
58
- puts "Failed with error: #{error.content}."
56
+ puts "Failed with error: #{error.text}."
59
57
  exit 1
60
58
  end
61
59
 
62
- result.find('/response/cases/case').each do |bug|
60
+ result.elements.each('/response/cases/case') do |bug|
63
61
  puts format("%-6.6s %-20.20s %-16.16s %-16.16s %s\n",
64
- bug.find_first('ixBug').content,
65
- bug.find_first('sPersonAssignedTo').content,
66
- bug.find_first('sFixFor').content,
67
- bug.find_first('sPriority').content,
68
- bug.find_first('sTitle').content).strip!
62
+ bug.elements['ixBug'].text,
63
+ bug.elements['sPersonAssignedTo'].text,
64
+ bug.elements['sFixFor'].text,
65
+ bug.elements['sPriority'].text,
66
+ bug.elements['sTitle'].text).strip!
69
67
  end
data/bin/fogbugz-login CHANGED
@@ -1,14 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rubygems'
4
- require 'typhoeus'
5
- require 'xml'
6
- require 'tempfile'
7
- require 'pp'
4
+ require 'net/https'
5
+ require 'uri'
6
+ require 'rexml/document'
8
7
  require 'optparse'
9
- require 'yaml'
10
- require 'English'
11
- require 'term/ansicolor'
8
+ require 'highline'
12
9
 
13
10
  api_url = ENV['FOGBUGZ_API_URL']
14
11
  unless api_url
@@ -20,9 +17,9 @@ options = {}
20
17
  optparse = OptionParser.new do |opts|
21
18
  opts.banner = "usage: #{File::basename(__FILE__)} [options] <email> <password>"
22
19
 
23
- options[:verbose] = false
24
- opts.on('-v', '--verbose', 'Output verbose debugging information') do
25
- options[:verbose] = true
20
+ options[:password] = nil
21
+ opts.on_tail('-p', '--password=<password>') do |password|
22
+ options[:password] = password
26
23
  end
27
24
 
28
25
  opts.on_tail('-h', '--help') do
@@ -31,30 +28,35 @@ optparse = OptionParser.new do |opts|
31
28
  end
32
29
  end
33
30
  optparse.parse!
34
- unless ARGV.length == 2
31
+ unless ARGV.length == 1
35
32
  puts optparse.help
36
33
  exit 1
37
34
  end
38
35
 
39
- response = Typhoeus::Request.get(api_url,
40
- :verbose => options[:verbose],
41
- :params => {
42
- :cmd => 'logon',
43
- :email => ARGV[0],
44
- :password => ARGV[1] })
45
- if response.code != 200
36
+ password = options[:password] ||
37
+ HighLine.new.ask('Password: ') { |q| q.echo = false }
38
+
39
+ uri = URI format("#{api_url}?cmd=logon&email=%s&password=%s",
40
+ URI.escape(ARGV[0]), password)
41
+ http = Net::HTTP.new(uri.host, uri.port)
42
+ if uri.scheme == 'https'
43
+ http.use_ssl = true
44
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
45
+ end
46
+ response = http.start { |h| h.request Net::HTTP::Get.new(uri.request_uri) }
47
+ if response.code != '200'
46
48
  puts "HTTP request to #{api_url} failed with code #{response.code}."
47
49
  exit 1
48
50
  end
49
51
 
50
- result = XML::Parser.string(response.body).parse
51
- error = result.find_first('/response/error')
52
+ result = REXML::Document.new(response.body)
53
+ error = result.elements['/response/error']
52
54
  if error
53
- puts "Failed with error: #{error.content}."
55
+ puts "Failed with error: #{error.text}."
54
56
  exit 1
55
57
  end
56
58
 
57
59
  puts <<HERE
58
60
  Login successful. Set the following environment variable:
59
- export FOGBUGZ_API_TOKEN=#{result.find_first('/response/token').content}
61
+ export FOGBUGZ_API_TOKEN=#{result.elements['/response/token'].text}
60
62
  HERE
data/bin/fogbugz-logoff 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,17 +29,21 @@ optparse = OptionParser.new do |opts|
33
29
  end
34
30
  optparse.parse!
35
31
 
36
- response = Typhoeus::Request.get(api_url,
37
- :params => { :cmd => 'logoff', :token => api_token },
38
- :verbose => options[:verbose]);
39
- if response.code != 200
32
+ uri = URI format("#{api_url}?cmd=logoff&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'
40
40
  puts "HTTP request to #{api_url} failed with code #{response.code}."
41
41
  exit 1
42
42
  end
43
43
 
44
- result = XML::Parser.string(response.body).parse
45
- error = result.find_first('/response/error')
44
+ result = REXML::Document.new(response.body)
45
+ error = result.elements['/response/error']
46
46
  if error
47
- puts "Failed with error: #{error.content}."
47
+ puts "Failed with error: #{error.text}."
48
48
  exit 1
49
49
  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,37 +22,35 @@ 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
32
28
  end
33
29
  end
34
30
  optparse.parse!
35
- response = Typhoeus::Request.get(api_url,
36
- :verbose => options[:verbose],
37
- :params => {
38
- :cmd => 'listFixFors',
39
- :token => api_token })
40
- if response.code != 200
31
+
32
+ uri = URI format("#{api_url}?cmd=listFixFors&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'
41
40
  puts "HTTP request to #{api_url} failed with code #{response.code}."
42
41
  exit 1
43
42
  end
44
43
 
45
- result = XML::Parser.string(response.body).parse
46
- error = result.find_first('/response/error')
44
+ result = REXML::Document.new(response.body)
45
+ error = result.elements['/response/error']
47
46
  if error
48
- puts "Failed with error: #{error.content}."
47
+ puts "Failed with error: #{error.text}."
49
48
  exit 1
50
49
  end
51
50
 
52
- result.find('/response/fixfors/fixfor').each do |status|
51
+ result.elements.each('/response/fixfors/fixfor') do |milestones|
53
52
  puts format("%-30.30s %-16.16s %s\n",
54
- status.find_first('sFixFor').content,
55
- status.find_first('dt').content,
56
- status.find_first('sProject').content).strip!
53
+ milestones.elements['sFixFor'].text,
54
+ milestones.elements['dt'].text,
55
+ milestones.elements['sProject'].text).strip!
57
56
  end