roart 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ ==0.1.10 / 2010-10-07
2
+ Fix creation of tickets with fields containing new lines (via hennk)
1
3
  ==0.1.9 / 2010-05-23
2
4
  Removed the String/Hash extensions copied from ActiveSupport and just added a dependency on ActiveSupport. Removed to_hash added to Array, as it conflicts with ActiveSupport's deep_merge. (via hennk)
3
5
  ==0.1.8 / 2010-03-16
@@ -5,7 +5,7 @@ require 'active_support/core_ext'
5
5
  module Roart
6
6
 
7
7
  # :stopdoc:
8
- VERSION = '0.1.9'
8
+ VERSION = '0.1.10'
9
9
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
10
10
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
11
11
  # :startdoc:
@@ -0,0 +1,12 @@
1
+ module Roart
2
+ class ContentFormatter
3
+ # The following is only based on quick trial&error on my part. The RT Api (at least in 3.6) does not have good documentation.
4
+ # Strings in a RT request:
5
+ # - are not allowed to contain '\r'
6
+ # - must use equally padded new-lines to distinguish them from the beginning of a new field (we use 2-space padding)
7
+ def self.format_string(string)
8
+ string.gsub("\r", '').gsub("\n", "\n ")
9
+ end
10
+
11
+ end
12
+ end
@@ -2,6 +2,7 @@ class Hash
2
2
  def to_content_format
3
3
  fields = self.map do |key,value|
4
4
  unless value.nil?
5
+ value = Roart::ContentFormatter.format_string(value.to_s)
5
6
  if key.to_s.match(/^cf_.+/)
6
7
  "CF-#{key.to_s[3..key.to_s.length].gsub(/_/, " ").camelize.humanize}: #{value}"
7
8
  else
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{roart}
5
- s.version = "0.1.9"
5
+ s.version = "0.1.10"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["PJ Davis"]
9
- s.date = %q{2010-09-15}
9
+ s.date = %q{2010-10-07}
10
10
  s.description = %q{Interface for working with Request Tracker (RT) tickets inspired by ActiveRecord.}
11
11
  s.email = %q{pj.davis@gmail.com}
12
12
  s.extra_rdoc_files = ["History.txt", "README.rdoc", "spec/test_data/full_history.txt", "spec/test_data/search_ticket.txt", "spec/test_data/single_history.txt", "spec/test_data/ticket.txt"]
13
- s.files = ["History.txt", "README.rdoc", "Rakefile", "lib/roart.rb", "lib/roart/callbacks.rb", "lib/roart/connection.rb", "lib/roart/connection_adapter.rb", "lib/roart/connection_adapters/mechanize_adapter.rb", "lib/roart/core/hash.rb", "lib/roart/errors.rb", "lib/roart/history.rb", "lib/roart/roart.rb", "lib/roart/ticket.rb", "lib/roart/ticket_page.rb", "lib/roart/validations.rb", "roart.gemspec", "spec/roart/callbacks_spec.rb", "spec/roart/connection_adapter_spec.rb", "spec/roart/connection_spec.rb", "spec/roart/core/hash_spec.rb", "spec/roart/history_spec.rb", "spec/roart/roart_spec.rb", "spec/roart/ticket_page_spec.rb", "spec/roart/ticket_spec.rb", "spec/roart/validation_spec.rb", "spec/roart_spec.rb", "spec/spec_helper.rb", "spec/test_data/full_history.txt", "spec/test_data/search_ticket.txt", "spec/test_data/single_history.txt", "spec/test_data/ticket.txt"]
13
+ s.files = ["History.txt", "README.rdoc", "Rakefile", "lib/roart.rb", "lib/roart/callbacks.rb", "lib/roart/connection.rb", "lib/roart/connection_adapter.rb", "lib/roart/connection_adapters/mechanize_adapter.rb", "lib/roart/core/content_formatter.rb", "lib/roart/core/hash.rb", "lib/roart/errors.rb", "lib/roart/history.rb", "lib/roart/roart.rb", "lib/roart/ticket.rb", "lib/roart/ticket_page.rb", "lib/roart/validations.rb", "roart.gemspec", "spec/roart/callbacks_spec.rb", "spec/roart/connection_adapter_spec.rb", "spec/roart/connection_spec.rb", "spec/roart/core/content_formatter_spec.rb", "spec/roart/core/hash_spec.rb", "spec/roart/history_spec.rb", "spec/roart/roart_spec.rb", "spec/roart/ticket_page_spec.rb", "spec/roart/ticket_spec.rb", "spec/roart/validation_spec.rb", "spec/roart_spec.rb", "spec/spec_helper.rb", "spec/test_data/full_history.txt", "spec/test_data/search_ticket.txt", "spec/test_data/single_history.txt", "spec/test_data/ticket.txt"]
14
14
  s.homepage = %q{http://github.com/pjdavis/roart}
15
15
  s.rdoc_options = ["--main", "README.rdoc"]
16
16
  s.require_paths = ["lib"]
@@ -0,0 +1,23 @@
1
+ require File.join(File.dirname(__FILE__), %w[ .. .. spec_helper])
2
+
3
+ describe 'content formatter' do
4
+ before do
5
+ @formatter = Roart::ContentFormatter
6
+ end
7
+
8
+ describe 'formatting strings' do
9
+ it "should remove \\r characters" do
10
+ @formatter.format_string("a\r\ntext with\ndifferent\rnew\r\nlines").should_not include("\r")
11
+ end
12
+
13
+ it "should pad new lines with 2 spaces" do
14
+ @formatter.format_string("a\ntext with\n\ndifferent\nnew\n \nlines").should == "a\n" +
15
+ " text with\n" +
16
+ " \n" +
17
+ " different\n" +
18
+ " new\n" +
19
+ " \n" +
20
+ " lines"
21
+ end
22
+ end
23
+ end
@@ -12,5 +12,11 @@ describe 'hash extentions' do
12
12
  payload = {:cf_stuff => 'field'}
13
13
  payload.to_content_format.should == "CF-Stuff: field"
14
14
  end
15
-
15
+
16
+ it 'should use our content formatter for strings' do
17
+ payload = {:subject => 'A new ticket', :queue => 'My queue', :text => "A text"}
18
+ Roart::ContentFormatter.should_receive(:format_string).at_least(:once)
19
+ payload.to_content_format
20
+ end
21
+
16
22
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roart
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 9
10
- version: 0.1.9
9
+ - 10
10
+ version: 0.1.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - PJ Davis
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-15 00:00:00 -05:00
18
+ date: 2010-10-07 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -72,6 +72,7 @@ files:
72
72
  - lib/roart/connection.rb
73
73
  - lib/roart/connection_adapter.rb
74
74
  - lib/roart/connection_adapters/mechanize_adapter.rb
75
+ - lib/roart/core/content_formatter.rb
75
76
  - lib/roart/core/hash.rb
76
77
  - lib/roart/errors.rb
77
78
  - lib/roart/history.rb
@@ -83,6 +84,7 @@ files:
83
84
  - spec/roart/callbacks_spec.rb
84
85
  - spec/roart/connection_adapter_spec.rb
85
86
  - spec/roart/connection_spec.rb
87
+ - spec/roart/core/content_formatter_spec.rb
86
88
  - spec/roart/core/hash_spec.rb
87
89
  - spec/roart/history_spec.rb
88
90
  - spec/roart/roart_spec.rb