block-kit 1.0.3 → 1.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 033e781b6f1656644ae2038ad1c4d1575f9fe1e9179da732127edb43895612c7
4
- data.tar.gz: dbb788025b21764ec964ccfa6c7b2409f47990e64990e62dde1d96ab11e28dd5
3
+ metadata.gz: 5946d09896645506f0cab7a25f94081426cb76aff710daba32f7435c39a85eef
4
+ data.tar.gz: 29c70c2b4165a6b91751b25ad8b8492a97dc76b4e9bfd36b3c21c41a41ec112b
5
5
  SHA512:
6
- metadata.gz: c9fac2d8adf017f7fcdb109ad1c55f011668c5ec3d2e716d895aaaf38e95d46846b8b7c7a78989e7c8cd40f2ec3a05bf3448d9f9332465757bf7ebe512a55caf
7
- data.tar.gz: 777df84ebe6aa32be0ff508d52138bda2546fa5ce0ba60a00aa255637ae3274e78f89382a7cb7dbc70cbbbf91dee43fa937477c30e48aa88ead22e7ebe96dce9
6
+ metadata.gz: 92fde835090a61e50d948414f7cc6cf470fa60d46fa7ac7043e24e868949a69d04a93e4fdc25c7e8a916ffa0f43ab4fc36c741b674156ff8b062a5db509f23fb
7
+ data.tar.gz: 2fccbc33a2b9cf5475829a7fd8f75b96131f734a87ef19003761587809c5c82892833d3bf876403cccb70e6bf0d5ad743b089e72ab0dd3911dc22773819c1224
@@ -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
@@ -14,6 +14,8 @@ module BlockKit
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)
@@ -29,5 +31,7 @@ module BlockKit
29
31
  super().except(:type).merge(trigger_actions_on: trigger_actions_on&.to_a).compact
30
32
  end
31
33
  end
34
+
35
+ DispatchActionConfiguration = DispatchActionConfig
32
36
  end
33
37
  end
@@ -21,7 +21,7 @@ module BlockKit
21
21
  validate :id_or_url_present
22
22
 
23
23
  def as_json(*)
24
- super().except(:type).merge(id: id, url: url).compact
24
+ {id: id, url: url}.compact
25
25
  end
26
26
 
27
27
  private
@@ -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(*)
@@ -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|
@@ -17,5 +17,7 @@ module BlockKit
17
17
  super.merge(initial_date_time: initial_date_time&.to_i).compact
18
18
  end
19
19
  end
20
+
21
+ Datetimepicker = DatetimePicker
20
22
  end
21
23
  end
@@ -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
 
@@ -39,5 +39,7 @@ module BlockKit
39
39
  end
40
40
  end
41
41
  end
42
+
43
+ Timepicker = TimePicker
42
44
  end
43
45
  end
@@ -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"
@@ -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,8 @@ module BlockKit
8
8
  attribute :channel_id, :string
9
9
  attribute :style, Types::Generic.of_type(RichText::Elements::MentionStyle)
10
10
 
11
+ alias_attribute :id, :channel_id
12
+
11
13
  validates :channel_id, presence: true
12
14
 
13
15
  def as_json(*)
@@ -8,6 +8,8 @@ module BlockKit
8
8
  attribute :user_id, :string
9
9
  attribute :style, Types::Generic.of_type(RichText::Elements::MentionStyle)
10
10
 
11
+ alias_attribute :id, :user_id
12
+
11
13
  validates :user_id, presence: true
12
14
 
13
15
  def as_json(*)
@@ -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"
@@ -22,15 +22,15 @@ module BlockKit
22
22
  validates :elements, presence: true, "block_kit/validators/associated": true
23
23
  fixes :elements, associated: true
24
24
 
25
- dsl_method :elements, as: :list, type: RichText::List
26
- dsl_method :elements, as: :preformatted, type: RichText::Preformatted
27
- dsl_method :elements, as: :quote, type: RichText::Quote
28
- dsl_method :elements, as: :section, type: RichText::Section
29
-
30
- alias_method :rich_text_list, :list
31
- alias_method :rich_text_preformatted, :preformatted
32
- alias_method :rich_text_quote, :quote
33
- alias_method :rich_text_section, :section
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
+
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
34
34
 
35
35
  def initialize(attributes = {})
36
36
  attributes = attributes.with_indifferent_access
@@ -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}
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BlockKit
4
- VERSION = "1.0.3"
4
+ VERSION = "1.0.4"
5
5
  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.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Celis
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-04-24 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activemodel
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  - !ruby/object:Gem::Version
185
185
  version: '0'
186
186
  requirements: []
187
- rubygems_version: 3.6.6
187
+ rubygems_version: 3.6.8
188
188
  specification_version: 4
189
189
  summary: A powerful DSL-based library for Slack's Block Kit framework.
190
190
  test_files: []