line-message-builder 0.6.0 → 0.7.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/CHANGELOG.md +16 -0
- data/README.md +54 -0
- data/lib/line/message/builder/base.rb +1 -1
- data/lib/line/message/builder/context.rb +30 -0
- data/lib/line/message/builder/flex/box.rb +1 -0
- data/lib/line/message/builder/flex/bubble.rb +2 -0
- data/lib/line/message/builder/flex/carousel.rb +2 -0
- data/lib/line/message/builder/flex/partial.rb +44 -0
- data/lib/line/message/builder/flex/position.rb +6 -6
- data/lib/line/message/builder/flex/size.rb +4 -4
- data/lib/line/message/builder/flex.rb +3 -0
- data/lib/line/message/builder/version.rb +1 -1
- data/lib/line/message/builder.rb +1 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e34932b3afe2a1bbe05967e19991c2d1af583094e2b60be909efa9c773296fe
|
4
|
+
data.tar.gz: 2c7c94550e9b29a943b517aa5b19a9d03ec213a8779df05b1d0c55a886b8872b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c60b5ee94ee4e2f8dc658acace8538af12c9ee374f48b5fb5577c4baf43d93d661b2b47e18d8d09ee7f0e99f9fdbd0cdc3ce05e9bfd54c96ad36acd82b7b0cb6
|
7
|
+
data.tar.gz: afb292eec260c30163e79d8108471a7a5db4a722d6f44d54de7e25ae884375968addb2b6be9271240a6aae58023539acaca99109eeba95fc016e0e4aae94f0c8
|
@@ -1 +1 @@
|
|
1
|
-
{".":"0.
|
1
|
+
{".":"0.7.0"}
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.7.0](https://github.com/elct9620/line-message-builder/compare/v0.6.1...v0.7.0) (2025-05-21)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* add assigns feature to flex partial with context override ([76c1d34](https://github.com/elct9620/line-message-builder/commit/76c1d34569d031ce6ddf64e948d33cd26a12b231))
|
9
|
+
* add context with assigns support for flex message partials ([1c4c89f](https://github.com/elct9620/line-message-builder/commit/1c4c89f590dd251fb0def48109961469c136bd86))
|
10
|
+
* add partial support for Flex message components ([57ff183](https://github.com/elct9620/line-message-builder/commit/57ff183b173e4c62e7119862df343c9d8a1174bd))
|
11
|
+
|
12
|
+
## [0.6.1](https://github.com/elct9620/line-message-builder/compare/v0.6.0...v0.6.1) (2025-05-13)
|
13
|
+
|
14
|
+
|
15
|
+
### Bug Fixes
|
16
|
+
|
17
|
+
* change default option values from :nil to nil ([4f87919](https://github.com/elct9620/line-message-builder/commit/4f879191b129b7a1780b690c9949afe9e8f87bcc))
|
18
|
+
|
3
19
|
## [0.6.0](https://github.com/elct9620/line-message-builder/compare/v0.5.0...v0.6.0) (2025-04-07)
|
4
20
|
|
5
21
|
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://github.com/elct9620/line-message-builder/actions/workflows/main.yml)
|
4
4
|
[](https://codecov.io/gh/elct9620/line-message-builder)
|
5
|
+
[](https://deepwiki.com/elct9620/line-message-builder)
|
5
6
|
|
6
7
|
Build LINE messages using DSL (Domain Specific Language) in Ruby.
|
7
8
|
|
@@ -98,6 +99,59 @@ builder = Line::MessageBuilder::Builder.with(context) do
|
|
98
99
|
end
|
99
100
|
```
|
100
101
|
|
102
|
+
### Partial
|
103
|
+
|
104
|
+
> [!WARNING]
|
105
|
+
> This is experimental and may change in the future.
|
106
|
+
|
107
|
+
You can create a partial object to reuse the same structure in the `Carousel`, `Bubble`, or `Box`.
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
# Reuse the bubble structure in the Carousel
|
111
|
+
class CardPartial < Line::Message::Builder::Flex::Partial
|
112
|
+
def call
|
113
|
+
body do
|
114
|
+
text "Hello World!"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
builder = Line::MessageBuilder::Builder.with do
|
120
|
+
carousel do
|
121
|
+
3.times do |i|
|
122
|
+
bubble do
|
123
|
+
partial! CardPartial
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
```
|
129
|
+
|
130
|
+
The partial can have `assigns` feature to provide variables to the partial.
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
class CardPartial < Line::Message::Builder::Flex::Partial
|
134
|
+
def call
|
135
|
+
body do
|
136
|
+
text "Card #{idx}!"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
builder = Line::MessageBuilder::Builder.with do
|
142
|
+
carousel do
|
143
|
+
3.times do |i|
|
144
|
+
bubble do
|
145
|
+
partial! CardPartial, idx: i
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
```
|
151
|
+
|
152
|
+
> [!NOTE]
|
153
|
+
> The assigns will override the context variables.
|
154
|
+
|
101
155
|
### RSpec Matcher
|
102
156
|
|
103
157
|
| Matcher | Description |
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Line
|
4
|
+
module Message
|
5
|
+
module Builder
|
6
|
+
# The context is wrapper for the context object to provide assigns support.
|
7
|
+
class Context
|
8
|
+
attr_accessor :assigns
|
9
|
+
|
10
|
+
def initialize(context)
|
11
|
+
@context = context
|
12
|
+
@assigns = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
def respond_to_missing?(method_name, include_private = false)
|
16
|
+
@assigns.key?(method_name) ||
|
17
|
+
@context.respond_to?(method_name, include_private) ||
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def method_missing(method_name, ...)
|
22
|
+
return @assigns[method_name] if @assigns.key?(method_name)
|
23
|
+
return @context.public_send(method_name, ...) if @context.respond_to?(method_name)
|
24
|
+
|
25
|
+
super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Line
|
4
|
+
module Message
|
5
|
+
module Builder
|
6
|
+
module Flex
|
7
|
+
# Define a partial that can be reused in flex message.
|
8
|
+
module HasPartial
|
9
|
+
def partial!(partial, **assigns)
|
10
|
+
raise ArgumentError, "Not a partial" unless partial < Partial
|
11
|
+
|
12
|
+
prev = context.assigns
|
13
|
+
context.assigns = assigns
|
14
|
+
partial.new(context: self).call
|
15
|
+
context.assigns = prev
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# The partial designed to be reused in flex message.
|
20
|
+
class Partial
|
21
|
+
def initialize(context:)
|
22
|
+
@context = context
|
23
|
+
end
|
24
|
+
|
25
|
+
def call(*)
|
26
|
+
raise NotImplementedError, "The #{self.class} class must implement the call method"
|
27
|
+
end
|
28
|
+
|
29
|
+
def respond_to_missing?(method_name, include_private = false)
|
30
|
+
@context.respond_to?(method_name, include_private) || super
|
31
|
+
end
|
32
|
+
|
33
|
+
def method_missing(method_name, ...)
|
34
|
+
if @context.respond_to?(method_name)
|
35
|
+
@context.public_send(method_name, ...)
|
36
|
+
else
|
37
|
+
super
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -9,7 +9,7 @@ module Line
|
|
9
9
|
module Horizontal
|
10
10
|
def self.included(base)
|
11
11
|
base.option :align,
|
12
|
-
default:
|
12
|
+
default: nil,
|
13
13
|
validator: Validators::Enum.new(
|
14
14
|
:start, :center, :end
|
15
15
|
)
|
@@ -20,7 +20,7 @@ module Line
|
|
20
20
|
module Vertical
|
21
21
|
def self.included(base)
|
22
22
|
base.option :gravity,
|
23
|
-
default:
|
23
|
+
default: nil,
|
24
24
|
validator: Validators::Enum.new(
|
25
25
|
:top, :center, :bottom
|
26
26
|
)
|
@@ -32,7 +32,7 @@ module Line
|
|
32
32
|
def self.included(base)
|
33
33
|
%i[padding padding_top padding_bottom padding_start padding_end].each do |option|
|
34
34
|
base.option option,
|
35
|
-
default:
|
35
|
+
default: nil,
|
36
36
|
validator: Validators::Size.new(:pixel, :keyword, :percentage)
|
37
37
|
end
|
38
38
|
end
|
@@ -42,7 +42,7 @@ module Line
|
|
42
42
|
module Margin
|
43
43
|
def self.included(base)
|
44
44
|
base.option :margin,
|
45
|
-
default:
|
45
|
+
default: nil,
|
46
46
|
validator: Validators::Size.new(:pixel, :keyword)
|
47
47
|
end
|
48
48
|
end
|
@@ -51,12 +51,12 @@ module Line
|
|
51
51
|
module Offset
|
52
52
|
def self.included(base)
|
53
53
|
base.option :position,
|
54
|
-
default:
|
54
|
+
default: nil,
|
55
55
|
validator: Validators::Enum.new(:absolute, :relative)
|
56
56
|
|
57
57
|
%i[offset_top offset_bottom offset_start offset_end].each do |option|
|
58
58
|
base.option option,
|
59
|
-
default:
|
59
|
+
default: nil,
|
60
60
|
validator: Validators::Size.new(:pixel, :keyword)
|
61
61
|
end
|
62
62
|
end
|
@@ -9,7 +9,7 @@ module Line
|
|
9
9
|
module Flex
|
10
10
|
def self.included(base)
|
11
11
|
base.option :flex,
|
12
|
-
default:
|
12
|
+
default: nil
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -17,7 +17,7 @@ module Line
|
|
17
17
|
module Image
|
18
18
|
def self.included(base)
|
19
19
|
base.option :size,
|
20
|
-
default:
|
20
|
+
default: nil,
|
21
21
|
validator: Validators::Size.new(:pixel, :image, :percentage)
|
22
22
|
end
|
23
23
|
end
|
@@ -26,7 +26,7 @@ module Line
|
|
26
26
|
module Shared
|
27
27
|
def self.included(base)
|
28
28
|
base.option :size,
|
29
|
-
default:
|
29
|
+
default: nil,
|
30
30
|
validator: Validators::Size.new(:pixel, :keyword)
|
31
31
|
end
|
32
32
|
end
|
@@ -35,7 +35,7 @@ module Line
|
|
35
35
|
module AdjustMode
|
36
36
|
def self.included(base)
|
37
37
|
base.option :adjust_mode,
|
38
|
-
default:
|
38
|
+
default: nil,
|
39
39
|
validator: Validators::Enum.new(
|
40
40
|
:"shrink-to-fit"
|
41
41
|
)
|
data/lib/line/message/builder.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: line-message-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aotokitsuruya
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: The LINE Messaging API message builder.
|
13
13
|
email:
|
@@ -30,6 +30,7 @@ files:
|
|
30
30
|
- lib/line/message/builder/actions/postback.rb
|
31
31
|
- lib/line/message/builder/base.rb
|
32
32
|
- lib/line/message/builder/container.rb
|
33
|
+
- lib/line/message/builder/context.rb
|
33
34
|
- lib/line/message/builder/flex.rb
|
34
35
|
- lib/line/message/builder/flex/actionable.rb
|
35
36
|
- lib/line/message/builder/flex/box.rb
|
@@ -38,6 +39,7 @@ files:
|
|
38
39
|
- lib/line/message/builder/flex/button.rb
|
39
40
|
- lib/line/message/builder/flex/carousel.rb
|
40
41
|
- lib/line/message/builder/flex/image.rb
|
42
|
+
- lib/line/message/builder/flex/partial.rb
|
41
43
|
- lib/line/message/builder/flex/position.rb
|
42
44
|
- lib/line/message/builder/flex/size.rb
|
43
45
|
- lib/line/message/builder/flex/text.rb
|
@@ -79,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
81
|
- !ruby/object:Gem::Version
|
80
82
|
version: '0'
|
81
83
|
requirements: []
|
82
|
-
rubygems_version: 3.6.
|
84
|
+
rubygems_version: 3.6.7
|
83
85
|
specification_version: 4
|
84
86
|
summary: The LINE Messaging API message builder.
|
85
87
|
test_files: []
|