ludo-roart 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +9 -0
- data/Gemfile.lock +57 -0
- data/lib/roart/attachment.rb +37 -0
- data/lib/roart/core/content_formatter.rb +12 -0
- data/lib/roart/ticket.rb +1 -1
- data/roart.gemspec +4 -3
- data/spec/roart/attachment_spec.rb +65 -0
- data/spec/roart/core/content_formatter_spec.rb +23 -0
- data/spec/test_data/lorem.txt +1 -0
- metadata +36 -11
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
roart (0.1.9)
|
5
|
+
activesupport (>= 2.0.0)
|
6
|
+
mechanize (>= 1.0.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (3.0.12)
|
12
|
+
bones (3.8.0)
|
13
|
+
little-plugger (~> 1.1.3)
|
14
|
+
loquacious (~> 1.9.1)
|
15
|
+
rake (>= 0.8.7)
|
16
|
+
diff-lcs (1.1.3)
|
17
|
+
domain_name (0.5.2)
|
18
|
+
unf (~> 0.0.3)
|
19
|
+
i18n (0.6.0)
|
20
|
+
little-plugger (1.1.3)
|
21
|
+
loquacious (1.9.1)
|
22
|
+
mechanize (2.3)
|
23
|
+
domain_name (~> 0.5, >= 0.5.1)
|
24
|
+
mime-types (~> 1.17, >= 1.17.2)
|
25
|
+
net-http-digest_auth (~> 1.1, >= 1.1.1)
|
26
|
+
net-http-persistent (~> 2.5, >= 2.5.2)
|
27
|
+
nokogiri (~> 1.4)
|
28
|
+
ntlm-http (~> 0.1, >= 0.1.1)
|
29
|
+
webrobots (~> 0.0, >= 0.0.9)
|
30
|
+
mime-types (1.17.2)
|
31
|
+
net-http-digest_auth (1.2)
|
32
|
+
net-http-persistent (2.5.2)
|
33
|
+
nokogiri (1.5.2)
|
34
|
+
ntlm-http (0.1.1)
|
35
|
+
rake (0.9.2.2)
|
36
|
+
rspec (2.8.0)
|
37
|
+
rspec-core (~> 2.8.0)
|
38
|
+
rspec-expectations (~> 2.8.0)
|
39
|
+
rspec-mocks (~> 2.8.0)
|
40
|
+
rspec-core (2.8.0)
|
41
|
+
rspec-expectations (2.8.0)
|
42
|
+
diff-lcs (~> 1.1.2)
|
43
|
+
rspec-mocks (2.8.0)
|
44
|
+
unf (0.0.5)
|
45
|
+
unf_ext
|
46
|
+
unf_ext (0.0.4)
|
47
|
+
webrobots (0.0.13)
|
48
|
+
|
49
|
+
PLATFORMS
|
50
|
+
ruby
|
51
|
+
|
52
|
+
DEPENDENCIES
|
53
|
+
activesupport (= 3.0.12)
|
54
|
+
bones (>= 2.5.1)
|
55
|
+
i18n
|
56
|
+
roart!
|
57
|
+
rspec (= 2.8.0)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Roart
|
2
|
+
|
3
|
+
class AttachmentCollection < Array
|
4
|
+
def to_payload
|
5
|
+
hash = Hash.new
|
6
|
+
self.each_with_index do |attach, index|
|
7
|
+
hash["attachment_#{index+1}"] = attach.file
|
8
|
+
end
|
9
|
+
hash
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Attachment < Struct.new(:name, :file)
|
14
|
+
|
15
|
+
def path
|
16
|
+
name
|
17
|
+
end
|
18
|
+
|
19
|
+
def read
|
20
|
+
file.read
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.detect(*args)
|
24
|
+
AttachmentCollection.new Array(args.compact).flatten.map { |file|
|
25
|
+
if file.is_a?(File)
|
26
|
+
Attachment.new(File.basename(file.path), file)
|
27
|
+
elsif file.is_a?(String)
|
28
|
+
Attachment.new(File.basename(file), File.open(file, 'rb'))
|
29
|
+
elsif file.respond_to?(:open, :original_filename)
|
30
|
+
Attachment.new(file.original_filename, file.open)
|
31
|
+
end
|
32
|
+
}.compact
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -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
|
data/lib/roart/ticket.rb
CHANGED
@@ -78,7 +78,7 @@ module Roart
|
|
78
78
|
# tix.comment("This is a comment", :attachments => [params[:attachment_1], params[:attachment_2]])
|
79
79
|
#
|
80
80
|
def comment(comment, opt = {})
|
81
|
-
comment = {:text => comment, :action => '
|
81
|
+
comment = {:text => comment, :action => 'Comment'}.merge(opt)
|
82
82
|
|
83
83
|
uri = "#{self.class.connection.server}/REST/1.0/ticket/#{self.id}/comment"
|
84
84
|
|
data/roart.gemspec
CHANGED
@@ -2,15 +2,16 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{ludo-roart}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.15"
|
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
9
|
s.date = %q{2010-09-15}
|
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
|
-
s.extra_rdoc_files = [
|
13
|
-
s.files = [
|
12
|
+
s.extra_rdoc_files = Dir['{lib,spec}/**/*.txt', "[a-zA-Z]*.txt", "[a-zA-Z]*.rdoc"]
|
13
|
+
s.files = Dir['{lib,spec}/**/*', "[a-zA-Z]*"]
|
14
|
+
s.test_files = Dir['spec/**/*']
|
14
15
|
s.homepage = %q{http://github.com/pjdavis/roart}
|
15
16
|
s.rdoc_options = ["--main", "README.rdoc"]
|
16
17
|
s.require_paths = ["lib"]
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[ .. spec_helper])
|
2
|
+
|
3
|
+
describe Roart::Attachment do
|
4
|
+
|
5
|
+
context "instance" do
|
6
|
+
subject { described_class.new("zero", File.open("/dev/zero", "rb")) }
|
7
|
+
|
8
|
+
it { should respond_to(:path) }
|
9
|
+
it { should respond_to(:read) }
|
10
|
+
it { should respond_to(:name) }
|
11
|
+
end
|
12
|
+
|
13
|
+
describe ".detect" do
|
14
|
+
|
15
|
+
it "should create collection from attachments array" do
|
16
|
+
described_class.detect(['/dev/null', '/dev/zero']).should be_a(Enumerable)
|
17
|
+
described_class.detect(['/dev/null', '/dev/zero']).first.should be_a(Roart::Attachment)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should create collection from attachments as params" do
|
21
|
+
described_class.detect('/dev/null', '/dev/zero').should be_a(Enumerable)
|
22
|
+
described_class.detect(['/dev/null', '/dev/zero']).first.should be_a(Roart::Attachment)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should create collection from one attachment" do
|
26
|
+
described_class.detect('/dev/null').should be_a(Enumerable)
|
27
|
+
described_class.detect(['/dev/null', '/dev/zero']).first.should be_a(Roart::Attachment)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should create using String filename" do
|
31
|
+
@attachment = described_class.detect('/dev/null').first
|
32
|
+
@attachment.file.should be_a(File)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should create using File descriptor" do
|
36
|
+
@attachment = described_class.detect(File.open('/dev/null', 'rb')).first
|
37
|
+
@attachment.file.should be_a(File)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should create using Tempfile instance" do
|
41
|
+
@tempfile = mock(:tempfile, :original_filename => "test name", :open => "file descriptor")
|
42
|
+
@attachment = described_class.detect(@tempfile).first
|
43
|
+
@attachment.file.should == "file descriptor"
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
describe Roart::AttachmentCollection, ".to_payload" do
|
49
|
+
subject { Roart::Attachment.detect(['/dev/null', '/dev/zero']) }
|
50
|
+
|
51
|
+
it "should return a Hash" do
|
52
|
+
subject.to_payload.should be_a(Hash)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should generate keys for attachments" do
|
56
|
+
subject.to_payload.should have_key("attachment_1")
|
57
|
+
subject.to_payload.should have_key("attachment_2")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should contain file descriptors" do
|
61
|
+
subject.to_payload["attachment_1"].should be_a(File)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -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
|
@@ -0,0 +1 @@
|
|
1
|
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ludo-roart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 15
|
10
|
+
version: 0.1.15
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- PJ Davis
|
@@ -72,21 +72,20 @@ executables: []
|
|
72
72
|
extensions: []
|
73
73
|
|
74
74
|
extra_rdoc_files:
|
75
|
-
- History.txt
|
76
|
-
- README.rdoc
|
77
75
|
- spec/test_data/full_history.txt
|
76
|
+
- spec/test_data/lorem.txt
|
78
77
|
- spec/test_data/search_ticket.txt
|
79
78
|
- spec/test_data/single_history.txt
|
80
79
|
- spec/test_data/ticket.txt
|
81
|
-
files:
|
82
80
|
- History.txt
|
83
81
|
- README.rdoc
|
84
|
-
|
85
|
-
- lib/roart.rb
|
82
|
+
files:
|
83
|
+
- lib/roart/attachment.rb
|
86
84
|
- lib/roart/callbacks.rb
|
87
85
|
- lib/roart/connection.rb
|
88
86
|
- lib/roart/connection_adapter.rb
|
89
87
|
- lib/roart/connection_adapters/mechanize_adapter.rb
|
88
|
+
- lib/roart/core/content_formatter.rb
|
90
89
|
- lib/roart/core/hash.rb
|
91
90
|
- lib/roart/errors.rb
|
92
91
|
- lib/roart/history.rb
|
@@ -94,10 +93,12 @@ files:
|
|
94
93
|
- lib/roart/ticket.rb
|
95
94
|
- lib/roart/ticket_page.rb
|
96
95
|
- lib/roart/validations.rb
|
97
|
-
- roart.
|
96
|
+
- lib/roart.rb
|
97
|
+
- spec/roart/attachment_spec.rb
|
98
98
|
- spec/roart/callbacks_spec.rb
|
99
99
|
- spec/roart/connection_adapter_spec.rb
|
100
100
|
- spec/roart/connection_spec.rb
|
101
|
+
- spec/roart/core/content_formatter_spec.rb
|
101
102
|
- spec/roart/core/hash_spec.rb
|
102
103
|
- spec/roart/history_spec.rb
|
103
104
|
- spec/roart/roart_spec.rb
|
@@ -107,9 +108,16 @@ files:
|
|
107
108
|
- spec/roart_spec.rb
|
108
109
|
- spec/spec_helper.rb
|
109
110
|
- spec/test_data/full_history.txt
|
111
|
+
- spec/test_data/lorem.txt
|
110
112
|
- spec/test_data/search_ticket.txt
|
111
113
|
- spec/test_data/single_history.txt
|
112
114
|
- spec/test_data/ticket.txt
|
115
|
+
- Gemfile
|
116
|
+
- Gemfile.lock
|
117
|
+
- History.txt
|
118
|
+
- Rakefile
|
119
|
+
- README.rdoc
|
120
|
+
- roart.gemspec
|
113
121
|
homepage: http://github.com/pjdavis/roart
|
114
122
|
licenses: []
|
115
123
|
|
@@ -144,5 +152,22 @@ rubygems_version: 1.8.15
|
|
144
152
|
signing_key:
|
145
153
|
specification_version: 3
|
146
154
|
summary: Interface for working with Request Tracker (RT) tickets inspired by ActiveRecord
|
147
|
-
test_files:
|
148
|
-
|
155
|
+
test_files:
|
156
|
+
- spec/roart/attachment_spec.rb
|
157
|
+
- spec/roart/callbacks_spec.rb
|
158
|
+
- spec/roart/connection_adapter_spec.rb
|
159
|
+
- spec/roart/connection_spec.rb
|
160
|
+
- spec/roart/core/content_formatter_spec.rb
|
161
|
+
- spec/roart/core/hash_spec.rb
|
162
|
+
- spec/roart/history_spec.rb
|
163
|
+
- spec/roart/roart_spec.rb
|
164
|
+
- spec/roart/ticket_page_spec.rb
|
165
|
+
- spec/roart/ticket_spec.rb
|
166
|
+
- spec/roart/validation_spec.rb
|
167
|
+
- spec/roart_spec.rb
|
168
|
+
- spec/spec_helper.rb
|
169
|
+
- spec/test_data/full_history.txt
|
170
|
+
- spec/test_data/lorem.txt
|
171
|
+
- spec/test_data/search_ticket.txt
|
172
|
+
- spec/test_data/single_history.txt
|
173
|
+
- spec/test_data/ticket.txt
|