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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.release-please-manifest.json +1 -1
  3. data/.rubocop.yml +5 -0
  4. data/CHANGELOG.md +41 -0
  5. data/CLAUDE.md +124 -0
  6. data/CONVENTIONS.md +36 -0
  7. data/README.md +61 -43
  8. data/claudekit.json +11 -0
  9. data/docs/rubrics/rdoc.md +169 -0
  10. data/lib/line/message/builder/actions/message.rb +52 -31
  11. data/lib/line/message/builder/actions/postback.rb +63 -33
  12. data/lib/line/message/builder/actions/uri.rb +139 -0
  13. data/lib/line/message/builder/actions.rb +6 -3
  14. data/lib/line/message/builder/base.rb +92 -67
  15. data/lib/line/message/builder/container.rb +64 -69
  16. data/lib/line/message/builder/context.rb +55 -80
  17. data/lib/line/message/builder/flex/actionable.rb +53 -32
  18. data/lib/line/message/builder/flex/box.rb +366 -79
  19. data/lib/line/message/builder/flex/bubble.rb +78 -51
  20. data/lib/line/message/builder/flex/builder.rb +47 -36
  21. data/lib/line/message/builder/flex/button.rb +96 -48
  22. data/lib/line/message/builder/flex/carousel.rb +57 -29
  23. data/lib/line/message/builder/flex/icon.rb +152 -0
  24. data/lib/line/message/builder/flex/image.rb +103 -42
  25. data/lib/line/message/builder/flex/partial.rb +58 -55
  26. data/lib/line/message/builder/flex/position.rb +187 -100
  27. data/lib/line/message/builder/flex/separator.rb +84 -0
  28. data/lib/line/message/builder/flex/size.rb +67 -47
  29. data/lib/line/message/builder/flex/span.rb +184 -0
  30. data/lib/line/message/builder/flex/text.rb +210 -54
  31. data/lib/line/message/builder/flex.rb +31 -26
  32. data/lib/line/message/builder/quick_reply.rb +174 -4
  33. data/lib/line/message/builder/text.rb +70 -3
  34. data/lib/line/message/builder/version.rb +1 -1
  35. data/lib/line/message/builder.rb +16 -13
  36. data/lib/line/message/rspec/matchers/have_flex_bubble.rb +1 -1
  37. data/lib/line/message/rspec/matchers/have_flex_component.rb +26 -5
  38. data/lib/line/message/rspec/matchers/have_flex_message.rb +1 -1
  39. data/lib/line/message/rspec/matchers/have_flex_separator.rb +20 -0
  40. data/lib/line/message/rspec/matchers/have_quick_reply.rb +1 -1
  41. data/lib/line/message/rspec/matchers/have_text_message.rb +1 -1
  42. data/lib/line/message/rspec/matchers.rb +1 -0
  43. data/llm.txt +367 -45
  44. data/release-please-config.json +3 -1
  45. metadata +12 -3
@@ -4,64 +4,85 @@ module Line
4
4
  module Message
5
5
  module Builder
6
6
  module Flex
7
- # The `Actionable` module provides a DSL for defining an action that can be
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 {Button} component, or an entire {Bubble} or {Box} component
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 {#message}
13
- # and {#postback} to associate a specific LINE action with itself. The
14
- # chosen action is stored in the `action` attribute.
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
- # @!attribute [r] action
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
- # @see Line::Message::Builder::Actions::Message
21
- # @see Line::Message::Builder::Actions::Postback
22
- # @see https://developers.line.biz/en/reference/messaging-api/#action-objects
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
- # @!visibility private
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 `text` is sent
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
- # @param text [String] The text of the message to send.
37
- # @param options [Hash] Additional options for the message action,
38
- # such as `:label`. See {Actions::Message#initialize}.
39
- # @param block [Proc, nil] An optional block, though not typically used
40
- # directly for message actions here.
41
- # @return [Actions::Message] The created message action object.
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 `data`
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
- # @param data [String] The data payload for the postback event.
54
- # @param options [Hash] Additional options for the postback action,
55
- # such as `:label` or `:display_text`. See {Actions::Postback#initialize}.
56
- # @param block [Proc, nil] An optional block, though not typically used
57
- # directly for postback actions here.
58
- # @return [Actions::Postback] The created postback action object.
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