idobata 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/idobata.rb +0 -1
- data/lib/idobata/message.rb +15 -4
- data/lib/idobata/version.rb +1 -1
- data/spec/lib/idobata/message_spec.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c626065e8bc3b6273d0b79a703cfcbe2c6d9d877
|
4
|
+
data.tar.gz: f5d13bd409bda36b71815039ad9b4427fcf35a3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2018806db983b584c9521d0a9d06123127bdbb8ee50f70ad9d990c14c9246eaa5d88b12748844d12fe7bc21d73086e7a0f006e4ad7b0fe3e736e26ffdabe35fa
|
7
|
+
data.tar.gz: a20db4aaabb0df69428201c13fd624d7f3c2153322828610a58cb52c352cd725307f6771521c5b502209ceae830366f64f685fbb27901a1a4ee042709027a765
|
data/lib/idobata.rb
CHANGED
data/lib/idobata/message.rb
CHANGED
@@ -6,12 +6,23 @@ module Idobata
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.label_writer(params)
|
9
|
-
|
10
|
-
|
9
|
+
labels =
|
10
|
+
if params[:label].nil?
|
11
|
+
[]
|
12
|
+
elsif params[:label].respond_to?(:to_ary)
|
13
|
+
params[:label].to_ary || [params[:label]]
|
14
|
+
else
|
15
|
+
[params[:label]]
|
16
|
+
end
|
17
|
+
|
18
|
+
label_tags = labels.map do |label|
|
11
19
|
type = label[:type] ? "label-#{label[:type]}" : ""
|
12
|
-
|
13
|
-
params[:format] = :html unless params[:format] == :html
|
20
|
+
"<span class='label #{type}'>#{label[:text]}</span>"
|
14
21
|
end
|
22
|
+
|
23
|
+
params[:source] = "#{label_tags.join(' ')} #{params[:source]}"
|
24
|
+
params[:format] = :html unless labels.empty?
|
25
|
+
|
15
26
|
params
|
16
27
|
end
|
17
28
|
end
|
data/lib/idobata/version.rb
CHANGED
@@ -41,5 +41,22 @@ describe Idobata::Message do
|
|
41
41
|
expect(formatting_params[:source]).to match("<span class='label label-success'>DEPLOY</span>")
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
45
|
+
context "when specify multiple labels" do
|
46
|
+
let(:params) {
|
47
|
+
{
|
48
|
+
source: "hello idobata",
|
49
|
+
format: :html,
|
50
|
+
label: [
|
51
|
+
{ type: :inverse, text: "Inverse" },
|
52
|
+
{ type: :warning, text: "Warning" }
|
53
|
+
]
|
54
|
+
}
|
55
|
+
}
|
56
|
+
subject(:formatting_params) { Idobata::Message.label_writer(params) }
|
57
|
+
it "should include span tags" do
|
58
|
+
expect(formatting_params[:source]).to match("<span class='label label-inverse'>Inverse</span> <span class='label label-warning'>Warning</span>")
|
59
|
+
end
|
60
|
+
end
|
44
61
|
end
|
45
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: idobata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- asonas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|