line-message-builder 0.8.0 → 0.10.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/.release-please-manifest.json +1 -1
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +41 -0
- data/CLAUDE.md +124 -0
- data/CONVENTIONS.md +36 -0
- data/README.md +61 -43
- data/claudekit.json +11 -0
- data/docs/rubrics/rdoc.md +169 -0
- data/lib/line/message/builder/actions/message.rb +52 -31
- data/lib/line/message/builder/actions/postback.rb +63 -33
- data/lib/line/message/builder/actions/uri.rb +139 -0
- data/lib/line/message/builder/actions.rb +6 -3
- data/lib/line/message/builder/base.rb +92 -67
- data/lib/line/message/builder/container.rb +64 -69
- data/lib/line/message/builder/context.rb +55 -80
- data/lib/line/message/builder/flex/actionable.rb +53 -32
- data/lib/line/message/builder/flex/box.rb +366 -79
- data/lib/line/message/builder/flex/bubble.rb +78 -51
- data/lib/line/message/builder/flex/builder.rb +47 -36
- data/lib/line/message/builder/flex/button.rb +96 -48
- data/lib/line/message/builder/flex/carousel.rb +57 -29
- data/lib/line/message/builder/flex/icon.rb +152 -0
- data/lib/line/message/builder/flex/image.rb +103 -42
- data/lib/line/message/builder/flex/partial.rb +58 -55
- data/lib/line/message/builder/flex/position.rb +187 -100
- data/lib/line/message/builder/flex/separator.rb +84 -0
- data/lib/line/message/builder/flex/size.rb +67 -47
- data/lib/line/message/builder/flex/span.rb +184 -0
- data/lib/line/message/builder/flex/text.rb +210 -54
- data/lib/line/message/builder/flex.rb +31 -26
- data/lib/line/message/builder/quick_reply.rb +174 -4
- data/lib/line/message/builder/text.rb +70 -3
- data/lib/line/message/builder/version.rb +1 -1
- data/lib/line/message/builder.rb +16 -13
- data/lib/line/message/rspec/matchers/have_flex_bubble.rb +1 -1
- data/lib/line/message/rspec/matchers/have_flex_component.rb +26 -5
- data/lib/line/message/rspec/matchers/have_flex_message.rb +1 -1
- data/lib/line/message/rspec/matchers/have_flex_separator.rb +20 -0
- data/lib/line/message/rspec/matchers/have_quick_reply.rb +1 -1
- data/lib/line/message/rspec/matchers/have_text_message.rb +1 -1
- data/lib/line/message/rspec/matchers.rb +1 -0
- data/llm.txt +367 -45
- data/release-please-config.json +3 -1
- metadata +12 -3
|
@@ -4,64 +4,85 @@ module Line
|
|
|
4
4
|
module Message
|
|
5
5
|
module Builder
|
|
6
6
|
module Flex
|
|
7
|
-
# The
|
|
7
|
+
# The Actionable module provides a DSL for defining an action that can be
|
|
8
8
|
# triggered when a user interacts with certain Flex Message components
|
|
9
|
-
# (e.g., a
|
|
9
|
+
# (e.g., a Button component, or an entire Bubble or Box component
|
|
10
10
|
# if it's made tappable).
|
|
11
11
|
#
|
|
12
|
-
# When a component includes this module, it gains methods like
|
|
13
|
-
# and
|
|
14
|
-
# chosen action is stored in the
|
|
12
|
+
# When a component includes this module, it gains methods like +message+,
|
|
13
|
+
# +postback+ and +uri+ to associate a specific LINE action with itself.
|
|
14
|
+
# The chosen action is stored in the +action+ attribute.
|
|
15
15
|
#
|
|
16
|
-
#
|
|
17
|
-
# @return [Actions::Message, Actions::Postback, nil] The action object
|
|
18
|
-
# associated with this component. `nil` if no action is defined.
|
|
16
|
+
# == Attributes
|
|
19
17
|
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
18
|
+
# The following attribute is automatically added to classes that include
|
|
19
|
+
# this module:
|
|
20
|
+
#
|
|
21
|
+
# [action]
|
|
22
|
+
# The action object associated with this component. Returns an
|
|
23
|
+
# Actions::Message, Actions::Postback, or +nil+ if no action is defined.
|
|
24
|
+
#
|
|
25
|
+
# See also:
|
|
26
|
+
# - Line::Message::Builder::Actions::Message
|
|
27
|
+
# - Line::Message::Builder::Actions::Postback
|
|
28
|
+
# - Line::Message::Builder::Actions::Uri
|
|
29
|
+
# - https://developers.line.biz/en/reference/messaging-api/#action-objects
|
|
23
30
|
module Actionable
|
|
24
|
-
#
|
|
25
|
-
# Automatically adds an `attr_reader :action` to the class that includes
|
|
26
|
-
# this module.
|
|
27
|
-
# @param base [Class] The class including this module.
|
|
28
|
-
def self.included(base)
|
|
31
|
+
def self.included(base) # :nodoc:
|
|
29
32
|
base.attr_reader :action
|
|
30
33
|
end
|
|
31
34
|
|
|
32
35
|
# Defines a message action for the component.
|
|
33
|
-
# When the component is tapped, a message with the given
|
|
36
|
+
# When the component is tapped, a message with the given text is sent
|
|
34
37
|
# from the user to the chat.
|
|
35
38
|
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
39
|
+
# [text]
|
|
40
|
+
# The text of the message to send
|
|
41
|
+
# [options]
|
|
42
|
+
# Additional options for the message action, such as +:label+.
|
|
43
|
+
# See Actions::Message
|
|
44
|
+
#
|
|
45
|
+
# == Example
|
|
42
46
|
#
|
|
43
|
-
# @example Setting a message action on a button
|
|
44
47
|
# button_component.message "Hello User!", label: "Send Greeting"
|
|
45
48
|
def message(text, **options, &)
|
|
46
49
|
@action = Actions::Message.new(text, context: context, **options, &)
|
|
47
50
|
end
|
|
48
51
|
|
|
49
52
|
# Defines a postback action for the component.
|
|
50
|
-
# When the component is tapped, a postback event with the given
|
|
53
|
+
# When the component is tapped, a postback event with the given data
|
|
51
54
|
# is sent to the bot's webhook.
|
|
52
55
|
#
|
|
53
|
-
#
|
|
54
|
-
#
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
#
|
|
56
|
+
# [data]
|
|
57
|
+
# The data payload for the postback event
|
|
58
|
+
# [options]
|
|
59
|
+
# Additional options for the postback action, such as +:label+ or
|
|
60
|
+
# +:display_text+. See Actions::Postback
|
|
61
|
+
#
|
|
62
|
+
# == Example
|
|
59
63
|
#
|
|
60
|
-
# @example Setting a postback action on a button
|
|
61
64
|
# button_component.postback "action=buy&item_id=123", label: "Buy Item"
|
|
62
65
|
def postback(data, **options, &)
|
|
63
66
|
@action = Actions::Postback.new(data, context: context, **options, &)
|
|
64
67
|
end
|
|
68
|
+
|
|
69
|
+
# Defines a URI action for the component.
|
|
70
|
+
# When the component is tapped, the given URI is opened. No webhook
|
|
71
|
+
# handling is needed, which makes this the action to use for linking
|
|
72
|
+
# a component to a web page.
|
|
73
|
+
#
|
|
74
|
+
# [uri]
|
|
75
|
+
# The URI to open. Schemes +http+, +https+, +line+ and +tel+
|
|
76
|
+
# [options]
|
|
77
|
+
# Additional options for the URI action, such as +:label+ or
|
|
78
|
+
# +:alt_uri_desktop+. See Actions::Uri
|
|
79
|
+
#
|
|
80
|
+
# == Example
|
|
81
|
+
#
|
|
82
|
+
# button_component.uri "https://example.com", label: "Learn more"
|
|
83
|
+
def uri(uri, **options, &)
|
|
84
|
+
@action = Actions::Uri.new(uri, context: context, **options, &)
|
|
85
|
+
end
|
|
65
86
|
end
|
|
66
87
|
end
|
|
67
88
|
end
|