block-kit 1.0.4 → 1.0.5
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/.tool-versions +1 -0
- data/lib/block_kit/blocks.rb +2 -3
- data/lib/block_kit/composition/dispatch_action_config.rb +2 -3
- data/lib/block_kit/concerns/has_rich_text_elements.rb +1 -8
- data/lib/block_kit/elements/overflow.rb +1 -1
- data/lib/block_kit/layout/actions.rb +1 -8
- data/lib/block_kit/layout/context.rb +1 -8
- data/lib/block_kit/layout/rich_text/list.rb +1 -1
- data/lib/block_kit/layout/rich_text.rb +1 -8
- data/lib/block_kit/surfaces/base.rb +1 -1
- data/lib/block_kit/surfaces/home.rb +0 -7
- data/lib/block_kit/surfaces/message.rb +1 -8
- data/lib/block_kit/surfaces/modal.rb +0 -7
- data/lib/block_kit/version.rb +1 -1
- data/lib/block_kit.rb +8 -8
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9eb45957df50e7755b070ec1e7167490ab8f9f399699ee5de352552f43b6946f
|
4
|
+
data.tar.gz: bc88817b9ba976aa1e4804d5e42feb85fa6d42fdcc74cd029ff8f2272ebf3c90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f41484044c660930c2c4754fcff3e97e046da19cb14ffd6e4a1af83055e6e5ebcd9d5ca16ec04a538db0e8fc9b22490951ac37f0b27ecbae1401ab3bd0b068de
|
7
|
+
data.tar.gz: fbce285e1a58fb5c91309743fbdff18a01c477d9779e44c07336c62253957cc8a0507316476fa49fffa1696a1187e12cc32e57119df2dfea93ee0c6dddbc9fcf
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.4.4
|
data/lib/block_kit/blocks.rb
CHANGED
@@ -4,7 +4,7 @@ require "active_support/core_ext/module/delegation"
|
|
4
4
|
|
5
5
|
module BlockKit
|
6
6
|
class Blocks < Base
|
7
|
-
attribute :blocks, Types::Array.of(Types::Blocks.new(*Layout.all))
|
7
|
+
attribute :blocks, Types::Array.of(Types::Blocks.new(*Layout.all)), default: []
|
8
8
|
validates :blocks, "block_kit/validators/associated": true
|
9
9
|
fixes :blocks, associated: true
|
10
10
|
|
@@ -22,8 +22,7 @@ module BlockKit
|
|
22
22
|
delegate_missing_to :blocks
|
23
23
|
|
24
24
|
def initialize(attributes = {})
|
25
|
-
attributes = attributes.
|
26
|
-
attributes[:blocks] ||= []
|
25
|
+
attributes = {blocks: attributes} if attributes.is_a?(Array)
|
27
26
|
|
28
27
|
super
|
29
28
|
end
|
@@ -10,7 +10,7 @@ module BlockKit
|
|
10
10
|
ON_CHARACTER_ENTERED = "on_character_entered"
|
11
11
|
].freeze
|
12
12
|
|
13
|
-
attribute :trigger_actions_on, Types::Set.of(:string)
|
13
|
+
attribute :trigger_actions_on, Types::Set.of(:string), default: []
|
14
14
|
validates :trigger_actions_on, presence: true, "block_kit/validators/array_inclusion": {in: VALID_TRIGGERS}
|
15
15
|
fixes :trigger_actions_on, null_value: {error_types: [:inclusion]}
|
16
16
|
|
@@ -22,8 +22,7 @@ module BlockKit
|
|
22
22
|
end
|
23
23
|
|
24
24
|
define_method(:"trigger_actions_on_#{value}!") do
|
25
|
-
|
26
|
-
self.trigger_actions_on.add(value)
|
25
|
+
trigger_actions_on.add(value)
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
@@ -6,7 +6,7 @@ module BlockKit
|
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
included do
|
9
|
-
attribute :elements, Types::Array.of(Types::Blocks.new(*Layout::RichText::Elements.all))
|
9
|
+
attribute :elements, Types::Array.of(Types::Blocks.new(*Layout::RichText::Elements.all)), default: []
|
10
10
|
validates :elements, presence: true, "block_kit/validators/associated": true
|
11
11
|
fixes :elements, associated: true
|
12
12
|
|
@@ -16,13 +16,6 @@ module BlockKit
|
|
16
16
|
dsl_method :elements, as: :emoji, type: Layout::RichText::Elements::Emoji, required_fields: [:name], yields: false
|
17
17
|
end
|
18
18
|
|
19
|
-
def initialize(attributes = {})
|
20
|
-
attributes = attributes.with_indifferent_access
|
21
|
-
attributes[:elements] ||= []
|
22
|
-
|
23
|
-
super
|
24
|
-
end
|
25
|
-
|
26
19
|
def channel(channel_id:, styles: [])
|
27
20
|
style = if styles.present?
|
28
21
|
styles = Array(styles).map { |s| [s.to_s, true] }.to_h
|
@@ -9,7 +9,7 @@ module BlockKit
|
|
9
9
|
|
10
10
|
include Concerns::Confirmable
|
11
11
|
|
12
|
-
attribute :options, Types::Array.of(Composition::OverflowOption)
|
12
|
+
attribute :options, Types::Array.of(Composition::OverflowOption), default: []
|
13
13
|
validates :options, presence: true, length: {maximum: MAX_OPTIONS, message: "is too long (maximum is %{count} options)"}, "block_kit/validators/associated": true
|
14
14
|
fixes :options, truncate: {maximum: MAX_OPTIONS, dangerous: true}, associated: true
|
15
15
|
|
@@ -28,14 +28,7 @@ module BlockKit
|
|
28
28
|
Elements::WorkflowButton
|
29
29
|
]
|
30
30
|
|
31
|
-
|
32
|
-
attributes = attributes.with_indifferent_access
|
33
|
-
attributes[:elements] ||= []
|
34
|
-
|
35
|
-
super
|
36
|
-
end
|
37
|
-
|
38
|
-
attribute :elements, Types::Array.of(Types::Blocks.new(*SUPPORTED_ELEMENTS))
|
31
|
+
attribute :elements, Types::Array.of(Types::Blocks.new(*SUPPORTED_ELEMENTS)), default: []
|
39
32
|
validates :elements, presence: true, length: {maximum: MAX_ELEMENTS, message: "is too long (maximum is %{count} elements)"}, "block_kit/validators/associated": true
|
40
33
|
fixes :elements, truncate: {maximum: MAX_ELEMENTS, dangerous: true}, associated: true
|
41
34
|
|
@@ -12,20 +12,13 @@ module BlockKit
|
|
12
12
|
Composition::PlainText
|
13
13
|
].freeze
|
14
14
|
|
15
|
-
attribute :elements, Types::Array.of(Types::Blocks.new(*SUPPORTED_ELEMENTS))
|
15
|
+
attribute :elements, Types::Array.of(Types::Blocks.new(*SUPPORTED_ELEMENTS)), default: []
|
16
16
|
validates :elements, presence: true, length: {maximum: MAX_ELEMENTS, message: "is too long (maximum is %{count} elements)"}, "block_kit/validators/associated": true
|
17
17
|
fixes :elements, truncate: {maximum: MAX_ELEMENTS, dangerous: true}, associated: true
|
18
18
|
|
19
19
|
dsl_method :elements, as: :mrkdwn, type: Composition::Mrkdwn, required_fields: [:text], yields: false
|
20
20
|
dsl_method :elements, as: :plain_text, type: Composition::PlainText, required_fields: [:text], yields: false
|
21
21
|
|
22
|
-
def initialize(attributes = {})
|
23
|
-
attributes = attributes.with_indifferent_access
|
24
|
-
attributes[:elements] ||= []
|
25
|
-
|
26
|
-
super
|
27
|
-
end
|
28
|
-
|
29
22
|
def image(alt_text:, image_url: nil, slack_file: nil)
|
30
23
|
if (image_url.nil? && slack_file.nil?) || (image_url && slack_file)
|
31
24
|
raise ArgumentError, "Must provide either image_url or slack_file, but not both."
|
@@ -11,7 +11,7 @@ module BlockKit
|
|
11
11
|
].freeze
|
12
12
|
|
13
13
|
attribute :style, :string
|
14
|
-
attribute :elements, Types::Array.of(RichText::Section)
|
14
|
+
attribute :elements, Types::Array.of(RichText::Section), default: []
|
15
15
|
attribute :indent, :integer
|
16
16
|
attribute :offset, :integer
|
17
17
|
attribute :border, :integer
|
@@ -18,7 +18,7 @@ module BlockKit
|
|
18
18
|
RichText::Section
|
19
19
|
].freeze
|
20
20
|
|
21
|
-
attribute :elements, Types::Array.of(Types::Blocks.new(*SUPPORTED_ELEMENTS))
|
21
|
+
attribute :elements, Types::Array.of(Types::Blocks.new(*SUPPORTED_ELEMENTS)), default: []
|
22
22
|
validates :elements, presence: true, "block_kit/validators/associated": true
|
23
23
|
fixes :elements, associated: true
|
24
24
|
|
@@ -32,13 +32,6 @@ module BlockKit
|
|
32
32
|
alias_method :quote, :rich_text_quote
|
33
33
|
alias_method :section, :rich_text_section
|
34
34
|
|
35
|
-
def initialize(attributes = {})
|
36
|
-
attributes = attributes.with_indifferent_access
|
37
|
-
attributes[:elements] ||= []
|
38
|
-
|
39
|
-
super
|
40
|
-
end
|
41
|
-
|
42
35
|
def append(element)
|
43
36
|
elements << element
|
44
37
|
|
@@ -20,7 +20,7 @@ module BlockKit
|
|
20
20
|
Layout::Video
|
21
21
|
]
|
22
22
|
|
23
|
-
attribute :blocks, Types::Array.of(Types::Blocks.new(*SUPPORTED_BLOCKS))
|
23
|
+
attribute :blocks, Types::Array.of(Types::Blocks.new(*SUPPORTED_BLOCKS)), default: []
|
24
24
|
attribute :private_metadata, :string
|
25
25
|
attribute :callback_id, :string
|
26
26
|
attribute :external_id, :string
|
@@ -32,7 +32,7 @@ module BlockKit
|
|
32
32
|
].freeze
|
33
33
|
|
34
34
|
attribute :text, :string
|
35
|
-
attribute :blocks, Types::Array.of(Types::Blocks.new(*Layout.all))
|
35
|
+
attribute :blocks, Types::Array.of(Types::Blocks.new(*Layout.all)), default: []
|
36
36
|
attribute :thread_ts, :string
|
37
37
|
attribute :mrkdwn, :boolean
|
38
38
|
|
@@ -53,13 +53,6 @@ module BlockKit
|
|
53
53
|
dsl_method :blocks, as: :section, type: Layout::Section
|
54
54
|
dsl_method :blocks, as: :video, type: Layout::Video, required_fields: [:alt_text, :title, :thumbnail_url, :video_url], yields: false
|
55
55
|
|
56
|
-
def initialize(attributes = {})
|
57
|
-
attributes = attributes.with_indifferent_access
|
58
|
-
attributes[:blocks] ||= []
|
59
|
-
|
60
|
-
super
|
61
|
-
end
|
62
|
-
|
63
56
|
def image(alt_text:, image_url: nil, slack_file: nil, title: nil, emoji: nil, block_id: nil)
|
64
57
|
if (image_url.nil? && slack_file.nil?) || (image_url && slack_file)
|
65
58
|
raise ArgumentError, "Must provide either image_url or slack_file, but not both."
|
@@ -54,13 +54,6 @@ module BlockKit
|
|
54
54
|
fixes :submit, truncate: {maximum: MAX_BUTTON_LENGTH}, null_value: {error_types: [:blank]}
|
55
55
|
fix :add_default_submit_button
|
56
56
|
|
57
|
-
def initialize(attributes = {})
|
58
|
-
attributes = attributes.with_indifferent_access
|
59
|
-
attributes[:blocks] ||= []
|
60
|
-
|
61
|
-
super
|
62
|
-
end
|
63
|
-
|
64
57
|
def as_json(*)
|
65
58
|
super.merge(
|
66
59
|
title: title&.as_json,
|
data/lib/block_kit/version.rb
CHANGED
data/lib/block_kit.rb
CHANGED
@@ -20,19 +20,19 @@ module BlockKit
|
|
20
20
|
|
21
21
|
autoload :VERSION, "block_kit/version"
|
22
22
|
|
23
|
-
def self.blocks(&block)
|
24
|
-
Blocks.new(&block)
|
23
|
+
def self.blocks(attributes = {}, &block)
|
24
|
+
Blocks.new(attributes, &block)
|
25
25
|
end
|
26
26
|
|
27
|
-
def self.home(&block)
|
28
|
-
Surfaces::Home.new(&block)
|
27
|
+
def self.home(attributes = {}, &block)
|
28
|
+
Surfaces::Home.new(attributes, &block)
|
29
29
|
end
|
30
30
|
|
31
|
-
def self.modal(&block)
|
32
|
-
Surfaces::Modal.new(&block)
|
31
|
+
def self.modal(attributes = {}, &block)
|
32
|
+
Surfaces::Modal.new(attributes, &block)
|
33
33
|
end
|
34
34
|
|
35
|
-
def self.message(&block)
|
36
|
-
Surfaces::Message.new(&block)
|
35
|
+
def self.message(attributes = {}, &block)
|
36
|
+
Surfaces::Message.new(attributes, &block)
|
37
37
|
end
|
38
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: block-kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Celis
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- ".rspec"
|
49
|
+
- ".tool-versions"
|
49
50
|
- CODE_OF_CONDUCT.md
|
50
51
|
- LICENSE.txt
|
51
52
|
- README.md
|
@@ -184,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
185
|
- !ruby/object:Gem::Version
|
185
186
|
version: '0'
|
186
187
|
requirements: []
|
187
|
-
rubygems_version: 3.6.
|
188
|
+
rubygems_version: 3.6.7
|
188
189
|
specification_version: 4
|
189
190
|
summary: A powerful DSL-based library for Slack's Block Kit framework.
|
190
191
|
test_files: []
|