ludo-roart 0.1.15 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roart (0.1.9)
4
+ ludo-roart (0.1.10)
5
5
  activesupport (>= 2.0.0)
6
6
  mechanize (>= 1.0.0)
7
7
 
@@ -27,7 +27,7 @@ GEM
27
27
  nokogiri (~> 1.4)
28
28
  ntlm-http (~> 0.1, >= 0.1.1)
29
29
  webrobots (~> 0.0, >= 0.0.9)
30
- mime-types (1.17.2)
30
+ mime-types (1.18)
31
31
  net-http-digest_auth (1.2)
32
32
  net-http-persistent (2.5.2)
33
33
  nokogiri (1.5.2)
@@ -53,5 +53,5 @@ DEPENDENCIES
53
53
  activesupport (= 3.0.12)
54
54
  bones (>= 2.5.1)
55
55
  i18n
56
- roart!
56
+ ludo-roart!
57
57
  rspec (= 2.8.0)
@@ -1,17 +1,26 @@
1
1
  class Hash
2
- def to_content_format
3
- fields = self.map do |key,value|
4
- unless value.nil?
5
- value = Roart::ContentFormatter.format_string(value.to_s)
2
+ def to_content_format
3
+ fields = []
4
+
5
+ self.each do |key, values|
6
+ next if values.nil?
7
+
8
+ key_name =
6
9
  if key.to_s.match(/^cf_.+/)
7
- "CF-#{key.to_s[3..key.to_s.length].gsub(/_/, " ").camelize.humanize}: #{value}"
10
+ "CF-#{key.to_s[3..key.to_s.length].gsub(/_/, " ").camelize.humanize}"
8
11
  elsif key.to_s.match(/^CF-.+/)
9
- "#{key.to_s}: #{value}"
12
+ key.to_s
10
13
  elsif key.to_s.match(/^[a|A]ttachments/)
11
- "Attachment: #{value.join(",")}" if value.kind_of?(Array)
14
+ values = values.join(",") if values.kind_of?(Array)
15
+ "Attachment"
12
16
  else
13
- "#{key.to_s.camelize}: #{value}"
17
+ key.to_s.camelize
14
18
  end
19
+
20
+ values = [values] unless values.is_a?(Array)
21
+ values.each do |value|
22
+ value = Roart::ContentFormatter.format_string(value.to_s)
23
+ fields << "#{key_name}: #{value}"
15
24
  end
16
25
  end
17
26
  content = fields.compact.sort.join("\n")
data/roart.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ludo-roart}
5
- s.version = "0.1.15"
5
+ s.version = "0.1.16"
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"]
@@ -25,16 +25,16 @@ describe 'hash extentions' do
25
25
  payload.to_content_format
26
26
  end
27
27
 
28
- it "should not include attachments into content" do
29
- payload = {:subject => 'A new ticket', :queue => 'My queue', :text => "A text", :attachments => '/dev/null'}
30
- payload.to_content_format.should_not include("Attachment")
31
- end
32
-
33
- it "should not include attachments into content" do
34
- payload = {:subject => 'A new ticket', :queue => 'My queue', :text => "A text", :attachment => '/dev/null,/dev/zero'}
28
+ it "should include attachments into content" do
29
+ payload = {:subject => 'A new ticket', :queue => 'My queue', :text => "A text", :attachments => '/dev/null,/dev/zero'}
35
30
  payload.to_content_format.should include("Attachment")
36
31
  end
37
32
 
38
33
  end
39
34
 
35
+ it "should return sorted data with the same key multiple times when value is array" do
36
+ payload = { 'CF-My Day' => %w(Tue Wed Fri), 'CF-My Time' => %w(morning evening) }
37
+ payload.to_content_format.should == "CF-My Day: Fri\nCF-My Day: Tue\nCF-My Day: Wed\nCF-My Time: evening\nCF-My Time: morning"
38
+ end
39
+
40
40
  end
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: 5
4
+ hash: 59
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 15
10
- version: 0.1.15
9
+ - 16
10
+ version: 0.1.16
11
11
  platform: ruby
12
12
  authors:
13
13
  - PJ Davis