kamiflex 0.16.0 → 0.17.0

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
  SHA256:
3
- metadata.gz: f720f54831cd629b5e9ac62071f89fe6bf94c048724a09855a42f925651b95b1
4
- data.tar.gz: 74803c3a50ae3b7815f5129198957fa14da4795575980d5d3205866c690addaa
3
+ metadata.gz: 3aebab2a944c48f712b4a67eb0e647f681752c5e6a12d0ad0643dcf94aef3100
4
+ data.tar.gz: 1cfcd6b3b0608f67dd4194544b77040d9637a5dcb3a94408163c0a9f536c9326
5
5
  SHA512:
6
- metadata.gz: 382b0159bd2c5b8690429197c70c9abddc0c6544094efed5ca40700dcdad3c2adc138d432f52b92ce312d3393a2c7c3ac9d1bc43217ce039bde37854e2ccef6a
7
- data.tar.gz: 9ec944b733f1d561ceea2c0bb3e598887946a8906ae6bcf365d7f1606f168fef92d19642890b5d58573ca1dcb717aa8b291a08330e8c28b989712d3bc67142eb
6
+ metadata.gz: 25a72620cf4bc5a5f06ab54254eb4697c0fc212b7946d924a61a09232123a75dae3d6a07db165f46f2631dcb7b90f34ba4902d819f385add4e80fedb48aa1968
7
+ data.tar.gz: fd76b82aa9368e3a00cc3c38aae6bf73b07460d067e9258ad17a36eac286b21f7995794ebbb3ce2bfb1d97c1f63ec6d038b8a015c2c14bfc5d365de3a8942bc7
data/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Kamiflex
2
2
  Kamiflex provide a pretty DSL to build your [flex message of line messaging api](https://developers.line.biz/en/docs/messaging-api/using-flex-messages/) like this:
3
3
 
4
+
5
+ # Live Demo
6
+
7
+ [Kamiflex Simulator](https://kamiflex.etrex.tw/)
8
+
4
9
  #### in pure ruby
5
10
 
6
11
  # [example/show_cases/cards.rb](example/show_cases/cards.rb)
@@ -1,8 +1,23 @@
1
1
  module Kamiflex
2
2
  module BasicElements
3
- def text(message, **params)
3
+ def text(message = nil, **params)
4
+ if block_given?
5
+ _attributes, contents = flex_scope{ yield }
6
+ @flex_contents << {
7
+ type: "text",
8
+ contents: contents,
9
+ }.merge(params)
10
+ else
11
+ @flex_contents << {
12
+ type: "text",
13
+ text: message
14
+ }.merge(params)
15
+ end
16
+ end
17
+
18
+ def span(message, **params)
4
19
  @flex_contents << {
5
- "type": "text",
20
+ "type": "span",
6
21
  "text": message
7
22
  }.merge(params)
8
23
  end
data/lib/kamiflex/core.rb CHANGED
@@ -82,11 +82,11 @@ module Kamiflex
82
82
  # container
83
83
  def horizontal_box(resources = [nil], **params)
84
84
  resources.each_with_index do |resource, index|
85
- _attributes, contents = flex_scope{ yield(resource, index) }
85
+ _attributes, contents = flex_scope{ yield(resource, index) } if block_given?
86
86
  @flex_contents << {
87
87
  type: "box",
88
88
  layout: "horizontal",
89
- contents: contents
89
+ contents: contents || []
90
90
  }.merge(params)
91
91
  end
92
92
  end
@@ -1,3 +1,3 @@
1
1
  module Kamiflex
2
- VERSION = '0.16.0'
2
+ VERSION = '0.17.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kamiflex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - etrex kuo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-09 00:00:00.000000000 Z
11
+ date: 2021-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json