kamiflex 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kamiflex/core.rb +26 -4
- data/lib/kamiflex/version.rb +1 -1
- data/lib/kamiflex.rb +12 -6
- 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: 2c263b635edb1b2ec1f8ce031a6cb03a02322ea41d0729c3ce33562c8ddc545d
|
4
|
+
data.tar.gz: 7e3ff12df6581d21b24fea462187cd8ecae8c0127b91b90788f37b4c19cb7e54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d317727a0f21b3410cf0e3668cf4d42ba5678172b408e03ef71c21e38c8b80529f142dabc85bd732d8b237d4c6107d554b64cc75d2e35babcd124e2d573a653
|
7
|
+
data.tar.gz: ac3bbee99bfb10890f40fb92d07531acd25d35692f0a8da07f20ed4f9e6999e08b14c662f196e4a84774fdac2db297ab9b12c5708f50cc4010e5a3a59d6c8c89
|
data/lib/kamiflex/core.rb
CHANGED
@@ -1,16 +1,38 @@
|
|
1
1
|
module Kamiflex
|
2
2
|
module Core
|
3
|
-
def
|
3
|
+
def flex
|
4
4
|
attributes, _contents = flex_scope{ yield }
|
5
5
|
{
|
6
6
|
type: "flex",
|
7
7
|
altText: "this is a flex message",
|
8
|
-
contents:
|
9
|
-
type: "bubble"
|
10
|
-
}.merge(attributes.slice(:header, :hero, :body, :footer, :style))
|
8
|
+
contents: _contents.first
|
11
9
|
}.merge(attributes.slice(:quickReply))
|
12
10
|
end
|
13
11
|
|
12
|
+
def bubble
|
13
|
+
attributes, _contents = flex_scope{ yield }
|
14
|
+
@flex_contents << {
|
15
|
+
type: "bubble"
|
16
|
+
}.merge(attributes.slice(:size, :direction, :header, :hero, :body, :footer, :style, :action))
|
17
|
+
end
|
18
|
+
|
19
|
+
def bubbles(resources)
|
20
|
+
resources.each do |resource|
|
21
|
+
attributes, _contents = flex_scope{ yield resource }
|
22
|
+
@flex_contents << {
|
23
|
+
type: "bubble",
|
24
|
+
}.merge(attributes.slice(:size, :direction, :header, :hero, :body, :footer, :style, :action))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def carousel
|
29
|
+
attributes, _contents = flex_scope{ yield }
|
30
|
+
@flex_contents << {
|
31
|
+
type: "carousel",
|
32
|
+
contents: _contents
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
14
36
|
# bubble attributes
|
15
37
|
def header(**params)
|
16
38
|
_attributes, contents = flex_scope{ yield }
|
data/lib/kamiflex/version.rb
CHANGED
data/lib/kamiflex.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require "json"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
require_relative "./kamiflex/core"
|
3
|
+
require_relative "./kamiflex/basic_elements"
|
4
|
+
require_relative "./kamiflex/actions"
|
5
|
+
require_relative "./kamiflex/quick_reply"
|
6
6
|
|
7
7
|
module Kamiflex
|
8
8
|
def self.build(parent)
|
@@ -10,9 +10,15 @@ module Kamiflex
|
|
10
10
|
parent.class.include Kamiflex::BasicElements
|
11
11
|
parent.class.include Kamiflex::Actions
|
12
12
|
parent.class.include Kamiflex::QuickReply
|
13
|
-
|
13
|
+
|
14
|
+
hash = parent.instance_exec do
|
15
|
+
flex do
|
16
|
+
yield
|
17
|
+
end
|
18
|
+
end
|
19
|
+
JSON.pretty_generate hash
|
14
20
|
end
|
15
21
|
end
|
16
22
|
|
17
23
|
Mime::Type.register_alias "application/json", :line if defined?(Rails)
|
18
|
-
|
24
|
+
require_relative "./kamiflex/railtie" if defined?(Rails)
|
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.9.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: 2019-
|
11
|
+
date: 2019-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|