slackened 0.0.2 → 0.0.3

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: 131cd9af2cc7798da89323458bdb71d379009074849eaa1afc2d1497aa73491d
4
- data.tar.gz: 1ef60c6aa2368e38b41f555f64bd49804f87832d2ba9cf58a58569045485c744
3
+ metadata.gz: 00dd4b571df1550a1c2dd80b2d7b468a593501173d265131981cbc79ea1def5f
4
+ data.tar.gz: 1302cc5ba42cb3b06e1741f5f36a7f09ec25c1da5e57a3c66f793bdfb9836ea8
5
5
  SHA512:
6
- metadata.gz: 6350be07eb3211b1d01035c657213df54d33ab1a8729749faf8aa7dbd3a66f075e336959d35fc538dba78de5f63ccbd1452b40d47c4a14cc5f58723c25c1f293
7
- data.tar.gz: bfce28774bab1611467e07016506b7694e4372fab927286e9158d6a05e4e6dbdafed48e9f905ff144aa31ab2b87d4bdf71a409ff0aee92e731fdeaa78eef2183
6
+ metadata.gz: 6afa6168cb4f0226b163c7d4f09839b54fe05992d6199954c72d200bf3d1389f6abe0be6e6dc5bced48d453a9e17e4ff8f041e76f5cb97943d4a177b13983ef9
7
+ data.tar.gz: f99b6f5678851983bdf7f4b417df9a7285177089b1506dbfb2655f60464708a63a902383ff61c835489d2ec0459b659d669b259f92c5798397360bb914f7fe0c
checksums.yaml.gz.sig CHANGED
Binary file
@@ -8,6 +8,7 @@ module Slackened
8
8
  module Blocks
9
9
  class Actions < Slackened::BlockKit::Blocks::Base
10
10
  MAX_LENGTH = 25
11
+ ELEMENTS = %i(button checkboxes datepicker datetimepicker email_text_input file_input image multi_static_select multi_external_select multi_users_select multi_conversations_select multi_channels_select number_input overflow plain_text_input radio_buttons rich_text_input option_groups external_select users_select conversations_select channels_select timepicker url_text_input workflow_button)
11
12
 
12
13
  def initialize(*elements)
13
14
  raise MinimumElementsError if elements.length.zero?
@@ -15,7 +16,11 @@ module Slackened
15
16
 
16
17
  set({
17
18
  type: :actions,
18
- elements:
19
+ elements: elements.map do |element|
20
+ raise InvalidElement unless ELEMENTS.include? element.block[:type]
21
+
22
+ element
23
+ end
19
24
  })
20
25
 
21
26
  self
@@ -14,6 +14,9 @@ module Slackened
14
14
  class MaximumElementsError < StandardError; end
15
15
 
16
16
  class MustBeString < StandardError; end
17
+ class MustBeHash < StandardError; end
18
+
19
+ class InvalidElement < StandardError; end
17
20
 
18
21
  class Base
19
22
  attr_accessor :block
@@ -10,7 +10,7 @@ module Slackened
10
10
  MAX_LENGTH = 10
11
11
 
12
12
  def initialize(*elements)
13
- raise TooManyElementsError, "#{elements.count} can't be greater than #{MAX_LENGTH}" if elements.length > MAX_LENGTH
13
+ raise MaximumElementsError, "#{elements.count} can't be greater than #{MAX_LENGTH}" if elements.length > MAX_LENGTH
14
14
 
15
15
  # TODO: need to allow for image
16
16
  # https://api.slack.com/reference/block-kit/blocks#context
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base'
4
+
5
+ module Slackened
6
+ module BlockKit
7
+ # proof of concept
8
+ module Blocks
9
+ class Custom < Slackened::BlockKit::Blocks::Base
10
+ def initialize(block)
11
+ raise MustBeHash unless block.is_a? Hash
12
+
13
+ set(block)
14
+
15
+ self
16
+ end
17
+
18
+ def to_h
19
+ @block.to_h
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -10,7 +10,7 @@ module Slackened
10
10
  MAX_LENGTH = 150
11
11
 
12
12
  def initialize(plain_text)
13
- raise TooManyCharactersError, "#{plain_text} can't be greater than #{MAX_LENGTH}" if plain_text.length > MAX_LENGTH
13
+ raise MaximumCharactersError, "#{plain_text} can't be greater than #{MAX_LENGTH}" if plain_text.length > MAX_LENGTH
14
14
  raise MustBeString unless plain_text.is_a? String
15
15
 
16
16
  set({
@@ -10,7 +10,7 @@ module Slackened
10
10
  MAX_LENGTH = 10
11
11
 
12
12
  def initialize(*fields) # rubocop:disable Metrics/MethodLength
13
- raise TooManyFieldsError, "#{fields.count} can't be greater than #{MAX_LENGTH}" if fields.length > MAX_LENGTH
13
+ raise MaximumFieldsError, "#{fields.count} can't be greater than #{MAX_LENGTH}" if fields.length > MAX_LENGTH
14
14
  raise MustBeString unless fields.all? { |f| f.is_a? String }
15
15
 
16
16
  if fields.one?
@@ -10,7 +10,7 @@ module Slackened
10
10
  MAX_LENGTH = 3000
11
11
 
12
12
  def initialize(markdown)
13
- raise TooManyCharactersError, "#{markdown.length} can't be greater than #{MAX_LENGTH}" if markdown.length > MAX_LENGTH
13
+ raise MaximumCharactersError, "#{markdown.length} can't be greater than #{MAX_LENGTH}" if markdown.length > MAX_LENGTH
14
14
 
15
15
  set({
16
16
  type: :mrkdwn,
@@ -9,7 +9,7 @@ module Slackened
9
9
  extend Forwardable
10
10
 
11
11
  # alphabetical
12
- def_delegators self, :actions, :button, :context, :divider, :header, :section, :text
12
+ def_delegators self, :actions, :button, :context, :custom, :divider, :header, :section, :text
13
13
 
14
14
  # alphabetical
15
15
  class << self
@@ -25,6 +25,10 @@ module Slackened
25
25
  Context.new(*elements)
26
26
  end
27
27
 
28
+ def custom(block)
29
+ Custom.new(block)
30
+ end
31
+
28
32
  def divider
29
33
  Divider.new
30
34
  end
data/lib/slackened.rb CHANGED
@@ -9,6 +9,7 @@ module Slackened
9
9
  require_relative 'slackened/block_kit/blocks/actions'
10
10
  require_relative 'slackened/block_kit/blocks/button'
11
11
  require_relative 'slackened/block_kit/blocks/context'
12
+ require_relative 'slackened/block_kit/blocks/custom'
12
13
  require_relative 'slackened/block_kit/blocks/divider'
13
14
  require_relative 'slackened/block_kit/blocks/header'
14
15
  require_relative 'slackened/block_kit/blocks/section'
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slackened
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Matyus
@@ -35,9 +35,9 @@ cert_chain:
35
35
  kSxIyBhjGtfFTmutQUKLBZmOzNf1g4sxY0BylDvd+Ce270mbViFvmpwkpiKpPqQQ
36
36
  2UTSf+Edp6/W5RDQoUAObJKcsvzDv5tp
37
37
  -----END CERTIFICATE-----
38
- date: 2024-07-01 00:00:00.000000000 Z
38
+ date: 2024-07-03 00:00:00.000000000 Z
39
39
  dependencies: []
40
- description: A lightweight interface interacting with the Slack APIs
40
+ description: A lightweight interface interacting with your Slack app via the web APIs
41
41
  email: michael@maty.us
42
42
  executables: []
43
43
  extensions: []
@@ -51,6 +51,7 @@ files:
51
51
  - lib/slackened/block_kit/blocks/base.rb
52
52
  - lib/slackened/block_kit/blocks/button.rb
53
53
  - lib/slackened/block_kit/blocks/context.rb
54
+ - lib/slackened/block_kit/blocks/custom.rb
54
55
  - lib/slackened/block_kit/blocks/divider.rb
55
56
  - lib/slackened/block_kit/blocks/header.rb
56
57
  - lib/slackened/block_kit/blocks/section.rb
@@ -66,7 +67,8 @@ licenses:
66
67
  metadata:
67
68
  rubygems_mfa_requirea: 'true'
68
69
  source_code_uri: https://github.com/matyus/slackened
69
- post_install_message: 'Slack stands for: Searchable Log of All Communication and Knowledge'
70
+ post_install_message: 'Did you know that Slack stands for: Searchable Log of All Communication
71
+ and Knowledge?'
70
72
  rdoc_options: []
71
73
  require_paths:
72
74
  - lib
@@ -81,11 +83,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
83
  - !ruby/object:Gem::Version
82
84
  version: '0'
83
85
  requirements:
84
- - '"Activate incoming webhooks" in your Slack App settings'
85
- - A valid webhook endpoint URL provided by Slack
86
- - Store the entire URL in an ENV variable outside your application
86
+ - '"Activate incoming webhooks" in your Slack App settings and store the URL secretly/securely/safely
87
+ outside of your codebase'
87
88
  rubygems_version: 3.4.10
88
89
  signing_key:
89
90
  specification_version: 4
90
- summary: Interact with Slack
91
+ summary: Interact with your Slack apps
91
92
  test_files: []
metadata.gz.sig CHANGED
Binary file