slack-ruby-block-kit 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba4b59b1f8d591f6560563d913833ea5193d3c0ad1ff46e30b4484949d8cfeda
4
- data.tar.gz: 90c8576e1fadb6b9a17d8e6c76f9c871e073fa0cab1e9178a26959b80e62b1fa
3
+ metadata.gz: 31d357b44cc9c6e928a1ddc3e469393befde7bcc565416167e76767835551115
4
+ data.tar.gz: 942fb2311a0e388e7fe4d2fe40a76b2c398583fe06facdac05547b2d3102b6b1
5
5
  SHA512:
6
- metadata.gz: 37e969657c3cd6f54fd0f4d9a77292b4740917463823b84af9325a87455b6b686af353d98769a09d6e36e2ddd503e62fc1d460f981c359326deb87232349d89c
7
- data.tar.gz: af06784a17f10737b24c85b3ee2b59dd34f0bd61da21e19234d1cca04e213a195ca5698ec8ddbb876dd3a8fdf5894814b2c39da65305747f78a907401fbf5ccb
6
+ metadata.gz: 93c87de2988ede207c6950fd00ed7c68a84cb30cefeeeb105ce8309595f7135ef5db5ed3a9fa2ebf02e06b0744c0633ac3cd551ac9d93c43462ca1c8a1cb9d9f
7
+ data.tar.gz: 591a9b52614a626dccbe11dd1ddbf3ec6114f54f509209643d7e6eeac5a213d2e1262842c345ffab18af86e58fecec90ea7f5372403a2f8a03f36e131b5933dc
@@ -53,3 +53,15 @@ Style/HashTransformValues:
53
53
 
54
54
  Style/SlicingWithRange:
55
55
  Enabled: true
56
+
57
+ Lint/MixedRegexpCaptureTypes:
58
+ Enabled: true
59
+
60
+ Style/RedundantFetchBlock:
61
+ Enabled: true
62
+
63
+ Style/RedundantRegexpCharacterClass:
64
+ Enabled: true
65
+
66
+ Style/RedundantRegexpEscape:
67
+ Enabled: true
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slack-ruby-block-kit (0.8.0)
4
+ slack-ruby-block-kit (0.9.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -6,12 +6,13 @@ module Slack
6
6
  module Element; end
7
7
  module Layout; end
8
8
 
9
- VERSION = '0.8.0'
9
+ VERSION = '0.9.0'
10
10
 
11
11
  Dir[File.join(__dir__, 'block_kit', 'composition', '*.rb')].sort.each { |file| require file }
12
12
  Dir[File.join(__dir__, 'block_kit', 'element', '*.rb')].sort.each { |file| require file }
13
13
  Dir[File.join(__dir__, 'block_kit', 'layout', '*.rb')].sort.each { |file| require file }
14
14
  Dir[File.join(__dir__, 'block_kit', '*.rb')].sort.each { |file| require file }
15
+ Dir[File.join(__dir__, 'surfaces', '*.rb')].sort.each { |file| require file }
15
16
 
16
17
  module_function
17
18
 
@@ -22,5 +23,48 @@ module Slack
22
23
 
23
24
  blocks
24
25
  end
26
+
27
+ def home(blocks: nil,
28
+ private_metadata: nil, callback_id: nil, external_id: nil)
29
+ home_surface = Slack::Surfaces::Home.new(blocks: blocks,
30
+ private_metadata: private_metadata,
31
+ callback_id: callback_id,
32
+ external_id: external_id)
33
+
34
+ yield(home_surface) if block_given?
35
+
36
+ home_surface
37
+ end
38
+
39
+ def modal(title: nil,
40
+ blocks: nil,
41
+ private_metadata: nil, callback_id: nil, external_id: nil,
42
+ clear_on_close: nil, notify_on_close: nil)
43
+ modal_surface = Slack::Surfaces::Modal.new(title: title,
44
+ blocks: blocks,
45
+ private_metadata: private_metadata,
46
+ callback_id: callback_id,
47
+ external_id: external_id,
48
+ clear_on_close: clear_on_close,
49
+ notify_on_close: notify_on_close)
50
+
51
+ yield(modal_surface) if block_given?
52
+
53
+ modal_surface
54
+ end
55
+
56
+ def message(blocks: nil, channel: nil, thread_ts: nil, as_user: nil, text: nil)
57
+ message_surface = Slack::Surfaces::Message.new(
58
+ blocks: blocks,
59
+ channel: channel,
60
+ thread_ts: thread_ts,
61
+ text: text,
62
+ as_user: as_user
63
+ )
64
+
65
+ yield(message_surface) if block_given?
66
+
67
+ message_surface
68
+ end
25
69
  end
26
70
  end
@@ -13,10 +13,7 @@ module Slack
13
13
  @image_url = url
14
14
  @alt_text = alt_text
15
15
  @block_id = block_id
16
-
17
- return unless title
18
-
19
- @title = Composition::PlainText.new(
16
+ @title = title && Composition::PlainText.new(
20
17
  text: title,
21
18
  emoji: emoji
22
19
  )
@@ -157,7 +157,7 @@ module Slack
157
157
  end
158
158
 
159
159
  def image(url:, alt_text:)
160
- accessorize(Element::Image.new(image_url: url, alt_text: alt_text))
160
+ accessorise(Element::Image.new(image_url: url, alt_text: alt_text))
161
161
  end
162
162
 
163
163
  def accessorise(element)
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Slack
4
+ module Surfaces
5
+ # The Home tab is a persistent, yet dynamic interface
6
+ # for apps that lives within the App Home.
7
+ #
8
+ # https://api.slack.com/surfaces#tabs
9
+ # https://api.slack.com/reference/surfaces/views
10
+ class Home
11
+ TYPE = 'home'
12
+
13
+ def initialize(blocks: nil,
14
+ private_metadata: nil, callback_id: nil, external_id: nil)
15
+ @blocks = blocks || Slack::BlockKit::Blocks.new
16
+
17
+ @private_metadata = private_metadata
18
+ @callback_id = callback_id
19
+ @external_id = external_id
20
+ end
21
+
22
+ attr_reader :blocks
23
+
24
+ def as_json(*)
25
+ {
26
+ type: TYPE,
27
+ blocks: @blocks.as_json,
28
+ private_metadata: @private_metadata,
29
+ callback_id: @callback_id,
30
+ external_id: @external_id
31
+ }.compact
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Slack
4
+ module Surfaces
5
+ # App-published messages are dynamic yet transient spaces.
6
+ # They allow users to complete workflows among their Slack conversations.
7
+ #
8
+ # https://api.slack.com/surfaces#messages
9
+ # https://api.slack.com/messaging/composing#complex_layouts
10
+ class Message
11
+ TYPE = 'message'
12
+
13
+ def initialize(blocks: nil, text: nil, channel: nil, thread_ts: nil, as_user: nil)
14
+ @blocks = blocks || Slack::BlockKit::Blocks.new
15
+ @channel = channel
16
+ @thread_ts = thread_ts
17
+ @as_user = as_user
18
+ @text = text
19
+ end
20
+
21
+ attr_reader :blocks
22
+
23
+ def as_json(*)
24
+ {
25
+ channel: @channel,
26
+ thread_ts: @thread_ts,
27
+ as_user: @as_user,
28
+ text: @text,
29
+ blocks: @blocks.as_json
30
+ }.compact
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Slack
4
+ module Surfaces
5
+ # Modals provide focused spaces ideal for requesting and collecting data from users,
6
+ # or temporarily displaying dynamic and interactive information.
7
+ #
8
+ # https://api.slack.com/surfaces#modals
9
+ # https://api.slack.com/reference/surfaces/views
10
+ #
11
+ # @param title [String] title is required. Must be set as an initial argument
12
+ # or using #title for detail setup
13
+ #
14
+ class Modal
15
+ TYPE = 'modal'
16
+
17
+ def initialize(
18
+ title: nil,
19
+ blocks: nil,
20
+ private_metadata: nil,
21
+ callback_id: nil,
22
+ external_id: nil,
23
+ clear_on_close: nil,
24
+ notify_on_close: nil
25
+ )
26
+ @blocks = blocks || Slack::BlockKit::Blocks.new
27
+
28
+ @private_metadata = private_metadata
29
+ @callback_id = callback_id
30
+ @external_id = external_id
31
+
32
+ @clear_on_close = clear_on_close
33
+ @notify_on_close = notify_on_close
34
+
35
+ @title = Slack::BlockKit::Composition::PlainText.new(text: title) if title
36
+
37
+ @close, @submit = nil
38
+ end
39
+
40
+ attr_reader :blocks
41
+
42
+ def title(text:, emoji: nil)
43
+ @title = Slack::BlockKit::Composition::PlainText.new(text: text, emoji: emoji)
44
+
45
+ self
46
+ end
47
+
48
+ def close(text:, emoji: nil)
49
+ @close = Slack::BlockKit::Composition::PlainText.new(text: text, emoji: emoji)
50
+
51
+ self
52
+ end
53
+
54
+ def submit(text:, emoji: nil)
55
+ @submit = Slack::BlockKit::Composition::PlainText.new(text: text, emoji: emoji)
56
+
57
+ self
58
+ end
59
+
60
+ def as_json(*) # rubocop:disable Metrics/MethodLength
61
+ {
62
+ type: TYPE,
63
+ blocks: @blocks.as_json,
64
+ title: @title&.as_json,
65
+ close: @close&.as_json,
66
+ submit: @submit&.as_json,
67
+ clear_on_close: @clear_on_close,
68
+ notify_on_close: @notify_on_close,
69
+ private_metadata: @private_metadata,
70
+ callback_id: @callback_id,
71
+ external_id: @external_id
72
+ }.compact
73
+ end
74
+ end
75
+ end
76
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-ruby-block-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Gregg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-26 00:00:00.000000000 Z
11
+ date: 2020-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -186,6 +186,9 @@ files:
186
186
  - lib/slack/block_kit/layout/input.rb
187
187
  - lib/slack/block_kit/layout/section.rb
188
188
  - lib/slack/block_kit/layout/section/multi_select_elements.rb
189
+ - lib/slack/surfaces/home.rb
190
+ - lib/slack/surfaces/message.rb
191
+ - lib/slack/surfaces/modal.rb
189
192
  - slack-ruby-block-kit.gemspec
190
193
  homepage: https://github.com/CGA1123/slack-ruby-block-kit
191
194
  licenses:
@@ -207,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
210
  - !ruby/object:Gem::Version
208
211
  version: '0'
209
212
  requirements: []
210
- rubygems_version: 3.1.2
213
+ rubygems_version: 3.0.3
211
214
  signing_key:
212
215
  specification_version: 4
213
216
  summary: A ruby wrapper for Slack's Block Kit