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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02abb717a3c9bf92e88f986bd17fe1ef469fa5c48d498ad7548ef784d01744ac
4
- data.tar.gz: c6cf2e666d479328551e19139c34f2362c9d53fe38cbca903c9fb57f3c7b58d9
3
+ metadata.gz: 97f3dbf3bfc26ecc2c071d81cbd97f4118ee0c2efc1f88abeea671c0438a9958
4
+ data.tar.gz: 6dc9d9790d72c6bcc07bfb38a6efb7119a5fdb6917a6ff605eb692d8c500aa7a
5
5
  SHA512:
6
- metadata.gz: 52394c972f2ca4d08f3b0f67375cdeb1012f5a11a74c435e290494adbc08e37e70661d0f1318a9e971af059df88ea33c18e7be68818c58066243e4d4b3224397
7
- data.tar.gz: df49a613f94f1d35890cc9fe51d5cb9c6d33b057457c7807a2018ee4a3487b33b2f9d6a366f1a416ad4f6805c2ed247c12c1e32bcb6f7a4c1dafb64287440a1b
6
+ metadata.gz: d5465b5268c6e3f2657f88b10c3eca98a145104324c9808727218a4bf433a61ac699b5b1be84bfeda1c782274a472c2f940d138a1f3ebb1fa88a77bcc8bc433d
7
+ data.tar.gz: 41f4a7c6876ca7df6255094ea06092879371acfebd9bfb8e1bf1f737da2bcdf4071f05bf3634092ab5fdb246592560853045ea3e63d58f21542f5ccb2c40a8e4
data/README.md CHANGED
@@ -1,28 +1,114 @@
1
1
  # Kamiflex
2
- Short description and motivation.
2
+ provide a pretty DSL to build your flex message like this:
3
3
 
4
- ## Usage
5
- How to use my plugin.
4
+ #### in ruby
5
+ ``` ruby
6
+ # flex_sample.rb
7
+ require 'kamiflex'
6
8
 
7
- ## Installation
8
- Add this line to your application's Gemfile:
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
- ```ruby
11
- gem 'kamiflex'
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
- And then execute:
15
- ```bash
16
- $ bundle
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
- Or install it yourself as:
20
- ```bash
21
- $ gem install kamiflex
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
- ## Contributing
25
- Contribution directions go here.
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).
@@ -1,3 +1,3 @@
1
1
  module Kamiflex
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kamiflex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - etrex kuo