kamiflex 0.2.0 â 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +101 -15
- data/lib/kamiflex/version.rb +1 -1
- data/lib/kamiflex.rb +5 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97f3dbf3bfc26ecc2c071d81cbd97f4118ee0c2efc1f88abeea671c0438a9958
|
4
|
+
data.tar.gz: 6dc9d9790d72c6bcc07bfb38a6efb7119a5fdb6917a6ff605eb692d8c500aa7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5465b5268c6e3f2657f88b10c3eca98a145104324c9808727218a4bf433a61ac699b5b1be84bfeda1c782274a472c2f940d138a1f3ebb1fa88a77bcc8bc433d
|
7
|
+
data.tar.gz: 41f4a7c6876ca7df6255094ea06092879371acfebd9bfb8e1bf1f737da2bcdf4071f05bf3634092ab5fdb246592560853045ea3e63d58f21542f5ccb2c40a8e4
|
data/README.md
CHANGED
@@ -1,28 +1,114 @@
|
|
1
1
|
# Kamiflex
|
2
|
-
|
2
|
+
provide a pretty DSL to build your flex message like this:
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
#### in ruby
|
5
|
+
``` ruby
|
6
|
+
# flex_sample.rb
|
7
|
+
require 'kamiflex'
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
+
@todos = [
|
10
|
+
{
|
11
|
+
id: 1,
|
12
|
+
name: "ruby"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
id: 2,
|
16
|
+
name: "rails"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
id: 3,
|
20
|
+
name: "kamiflex"
|
21
|
+
}
|
22
|
+
]
|
9
23
|
|
10
|
-
|
11
|
-
|
24
|
+
puts Kamiflex.build(self) do
|
25
|
+
bubble do
|
26
|
+
body do
|
27
|
+
horizontal_box do
|
28
|
+
text "đ", flex: 0, action: message_action("/")
|
29
|
+
text "Todos"
|
30
|
+
text "đ", align: "end", action: uri_action(new_todo_path))
|
31
|
+
end
|
32
|
+
separator
|
33
|
+
if @todos.present?
|
34
|
+
vertical_box margin: "lg" do
|
35
|
+
horizontal_box @todos, margin: "lg" do |todo|
|
36
|
+
text todo[:name], action: message_action("/todos/#{todo[:id]}")
|
37
|
+
text "â", align: "end", action: message_action("DELETE /todos/#{todo[:id]}")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
else
|
41
|
+
text "no contents yet", margin: "lg"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
12
46
|
```
|
13
47
|
|
14
|
-
|
15
|
-
```
|
16
|
-
|
48
|
+
#### in rails
|
49
|
+
``` ruby
|
50
|
+
# todos/index.line.erb
|
51
|
+
<%= raw(Kamiflex.build(self) do
|
52
|
+
bubble do
|
53
|
+
body do
|
54
|
+
horizontal_box do
|
55
|
+
text "đ", flex: 0, action: message_action("/")
|
56
|
+
text "Todos"
|
57
|
+
text "đ", align: "end", action: uri_action(new_todo_path))
|
58
|
+
end
|
59
|
+
separator
|
60
|
+
if @todos.present?
|
61
|
+
vertical_box margin: "lg" do
|
62
|
+
horizontal_box @todos, margin: "lg" do |todo|
|
63
|
+
text todo.name, action: message_action("/todos/#{todo.id}")
|
64
|
+
text "â", align: "end", action: message_action("DELETE /todos/#{todo.id}")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
else
|
68
|
+
text "no contents yet", margin: "lg"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end )%>
|
17
73
|
```
|
18
74
|
|
19
|
-
|
20
|
-
|
21
|
-
|
75
|
+
the render result looks like this:
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
I will add a template name `flex` for rails in the future.
|
81
|
+
|
82
|
+
``` ruby
|
83
|
+
# todos/index.line.flex
|
84
|
+
bubble do
|
85
|
+
body do
|
86
|
+
horizontal_box do
|
87
|
+
text "đ", flex: 0, action: message_action("/")
|
88
|
+
text "Todos"
|
89
|
+
text "đ", align: "end", action: uri_action(new_todo_path))
|
90
|
+
end
|
91
|
+
separator
|
92
|
+
if @todos.present?
|
93
|
+
vertical_box margin: "lg" do
|
94
|
+
horizontal_box @todos, margin: "lg" do |todo|
|
95
|
+
text todo.name, action: message_action("/todos/#{todo.id}")
|
96
|
+
text "â", align: "end", action: message_action("DELETE /todos/#{todo.id}")
|
97
|
+
end
|
98
|
+
end
|
99
|
+
else
|
100
|
+
text "ć˛ćçŽĺĺ
§ĺŽš", margin: "lg"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
22
104
|
```
|
23
105
|
|
24
|
-
##
|
25
|
-
|
106
|
+
## Installation
|
107
|
+
Add this line to your application's Gemfile:
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
gem 'kamiflex'
|
111
|
+
```
|
26
112
|
|
27
113
|
## License
|
28
114
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/kamiflex/version.rb
CHANGED
data/lib/kamiflex.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
require "kamiflex/railtie"
|
2
1
|
require "kamiflex/core"
|
3
2
|
require "kamiflex/basic_elements"
|
4
3
|
require "kamiflex/actions"
|
5
4
|
require "kamiflex/quick_reply"
|
6
5
|
|
6
|
+
Mime::Type.register "application/json", :line
|
7
|
+
|
7
8
|
module Kamiflex
|
8
9
|
def self.build(parent)
|
9
10
|
parent.class.include Kamiflex::Core
|
@@ -12,4 +13,6 @@ module Kamiflex
|
|
12
13
|
parent.class.include Kamiflex::QuickReply
|
13
14
|
JSON.pretty_generate yield
|
14
15
|
end
|
15
|
-
end
|
16
|
+
end
|
17
|
+
|
18
|
+
require "kamiflex/railtie" if defined?(Rails)
|