roust 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -8
- data/Rakefile +2 -0
- data/lib/roust/version.rb +1 -1
- data/lib/roust.rb +82 -51
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7ee7d17e0b20c09150bf0bdd916cb095e80cb00
|
4
|
+
data.tar.gz: 8980ec21a7e9ba564c76b030b7228864eb63c967
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79232477402303a69319cc1b5ec6d7d586b15b25c769fdfac226806d8b5262308a3daf24878bcaaea6afc002f2cbc39c6e9401c01c5cd7fb7a2b8c37735c5089
|
7
|
+
data.tar.gz: f0df4616af12ea96fa3443c216fbf7371e88f3ba8b95d1143b2059f721c79f69c0a09b406960c746adcb2067dad140aec433c1d83bddff8389ea342de33767b1
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -3,7 +3,7 @@ Roust
|
|
3
3
|
|
4
4
|
Roust is a Ruby client for [Request Tracker](http://www.bestpractical.com/rt/)'s REST API.
|
5
5
|
|
6
|
-
It is a fork of [rt-client](http://rubygems.org/gems/rt-client) by Tom Lahti.
|
6
|
+
It is a complete fork of [rt-client](http://rubygems.org/gems/rt-client) by Tom Lahti, and shares little ancestry.
|
7
7
|
|
8
8
|
Features
|
9
9
|
--------
|
@@ -43,7 +43,7 @@ credentials = {
|
|
43
43
|
rt = Roust.new(credentials)
|
44
44
|
rt.authenticated? # => true
|
45
45
|
|
46
|
-
# Query RT
|
46
|
+
# Query RT
|
47
47
|
rt.list(:query => "id = 1 or id = 2") # => [["1", "A subject"], ["2", "Another subject"]]
|
48
48
|
|
49
49
|
# Fetch ticket metadata
|
@@ -86,12 +86,10 @@ Releasing
|
|
86
86
|
---------
|
87
87
|
|
88
88
|
1. Bump the version in `lib/roust/version.rb`
|
89
|
-
2.
|
90
|
-
3.
|
91
|
-
4. `
|
92
|
-
5.
|
93
|
-
6. Build the gem with `rake build`
|
94
|
-
|
89
|
+
2. Run a `bundle` to update any RubyGems dependencies.
|
90
|
+
3. git tag the version git tag X.Y.Z
|
91
|
+
4. Build the gem with `rake build`
|
92
|
+
5. Push the gem with `rake push`
|
95
93
|
|
96
94
|
|
97
95
|
TODO
|
data/Rakefile
CHANGED
data/lib/roust/version.rb
CHANGED
data/lib/roust.rb
CHANGED
@@ -198,14 +198,19 @@ class Roust
|
|
198
198
|
reply = {}
|
199
199
|
resp = @site["ticket/#{sid}/links/show"].get
|
200
200
|
resp.gsub!(/RT\/\d+\.\d+\.\d+\s\d{3}\s.*\n\n/,"") # toss the HTTP response
|
201
|
-
resp.gsub!(/\n\n/,"\n") # remove double spacing,
|
201
|
+
resp.gsub!(/\n\n/,"\n") # remove double spacing, Mail stops at a blank line
|
202
202
|
while resp.match(/CF\.\{[\w_ ]*[ ]+[\w ]*\}/) #replace CF spaces with underscores
|
203
203
|
resp.gsub!(/CF\.\{([\w_ ]*)([ ]+)([\w ]*)\}/, 'CF.{\1_\3}')
|
204
204
|
end
|
205
205
|
return {:error => resp, } if resp =~ /does not exist./
|
206
|
-
|
207
|
-
|
208
|
-
|
206
|
+
items = resp.split("\n--\n")
|
207
|
+
items.each do |item|
|
208
|
+
th = Mail.new(item)
|
209
|
+
th.header.fields.each do |header|
|
210
|
+
k = header.name.to_s.downcase
|
211
|
+
v = header.value.to_s
|
212
|
+
reply["#{k}"] = v.to_s
|
213
|
+
end
|
209
214
|
end
|
210
215
|
reply
|
211
216
|
end
|
@@ -460,23 +465,30 @@ class Roust
|
|
460
465
|
tickets = resp.split("\n--\n") # -- occurs between each ticket
|
461
466
|
tickets.each do |ticket|
|
462
467
|
ticket.gsub!(/^\n/,"") # strip leading blank lines
|
463
|
-
ticket.gsub!(/\n\n/,"\n") # remove blank lines for
|
468
|
+
ticket.gsub!(/\n\n/,"\n") # remove blank lines for Mail
|
464
469
|
while ticket.match(/CF\.\{[\w_ ]*[ ]+[\w ]*\}/) #replace CF spaces with underscores
|
465
470
|
ticket.gsub!(/CF\.\{([\w_ ]*)([ ]+)([\w ]*)\}/, 'CF.{\1_\3}')
|
466
471
|
end
|
467
|
-
|
472
|
+
items = ticket.split("\n--\n")
|
468
473
|
reply = {}
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
474
|
+
items.each do |item|
|
475
|
+
item.gsub!(/\n\s*\n/,"\n") # remove blank lines for Mail
|
476
|
+
th = Mail.new(item)
|
477
|
+
th.header.fields.each do |header|
|
478
|
+
k = header.name.to_s.downcase
|
479
|
+
v = header.value.to_s
|
480
|
+
case k
|
481
|
+
when 'created','due','told','lastupdated','started'
|
482
|
+
begin
|
483
|
+
vv = DateTime.parse(v)
|
484
|
+
reply["#{k}"] = vv.strftime("%Y-%m-%d %H:%M:%S")
|
485
|
+
rescue ArgumentError => e
|
486
|
+
p "e #{e}"
|
487
|
+
reply["#{k}"] = v
|
488
|
+
end
|
489
|
+
else
|
490
|
+
reply["#{k}"] = v
|
491
|
+
end
|
480
492
|
end
|
481
493
|
end
|
482
494
|
replies.push reply
|
@@ -534,9 +546,10 @@ class Roust
|
|
534
546
|
resp.gsub!(/CF\.\{([\w_ ]*)([ ]+)([\w ]*)\}/, 'CF.{\1_\3}')
|
535
547
|
end
|
536
548
|
items = resp.split("\n--\n")
|
537
|
-
|
538
549
|
list = []
|
539
550
|
items.each do |item|
|
551
|
+
#yes, this messes with the "content:" field but that's the one that's upsetting Mail.new
|
552
|
+
item.gsub!(/\n\s*\n/,"\n") # remove blank lines for Mail
|
540
553
|
th = Mail.new(item)
|
541
554
|
next if not comments and th["type"].to_s =~ /Comment/ # skip comments
|
542
555
|
reply = {}
|
@@ -567,7 +580,7 @@ class Roust
|
|
567
580
|
end
|
568
581
|
when "content"
|
569
582
|
reply["content"] = v.to_s
|
570
|
-
#temp = item.match(/^Content: (.*?)^\w+:/m) #
|
583
|
+
#temp = item.match(/^Content: (.*?)^\w+:/m) # Mail strips line breaks
|
571
584
|
#reply["content"] = temp[1] if temp.class != NilClass
|
572
585
|
else
|
573
586
|
reply["#{k}"] = v.to_s
|
@@ -607,35 +620,39 @@ class Roust
|
|
607
620
|
while resp.match(/CF\.\{[\w_ ]*[ ]+[\w ]*\}/) #replace CF spaces with underscores
|
608
621
|
resp.gsub!(/CF\.\{([\w_ ]*)([ ]+)([\w ]*)\}/, 'CF.{\1_\3}')
|
609
622
|
end
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
s
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
s[:name] =
|
627
|
-
|
623
|
+
items = resp.split("\n--\n")
|
624
|
+
items.each do |item|
|
625
|
+
th = Mail.new(item)
|
626
|
+
th.header.fields.each do |header|
|
627
|
+
k = header.name.to_s.downcase
|
628
|
+
v = header.value.to_s
|
629
|
+
case k
|
630
|
+
when "attachments"
|
631
|
+
temp = resp.match(/Attachments:\s*(.*)[^\w|$]/m)
|
632
|
+
if temp.class != NilClass
|
633
|
+
atarr = temp[1].split("\n")
|
634
|
+
atarr.map { |a| a.gsub!(/^\s*/,"") }
|
635
|
+
atarr.each do |a|
|
636
|
+
i = a.match(/(\d+):\s*(.*)/)
|
637
|
+
s={}
|
638
|
+
s[:id] = i[1]
|
639
|
+
s[:name] = i[2]
|
640
|
+
sz = i[2].match(/(.*?)\s*\((.*?)\)/)
|
641
|
+
if sz.class == MatchData
|
642
|
+
s[:name] = sz[1]
|
643
|
+
s[:size] = sz[2]
|
644
|
+
end
|
645
|
+
attachments.push s
|
628
646
|
end
|
629
|
-
attachments
|
647
|
+
reply["#{k}"] = attachments
|
630
648
|
end
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
reply["#{k}"] = v.to_s
|
649
|
+
when "content"
|
650
|
+
reply["content"] = v.to_s
|
651
|
+
temp = resp.match(/^Content: (.*?)^\w+:/m) # Mail strips line breaks
|
652
|
+
reply["content"] = temp[1] if temp.class != NilClass
|
653
|
+
else
|
654
|
+
reply["#{k}"] = v.to_s
|
655
|
+
end
|
639
656
|
end
|
640
657
|
end
|
641
658
|
reply
|
@@ -662,10 +679,19 @@ class Roust
|
|
662
679
|
while resp.match(/CF\.\{[\w_ ]*[ ]+[\w ]*\}/) #replace CF spaces with underscores
|
663
680
|
resp.gsub!(/CF\.\{([\w_ ]*)([ ]+)([\w ]*)\}/, 'CF.{\1_\3}')
|
664
681
|
end
|
665
|
-
th = TMail::Mail.parse(resp)
|
666
682
|
list = []
|
667
683
|
pattern = /(\d+:\s.*?\)),/
|
668
|
-
|
684
|
+
items = resp.split("\n--\n")
|
685
|
+
attachment_string = ""
|
686
|
+
items.each do |item|
|
687
|
+
th = Mail.new(item)
|
688
|
+
th.header.fields.each do |header|
|
689
|
+
if header.name.to_s.downcase == "attachments"
|
690
|
+
attachment_string = attachment_string + header.value.to_s
|
691
|
+
end
|
692
|
+
end
|
693
|
+
end
|
694
|
+
match = pattern.match(attachment_string)
|
669
695
|
while match != nil
|
670
696
|
list.push match[0]
|
671
697
|
s = match.post_match
|
@@ -721,10 +747,15 @@ class Roust
|
|
721
747
|
while resp.match(/CF\.\{[\w_ ]*[ ]+[\w ]*\}/) #replace CF spaces with underscores
|
722
748
|
resp.gsub!(/CF\.\{([\w_ ]*)([ ]+)([\w ]*)\}/, 'CF.{\1_\3}')
|
723
749
|
end
|
724
|
-
headers = TMail::Mail.parse(resp)
|
725
750
|
reply = {}
|
726
|
-
|
727
|
-
|
751
|
+
items = resp.split("\n--\n")
|
752
|
+
items.each do |item|
|
753
|
+
th = Mail.new(item)
|
754
|
+
th.header.fields.each do |header|
|
755
|
+
k = header.name.to_s.downcase
|
756
|
+
v = header.value.to_s
|
757
|
+
reply["#{k}"] = v.to_s
|
758
|
+
end
|
728
759
|
end
|
729
760
|
content = resp.match(/Content:\s+(.*)/m)[1]
|
730
761
|
content.gsub!(/\n\s{9}/,"\n") # strip leading spaces on each line
|