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 +4 -4
- data/README.md +5 -0
- data/lib/kamiflex/basic_elements.rb +17 -2
- data/lib/kamiflex/core.rb +2 -2
- data/lib/kamiflex/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3aebab2a944c48f712b4a67eb0e647f681752c5e6a12d0ad0643dcf94aef3100
|
4
|
+
data.tar.gz: 1cfcd6b3b0608f67dd4194544b77040d9637a5dcb3a94408163c0a9f536c9326
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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": "
|
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
|
data/lib/kamiflex/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2021-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|