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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 274e050da86f19328898e97cc9336f481d3969a4
4
- data.tar.gz: 0fc42c2cc73b1c8f34c39d34148299b82a7872e6
3
+ metadata.gz: c626065e8bc3b6273d0b79a703cfcbe2c6d9d877
4
+ data.tar.gz: f5d13bd409bda36b71815039ad9b4427fcf35a3f
5
5
  SHA512:
6
- metadata.gz: c444ec4f9da6c43166a191c060722eb6124449bc7c8343c914584cc662e322ef4f5ed71fd6814a29be0052328591df445960648fcf476dc73943b032a7dc6e73
7
- data.tar.gz: 7367ad17b957785a571ebc80c265052554e45b0ce5219b34f3c210bc481c5d324cfa4e89e9076aea9390f2d224fd647c05eec22e9766df72ddb37b34a48d531b
6
+ metadata.gz: 2018806db983b584c9521d0a9d06123127bdbb8ee50f70ad9d990c14c9246eaa5d88b12748844d12fe7bc21d73086e7a0f006e4ad7b0fe3e736e26ffdabe35fa
7
+ data.tar.gz: a20db4aaabb0df69428201c13fd624d7f3c2153322828610a58cb52c352cd725307f6771521c5b502209ceae830366f64f685fbb27901a1a4ee042709027a765
@@ -3,7 +3,6 @@ require "idobata/version"
3
3
  module Idobata
4
4
  autoload(:Client, 'idobata/client')
5
5
  autoload(:Message, 'idobata/message')
6
- autoload(:Support, 'idobata/support')
7
6
 
8
7
  @hook_url = nil
9
8
 
@@ -6,12 +6,23 @@ module Idobata
6
6
  end
7
7
 
8
8
  def self.label_writer(params)
9
- label = params[:label]
10
- if label
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
- params[:source] = "<span class='label #{type}'>#{label[:text]}</span> #{params[:source]}"
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
@@ -1,3 +1,3 @@
1
1
  module Idobata
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -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.8
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-08-28 00:00:00.000000000 Z
11
+ date: 2014-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday