ludo-roart 0.1.15 → 0.1.16
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.
- data/Gemfile.lock +3 -3
- data/lib/roart/core/hash.rb +17 -8
- data/roart.gemspec +1 -1
- data/spec/roart/core/hash_spec.rb +7 -7
- metadata +3 -3
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
roart (0.1.
|
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.
|
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)
|
data/lib/roart/core/hash.rb
CHANGED
@@ -1,17 +1,26 @@
|
|
1
1
|
class Hash
|
2
|
-
|
3
|
-
fields =
|
4
|
-
|
5
|
-
|
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}
|
10
|
+
"CF-#{key.to_s[3..key.to_s.length].gsub(/_/, " ").camelize.humanize}"
|
8
11
|
elsif key.to_s.match(/^CF-.+/)
|
9
|
-
|
12
|
+
key.to_s
|
10
13
|
elsif key.to_s.match(/^[a|A]ttachments/)
|
11
|
-
|
14
|
+
values = values.join(",") if values.kind_of?(Array)
|
15
|
+
"Attachment"
|
12
16
|
else
|
13
|
-
|
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
@@ -25,16 +25,16 @@ describe 'hash extentions' do
|
|
25
25
|
payload.to_content_format
|
26
26
|
end
|
27
27
|
|
28
|
-
it "should
|
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:
|
4
|
+
hash: 59
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 16
|
10
|
+
version: 0.1.16
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- PJ Davis
|