block-kit 1.0.3 → 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/base.rb +8 -0
- data/lib/block_kit/blocks.rb +2 -3
- data/lib/block_kit/composition/dispatch_action_config.rb +6 -3
- data/lib/block_kit/composition/slack_file.rb +1 -1
- data/lib/block_kit/composition/trigger.rb +4 -0
- data/lib/block_kit/composition.rb +1 -0
- data/lib/block_kit/concerns/confirmable.rb +2 -0
- data/lib/block_kit/concerns/conversation_selection.rb +3 -0
- data/lib/block_kit/concerns/dispatchable.rb +1 -1
- data/lib/block_kit/concerns/has_rich_text_elements.rb +1 -8
- data/lib/block_kit/concerns/plain_text_emoji_assignment.rb +2 -2
- data/lib/block_kit/elements/datetime_picker.rb +2 -0
- data/lib/block_kit/elements/image.rb +2 -0
- data/lib/block_kit/elements/overflow.rb +1 -1
- data/lib/block_kit/elements/time_picker.rb +2 -0
- data/lib/block_kit/elements.rb +2 -0
- data/lib/block_kit/layout/actions.rb +1 -8
- data/lib/block_kit/layout/context.rb +1 -8
- data/lib/block_kit/layout/image.rb +2 -0
- data/lib/block_kit/layout/rich_text/elements/channel.rb +2 -0
- data/lib/block_kit/layout/rich_text/elements/user.rb +2 -0
- data/lib/block_kit/layout/rich_text/elements/usergroup.rb +5 -0
- data/lib/block_kit/layout/rich_text/elements.rb +1 -0
- data/lib/block_kit/layout/rich_text/list.rb +1 -1
- data/lib/block_kit/layout/rich_text.rb +9 -16
- data/lib/block_kit/layout/video.rb +2 -0
- 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 +4 -3
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/base.rb
CHANGED
|
@@ -141,6 +141,10 @@ module BlockKit
|
|
|
141
141
|
plain_text_fields = type.block_class.attribute_types.select { |_, v| v.respond_to?(:block_class) && v.block_class == Composition::PlainText }.keys.map(&:to_sym)
|
|
142
142
|
|
|
143
143
|
define_method(as || attribute) do |args = {}, &block|
|
|
144
|
+
# Convert any args that were passed as attribute aliases to the actual attribute name while keeping
|
|
145
|
+
# the original arg names in case we need to reference them in a later error message.
|
|
146
|
+
attribute_aliases = type.block_class.attribute_aliases
|
|
147
|
+
args = args.transform_keys { |arg| attribute_aliases[arg.to_s] || arg } if attribute_aliases.any?
|
|
144
148
|
args = args.symbolize_keys
|
|
145
149
|
|
|
146
150
|
# Return the existing attribute if no args or block are passed and we're not in a custom-named method
|
|
@@ -161,6 +165,10 @@ module BlockKit
|
|
|
161
165
|
|
|
162
166
|
mutually_exclusive = mutually_exclusive_fields & args.keys
|
|
163
167
|
if mutually_exclusive.length > 1
|
|
168
|
+
# This is the only error message that might need to show original arg names
|
|
169
|
+
# based on aliases; missing or unknown fields can't be affected.
|
|
170
|
+
mutually_exclusive = mutually_exclusive.map { |arg| attribute_aliases.key(arg) || arg }
|
|
171
|
+
|
|
164
172
|
message = "mutually exclusive keywords: #{mutually_exclusive.map(&:inspect).join(", ")}"
|
|
165
173
|
raise ArgumentError, message
|
|
166
174
|
end
|
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,18 +10,19 @@ 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
|
|
|
17
|
+
alias_attribute :triggers, :trigger_actions_on
|
|
18
|
+
|
|
17
19
|
VALID_TRIGGERS.each do |value|
|
|
18
20
|
define_method(:"trigger_actions_on_#{value}?") do
|
|
19
21
|
!!trigger_actions_on&.member?(value)
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
define_method(:"trigger_actions_on_#{value}!") do
|
|
23
|
-
|
|
24
|
-
self.trigger_actions_on.add(value)
|
|
25
|
+
trigger_actions_on.add(value)
|
|
25
26
|
end
|
|
26
27
|
end
|
|
27
28
|
|
|
@@ -29,5 +30,7 @@ module BlockKit
|
|
|
29
30
|
super().except(:type).merge(trigger_actions_on: trigger_actions_on&.to_a).compact
|
|
30
31
|
end
|
|
31
32
|
end
|
|
33
|
+
|
|
34
|
+
DispatchActionConfiguration = DispatchActionConfig
|
|
32
35
|
end
|
|
33
36
|
end
|
|
@@ -16,6 +16,10 @@ module BlockKit
|
|
|
16
16
|
validates :customizable_input_parameters, presence: true, "block_kit/validators/associated": true, allow_nil: true
|
|
17
17
|
fixes :customizable_input_parameters, null_value: {error_types: [:blank]}
|
|
18
18
|
|
|
19
|
+
alias_attribute :input_parameters, :customizable_input_parameters
|
|
20
|
+
alias_attribute :customizable_input_params, :customizable_input_parameters
|
|
21
|
+
alias_attribute :input_params, :customizable_input_parameters
|
|
22
|
+
|
|
19
23
|
dsl_method :customizable_input_parameters, as: :customizable_input_parameter, required_fields: [:name, :value], yields: false
|
|
20
24
|
|
|
21
25
|
alias_method :input_parameter, :customizable_input_parameter
|
|
@@ -5,6 +5,7 @@ module BlockKit
|
|
|
5
5
|
autoload :ConfirmationDialog, "block_kit/composition/confirmation_dialog"
|
|
6
6
|
autoload :ConversationFilter, "block_kit/composition/conversation_filter"
|
|
7
7
|
autoload :DispatchActionConfig, "block_kit/composition/dispatch_action_config"
|
|
8
|
+
autoload :DispatchActionConfiguration, "block_kit/composition/dispatch_action_config"
|
|
8
9
|
autoload :InputParameter, "block_kit/composition/input_parameter"
|
|
9
10
|
autoload :Mrkdwn, "block_kit/composition/mrkdwn"
|
|
10
11
|
autoload :OptionGroup, "block_kit/composition/option_group"
|
|
@@ -10,6 +10,8 @@ module BlockKit
|
|
|
10
10
|
validates :confirm, "block_kit/validators/associated": true, allow_nil: true
|
|
11
11
|
fixes :confirm, associated: true
|
|
12
12
|
|
|
13
|
+
alias_attribute :confirmation_dialog, :confirm
|
|
14
|
+
|
|
13
15
|
dsl_method :confirm, required_fields: [:title, :text, :confirm, :deny], yields: false
|
|
14
16
|
end
|
|
15
17
|
|
|
@@ -9,10 +9,13 @@ module BlockKit
|
|
|
9
9
|
attribute :default_to_current_conversation, :boolean
|
|
10
10
|
attribute :filter, Types::Generic.of_type(Composition::ConversationFilter)
|
|
11
11
|
|
|
12
|
+
alias_attribute :conversation_filter, :filter
|
|
13
|
+
|
|
12
14
|
validates :filter, "block_kit/validators/associated": true, allow_nil: true
|
|
13
15
|
fixes :filter, associated: true
|
|
14
16
|
|
|
15
17
|
dsl_method :filter
|
|
18
|
+
alias_method :conversation_filter, :filter
|
|
16
19
|
end
|
|
17
20
|
|
|
18
21
|
def as_json(*)
|
|
@@ -7,13 +7,13 @@ module BlockKit
|
|
|
7
7
|
|
|
8
8
|
included do
|
|
9
9
|
attribute :dispatch_action_config, Types::Generic.of_type(Composition::DispatchActionConfig)
|
|
10
|
+
alias_attribute :dispatch_action_configuration, :dispatch_action_config
|
|
10
11
|
|
|
11
12
|
validates :dispatch_action_config, presence: true, "block_kit/validators/associated": true, allow_nil: true
|
|
12
13
|
fixes :dispatch_action_config, associated: true
|
|
13
14
|
|
|
14
15
|
dsl_method :dispatch_action_config
|
|
15
16
|
alias_method :dispatch_action_configuration, :dispatch_action_config
|
|
16
|
-
alias_attribute :dispatch_action_configuration, :dispatch_action_config
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def as_json(*)
|
|
@@ -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
|
|
@@ -5,12 +5,12 @@ module BlockKit
|
|
|
5
5
|
module PlainTextEmojiAssignment
|
|
6
6
|
def self.new(*attributes)
|
|
7
7
|
Module.new do
|
|
8
|
-
define_method(:initialize) do |attrs = {}|
|
|
8
|
+
define_method(:initialize) do |attrs = {}, &block|
|
|
9
9
|
raise ArgumentError, "expected `attributes' to be a Hash, got #{attrs.class}" unless attrs.is_a?(Hash)
|
|
10
10
|
|
|
11
11
|
emoji = attrs.delete(:emoji)
|
|
12
12
|
|
|
13
|
-
super(attrs)
|
|
13
|
+
super(attrs, &block)
|
|
14
14
|
|
|
15
15
|
unless emoji.nil?
|
|
16
16
|
attributes.each do |attribute|
|
|
@@ -14,6 +14,8 @@ module BlockKit
|
|
|
14
14
|
attribute :image_url, :string
|
|
15
15
|
attribute :slack_file, Types::Generic.of_type(Composition::SlackFile)
|
|
16
16
|
|
|
17
|
+
alias_attribute :url, :image_url
|
|
18
|
+
|
|
17
19
|
validates :alt_text, presence: true, length: {maximum: MAX_ALT_TEXT_LENGTH}
|
|
18
20
|
fixes :alt_text, truncate: {maximum: MAX_ALT_TEXT_LENGTH}
|
|
19
21
|
|
|
@@ -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
|
|
data/lib/block_kit/elements.rb
CHANGED
|
@@ -14,6 +14,7 @@ module BlockKit
|
|
|
14
14
|
autoload :ConversationsSelect, "block_kit/elements/conversations_select"
|
|
15
15
|
autoload :DatePicker, "block_kit/elements/date_picker"
|
|
16
16
|
autoload :DatetimePicker, "block_kit/elements/datetime_picker"
|
|
17
|
+
autoload :Datetimepicker, "block_kit/elements/datetime_picker"
|
|
17
18
|
autoload :EmailTextInput, "block_kit/elements/email_text_input"
|
|
18
19
|
autoload :ExternalSelect, "block_kit/elements/external_select"
|
|
19
20
|
autoload :FileInput, "block_kit/elements/file_input"
|
|
@@ -29,6 +30,7 @@ module BlockKit
|
|
|
29
30
|
autoload :RichTextInput, "block_kit/elements/rich_text_input"
|
|
30
31
|
autoload :StaticSelect, "block_kit/elements/static_select"
|
|
31
32
|
autoload :TimePicker, "block_kit/elements/time_picker"
|
|
33
|
+
autoload :Timepicker, "block_kit/elements/time_picker"
|
|
32
34
|
autoload :URLTextInput, "block_kit/elements/url_text_input"
|
|
33
35
|
autoload :UsersSelect, "block_kit/elements/users_select"
|
|
34
36
|
autoload :WorkflowButton, "block_kit/elements/workflow_button"
|
|
@@ -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."
|
|
@@ -16,6 +16,8 @@ module BlockKit
|
|
|
16
16
|
attribute :slack_file, Types::Generic.of_type(Composition::SlackFile)
|
|
17
17
|
plain_text_attribute :title
|
|
18
18
|
|
|
19
|
+
alias_attribute :url, :image_url
|
|
20
|
+
|
|
19
21
|
include Concerns::PlainTextEmojiAssignment.new(:title)
|
|
20
22
|
|
|
21
23
|
validates :alt_text, presence: true, length: {maximum: MAX_ALT_TEXT_LENGTH}
|
|
@@ -8,6 +8,9 @@ module BlockKit
|
|
|
8
8
|
attribute :usergroup_id, :string
|
|
9
9
|
attribute :style, Types::Generic.of_type(RichText::Elements::MentionStyle)
|
|
10
10
|
|
|
11
|
+
alias_attribute :user_group_id, :usergroup_id
|
|
12
|
+
alias_attribute :id, :usergroup_id
|
|
13
|
+
|
|
11
14
|
validates :usergroup_id, presence: true
|
|
12
15
|
|
|
13
16
|
def as_json(*)
|
|
@@ -17,5 +20,7 @@ module BlockKit
|
|
|
17
20
|
).compact
|
|
18
21
|
end
|
|
19
22
|
end
|
|
23
|
+
|
|
24
|
+
RichText::Elements::UserGroup = RichText::Elements::Usergroup
|
|
20
25
|
end
|
|
21
26
|
end
|
|
@@ -12,6 +12,7 @@ module BlockKit
|
|
|
12
12
|
autoload :Text, "block_kit/layout/rich_text/elements/text"
|
|
13
13
|
autoload :User, "block_kit/layout/rich_text/elements/user"
|
|
14
14
|
autoload :Usergroup, "block_kit/layout/rich_text/elements/usergroup"
|
|
15
|
+
autoload :UserGroup, "block_kit/layout/rich_text/elements/usergroup"
|
|
15
16
|
|
|
16
17
|
# Utility blocks
|
|
17
18
|
autoload :MentionStyle, "block_kit/layout/rich_text/elements/mention_style"
|
|
@@ -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,26 +18,19 @@ 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
|
|
|
25
|
-
dsl_method :elements, as: :
|
|
26
|
-
dsl_method :elements, as: :
|
|
27
|
-
dsl_method :elements, as: :
|
|
28
|
-
dsl_method :elements, as: :
|
|
25
|
+
dsl_method :elements, as: :rich_text_list, type: RichText::List
|
|
26
|
+
dsl_method :elements, as: :rich_text_preformatted, type: RichText::Preformatted
|
|
27
|
+
dsl_method :elements, as: :rich_text_quote, type: RichText::Quote
|
|
28
|
+
dsl_method :elements, as: :rich_text_section, type: RichText::Section
|
|
29
29
|
|
|
30
|
-
alias_method :
|
|
31
|
-
alias_method :
|
|
32
|
-
alias_method :
|
|
33
|
-
alias_method :
|
|
34
|
-
|
|
35
|
-
def initialize(attributes = {})
|
|
36
|
-
attributes = attributes.with_indifferent_access
|
|
37
|
-
attributes[:elements] ||= []
|
|
38
|
-
|
|
39
|
-
super
|
|
40
|
-
end
|
|
30
|
+
alias_method :list, :rich_text_list
|
|
31
|
+
alias_method :preformatted, :rich_text_preformatted
|
|
32
|
+
alias_method :quote, :rich_text_quote
|
|
33
|
+
alias_method :section, :rich_text_section
|
|
41
34
|
|
|
42
35
|
def append(element)
|
|
43
36
|
elements << element
|
|
@@ -24,6 +24,8 @@ module BlockKit
|
|
|
24
24
|
attribute :thumbnail_url, :string
|
|
25
25
|
attribute :video_url, :string
|
|
26
26
|
|
|
27
|
+
alias_attribute :url, :video_url
|
|
28
|
+
|
|
27
29
|
include Concerns::PlainTextEmojiAssignment.new(:description, :title)
|
|
28
30
|
|
|
29
31
|
validates :alt_text, presence: true, length: {maximum: MAX_ALT_TEXT_LENGTH}
|
|
@@ -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,13 +1,13 @@
|
|
|
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
|
|
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
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activemodel
|
|
@@ -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: []
|