roust 1.0.0 → 1.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 513086117718e9f68a4940b63d82d3546b1c999e
4
- data.tar.gz: efa3079add7548468976c137b1b1cfb40525df21
3
+ metadata.gz: e7ee7d17e0b20c09150bf0bdd916cb095e80cb00
4
+ data.tar.gz: 8980ec21a7e9ba564c76b030b7228864eb63c967
5
5
  SHA512:
6
- metadata.gz: 4ccafda8340e695d70354798db29f7338828a2fa5d932ccb9bf8803a8aba0035ee109dbace9175d2dc78b177ddf10f9557238e503b09cd26d237a20a558e3b0c
7
- data.tar.gz: c1719e2fb75e59ffba44f05e5b5c24a98faa42fb625137a169a3b74063b46c45f27ac24d9847391e87999954fdf56b557c92ec9736da2fe49b6bc1592ceaef32
6
+ metadata.gz: 79232477402303a69319cc1b5ec6d7d586b15b25c769fdfac226806d8b5262308a3daf24878bcaaea6afc002f2cbc39c6e9401c01c5cd7fb7a2b8c37735c5089
7
+ data.tar.gz: f0df4616af12ea96fa3443c216fbf7371e88f3ba8b95d1143b2059f721c79f69c0a09b406960c746adcb2067dad140aec433c1d83bddff8389ea342de33767b1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roust (1.0.0)
4
+ roust (1.0.1)
5
5
  archive-tar-minitar (>= 0.5)
6
6
  mail (>= 2.5.4)
7
7
  mime-types (>= 1.16)
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. Add an entry to `CHANGELOG.md`
90
- 3. Run a `bundle` to update any RubyGems dependencies.
91
- 4. `git commit` everything.
92
- 5. git tag the version git tag X.Y.Z
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
@@ -29,6 +29,8 @@ task :push do
29
29
  newest = filenames_with_times.sort_by { |tuple| tuple.last }.last
30
30
  newest_filename = newest.first
31
31
 
32
+ p newest_filename
33
+
32
34
  command = "gem push #{newest_filename}"
33
35
  system(command)
34
36
  end
data/lib/roust/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Roust
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
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, TMail stops at a blank line
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
- th = TMail::Mail.parse(resp)
207
- th.each_header do |k,v|
208
- reply["#{k}"] = v.to_s
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 TMail
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
- th = TMail::Mail.parse(ticket)
472
+ items = ticket.split("\n--\n")
468
473
  reply = {}
469
- th.each_header do |k,v|
470
- case k
471
- when 'created','due','told','lastupdated','started'
472
- begin
473
- vv = DateTime.parse(v.to_s)
474
- reply["#{k}"] = vv.strftime("%Y-%m-%d %H:%M:%S")
475
- rescue ArgumentError
476
- reply["#{k}"] = v.to_s
477
- end
478
- else
479
- reply["#{k}"] = v.to_s
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) # TMail strips line breaks
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
- th = TMail::Mail.parse(resp)
611
- attachments = []
612
- th.each_header do |k,v|
613
- case k
614
- when "attachments"
615
- temp = resp.match(/Attachments:\s*(.*)[^\w|$]/m)
616
- if temp.class != NilClass
617
- atarr = temp[1].split("\n")
618
- atarr.map { |a| a.gsub!(/^\s*/,"") }
619
- atarr.each do |a|
620
- i = a.match(/(\d+):\s*(.*)/)
621
- s={}
622
- s[:id] = i[1]
623
- s[:name] = i[2]
624
- sz = i[2].match(/(.*?)\s*\((.*?)\)/)
625
- if sz.class == MatchData
626
- s[:name] = sz[1]
627
- s[:size] = sz[2]
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.push s
647
+ reply["#{k}"] = attachments
630
648
  end
631
- reply["#{k}"] = attachments
632
- end
633
- when "content"
634
- reply["content"] = v.to_s
635
- temp = resp.match(/^Content: (.*?)^\w+:/m) # TMail strips line breaks
636
- reply["content"] = temp[1] if temp.class != NilClass
637
- else
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
- match = pattern.match(th['attachments'].to_s)
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
- headers.each_header do |k,v|
727
- reply["#{k}"] = v.to_s
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roust
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lindsay Holmwood