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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53211ab3c004339dedfcd6f895601c5dfecc8c2941510f3ddc87a6b8fd1578e2
4
- data.tar.gz: 01f8866b0ddf537251cb8e9cc19f0c12d7d8ca232ecb6fa03ddadc62aadcc841
3
+ metadata.gz: 2c263b635edb1b2ec1f8ce031a6cb03a02322ea41d0729c3ce33562c8ddc545d
4
+ data.tar.gz: 7e3ff12df6581d21b24fea462187cd8ecae8c0127b91b90788f37b4c19cb7e54
5
5
  SHA512:
6
- metadata.gz: 567e76c064f7ed38a571799dbf8b2f5b1dbc344ace00a17266c6f8c6ccfda96080e20c1257b0d1bd5b4a73a8268c1e9da9d0e0e3b7a25180e431e5c0c51e5f94
7
- data.tar.gz: 8515ee6f6380fc748a27984cd39d9fd31f8e73d41976404d0d706cb13c5a7ec8adba22a2d7ddf2a9c42d46dc59b6d71b9cbf301e286128343e5bec018b0bd651
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 bubble
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 }
@@ -1,3 +1,3 @@
1
1
  module Kamiflex
2
- VERSION = '0.8.0'
2
+ VERSION = '0.9.0'
3
3
  end
data/lib/kamiflex.rb CHANGED
@@ -1,8 +1,8 @@
1
1
  require "json"
2
- require "kamiflex/core"
3
- require "kamiflex/basic_elements"
4
- require "kamiflex/actions"
5
- require "kamiflex/quick_reply"
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
- JSON.pretty_generate yield
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
- require "kamiflex/railtie" if defined?(Rails)
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.8.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-05-02 00:00:00.000000000 Z
11
+ date: 2019-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json