slack-ruby-block-kit 0.15.0 → 0.18.0

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: 644f871d525941f478c3be328b24038bdcfa219555efa6e1aa3e7c0a6fe2b0af
4
- data.tar.gz: 8ffd58726aee0032b5ffb7b97b879d8c56fb8c81a26f6cf9db251dc608ad756e
3
+ metadata.gz: e1dbf4c507a258057e4268545eb470d52283d73f24911adedf77f4cb3bd63dea
4
+ data.tar.gz: fbb29fb003bc969ca8d9dc7eb3db3f025afd7585dc671009f5aa482d79fd711f
5
5
  SHA512:
6
- metadata.gz: 5096cf81affb99eb90fe44f7c873caca6738b37579fc90d15dfec3ec6ea4f7c8fca7956958dbefcec9cf01105bf13dba834bf3e1ba9da3e4c51ebdd53c26e8e7
7
- data.tar.gz: dbf34713c3d0ecfaa61d8d36d8df7b7fff94482723bd42572d2c5fb98868e1db16673aae70196f7b340856774e4cb4919491576ad74a93e4e643e9f51c0c66f6
6
+ metadata.gz: 9838653c7f9641515da8433252f34123dff455b3619c3ba32fbdccaffdb8b16144f830d6ed53a246afd04acbce4ed8887a66ba45079eca99cce50b370afcbae4
7
+ data.tar.gz: 4d079f8202a4d9b3a8966adf4f01e37eb0c08a22e074a3dc149a09466ea63124eb7841f8585cfc295880754a68bf2352e33a6b9de8e68afa7b5092c0e9a812c0
@@ -0,0 +1 @@
1
+ FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-2.7
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "Ruby",
3
+ "build": {
4
+ "dockerfile": "Dockerfile"
5
+ },
6
+ "settings": {},
7
+ "extensions": [
8
+ "rebornix.Ruby"
9
+ ],
10
+ "remoteUser": "vscode"
11
+ }
@@ -3,7 +3,8 @@ updates:
3
3
  - package-ecosystem: bundler
4
4
  directory: "/"
5
5
  schedule:
6
- interval: daily
6
+ interval: weekly
7
+ day: thursday
7
8
  open-pull-requests-limit: 99
8
9
  reviewers:
9
10
  - CGA1123
@@ -30,4 +30,5 @@ jobs:
30
30
  - run: bundle exec rubocop
31
31
  - run: bundle exec rspec --format progress
32
32
  - run: ./bin/deepsource report --analyzer test-coverage --key ruby --value-file ./coverage/.resultset.json
33
- if: (github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == github.repository) # don't run on forks which don't have access to DEEPSOURCE_DSN
33
+ # don't run on forks which don't have access to DEEPSOURCE_DSN
34
+ if: (env.DEEPSOURCE_DSN != '') && (github.event_name == 'push') || (github.event.pull_request.head.repo.full_name == github.repository)
@@ -0,0 +1,30 @@
1
+ name: Release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ otp:
7
+ name: 'RubyGems OTP Code'
8
+ required: true
9
+
10
+ jobs:
11
+ release:
12
+ name: Release
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: 2.7
19
+ - run: |
20
+ otp=${{github.event.inputs.otp}}
21
+ echo "::add-mask::$otp"
22
+ - run: gem update --system
23
+ - run: git config --global user.email github-action@users.noreply.github.com
24
+ - run: git config --global user.name GitHub Actions
25
+ - run: git config --global user.password ${{ github.token }}
26
+ - run: bundle install
27
+ - run: bundle exec rake release
28
+ env:
29
+ GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
30
+ GEM_HOST_OTP_CODE: ${{ github.event.inputs.otp }}
data/CHANGELOG.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Changelog
2
+
2
3
  All notable changes to this project will be documented in this file.
3
4
 
4
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
@@ -24,35 +25,55 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
24
25
  ### Security
25
26
  - N/A
26
27
 
28
+ ## [0.18.0] - 2022-08-26
27
29
 
28
- [Unreleased]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.15.0...HEAD
30
+ ### Added
31
+ - `Slack::BlockKit::Layout::Input#Timepicker`
32
+ - `Slack::BlockKit::Layout::Actions#timepicker`
33
+ - `Slack::BlockKit::Layout::Section#timepicker`
29
34
 
35
+ ### Changed
36
+ - `Slack::BlockKit::Element::Timepicker.initialize` now accepts `initial:`, `emoji:`, `placeholder:`
37
+ - Rename `Slack::BlockKit::Element::DatePicker` to `Datepicker`
38
+ - Rename `Slack::BlockKit::Layout::Actions#date_picker` to `#datepicker`
39
+ - Rename `Slack::BlockKit::Layout::Section#date_picker` to `#datepicker`
40
+ - `Slack::BlockKit::Blocks#input` now supports passing through the `optional:` parameter (@sophieklm)
30
41
 
31
- ---
42
+ ### Removed
43
+ - `Slack::BlockKit::Element::Timepicker#placeholder`
44
+ - `Slack::BlockKit::Element::Timepicker#initial_time`
32
45
 
33
46
 
34
- ## [0.15.0] - 2021-06-14
47
+ ## [0.17.0] - 2021-06-28
35
48
 
36
49
  ### Added
37
- - Support `dispatch_action` and `dispatch_action_config` (#94 by @deecewan)
50
+ - `Slack::BlockKit::Formatting` with utility functions for Slack text formatting (#98 by @CGA1123)
38
51
 
39
52
 
40
- [0.15.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.14.1...v0.15.0
53
+ ## [0.16.0] - 2021-06-23
41
54
 
55
+ This release contains a breaking change on the `Layout::Actions` interface.
42
56
 
43
- ---
44
-
57
+ ### Added
58
+ - Added new `Layout::Actions#checkboxes` method (#96 by @ryanwilsonperkin)
45
59
 
46
- ## [0.14.1] - 2021-05-05
60
+ ### Removed
61
+ - `Layout::Actions#converstation_select` (use `#conversation_select` instead) (#97 by @ryanwilsonperkin)
47
62
 
48
63
  ### Fixed
49
- - Allow Layout::Section to render without `text` (#87 by @pbendersky)
64
+ - Fixed name of method in `Layout::Actions` to be `conversation_select` (#97 by @ryanwilsonperkin)
50
65
 
51
66
 
52
- [0.14.1]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.14.0...v0.14.1
67
+ ## [0.15.0] - 2021-06-14
53
68
 
69
+ ### Added
70
+ - Support `dispatch_action` and `dispatch_action_config` (#94 by @deecewan)
54
71
 
55
- ---
72
+
73
+ ## [0.14.1] - 2021-05-05
74
+
75
+ ### Fixed
76
+ - Allow Layout::Section to render without `text` (#87 by @pbendersky)
56
77
 
57
78
 
58
79
  ## [0.14.0] - 2021-02-06
@@ -61,12 +82,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
61
82
  - `Slack::BlockKit::Blocks#header` (#74 by @rspeicher)
62
83
 
63
84
 
64
- [0.14.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.13.0...v0.14.0
65
-
66
-
67
- ---
68
-
69
-
70
85
  ## [0.13.0] - 2020-12-29
71
86
 
72
87
  ### Added
@@ -78,12 +93,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
78
93
  - Development dependencies now managed by bundler via Gemfile, rather than in gemspec
79
94
 
80
95
 
81
- [0.13.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.12.0...v0.13.0
82
-
83
-
84
- ---
85
-
86
-
87
96
  ## [0.12.0] - 2020-10-06
88
97
 
89
98
  ### Added
@@ -95,12 +104,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
95
104
  - `Slack::BlockKit::Element::StaticSelect#initial`, use the `initial:` keyword on `#option`
96
105
 
97
106
 
98
- [0.12.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.11.0...v0.12.0
99
-
100
-
101
- ---
102
-
103
-
104
107
  ## [0.11.0] - 2020-10-03
105
108
 
106
109
  ### Added
@@ -113,12 +116,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
113
116
  - Ruby2.7 kwarg deprecation warnings
114
117
 
115
118
 
116
- [0.11.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.10.0...v0.11.0
117
-
118
-
119
- ---
120
-
121
-
122
119
  ## [0.10.0] - 2020-09-11
123
120
 
124
121
  ### Added
@@ -128,12 +125,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
128
125
  - Fixed initial options in multi select blocks (#46 by @caalberts)
129
126
 
130
127
 
128
+ [Unreleased]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.18.0...HEAD
129
+ [0.17.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.17.0...v0.18.0
130
+ [0.17.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.16.0...v0.17.0
131
+ [0.16.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.15.0...v0.16.0
132
+ [0.15.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.14.1...v0.15.0
133
+ [0.14.1]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.14.0...v0.14.1
134
+ [0.14.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.13.0...v0.14.0
135
+ [0.13.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.12.0...v0.13.0
136
+ [0.12.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.11.0...v0.12.0
137
+ [0.11.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.10.0...v0.11.0
131
138
  [0.10.0]: https://github.com/CGA1123/slack-ruby-block-kit/compare/v0.9.0...v0.10.0
132
-
133
-
134
- ---
135
-
136
- See [releases] for previous changes.
137
-
138
-
139
- [releases]: https://github.com/CGA1123/slack-ruby-block-kit/releases
data/Gemfile CHANGED
@@ -9,10 +9,10 @@ gem 'faraday', '~> 1'
9
9
  gem 'pry', '~> 0.14'
10
10
  gem 'rake', '~> 13'
11
11
  gem 'rspec', '~> 3'
12
- gem 'rspec_junit_formatter', '~> 0.4'
12
+ gem 'rspec_junit_formatter', '~> 0.5'
13
13
 
14
- gem 'codecov', '~> 0.5', require: false
14
+ gem 'codecov', '~> 0.6', require: false
15
15
  gem 'rubocop', '~> 1', require: false
16
- gem 'rubocop-rake', '~> 0.5', require: false
16
+ gem 'rubocop-rake', '~> 0.6', require: false
17
17
  gem 'rubocop-rspec', '~> 2', require: false
18
18
  gem 'simplecov', '~> 0.21', require: false
data/Gemfile.lock CHANGED
@@ -1,98 +1,110 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- slack-ruby-block-kit (0.15.0)
4
+ slack-ruby-block-kit (0.18.0)
5
+ zeitwerk (~> 2.6)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
9
10
  ast (2.4.2)
10
- codecov (0.5.2)
11
+ codecov (0.6.0)
11
12
  simplecov (>= 0.15, < 0.22)
12
13
  coderay (1.1.3)
13
- diff-lcs (1.4.4)
14
- docile (1.3.5)
15
- dotenv (2.7.6)
16
- faraday (1.4.2)
14
+ diff-lcs (1.5.0)
15
+ docile (1.4.0)
16
+ dotenv (2.8.1)
17
+ faraday (1.10.2)
17
18
  faraday-em_http (~> 1.0)
18
19
  faraday-em_synchrony (~> 1.0)
19
20
  faraday-excon (~> 1.1)
21
+ faraday-httpclient (~> 1.0)
22
+ faraday-multipart (~> 1.0)
20
23
  faraday-net_http (~> 1.0)
21
- faraday-net_http_persistent (~> 1.1)
22
- multipart-post (>= 1.2, < 3)
24
+ faraday-net_http_persistent (~> 1.0)
25
+ faraday-patron (~> 1.0)
26
+ faraday-rack (~> 1.0)
27
+ faraday-retry (~> 1.0)
23
28
  ruby2_keywords (>= 0.0.4)
24
29
  faraday-em_http (1.0.0)
25
30
  faraday-em_synchrony (1.0.0)
26
31
  faraday-excon (1.1.0)
32
+ faraday-httpclient (1.0.1)
33
+ faraday-multipart (1.0.4)
34
+ multipart-post (~> 2)
27
35
  faraday-net_http (1.0.1)
28
- faraday-net_http_persistent (1.1.0)
36
+ faraday-net_http_persistent (1.2.0)
37
+ faraday-patron (1.0.0)
38
+ faraday-rack (1.0.0)
39
+ faraday-retry (1.0.3)
29
40
  method_source (1.0.0)
30
- multipart-post (2.1.1)
31
- parallel (1.20.1)
32
- parser (3.0.1.1)
41
+ multipart-post (2.2.3)
42
+ parallel (1.22.1)
43
+ parser (3.1.2.0)
33
44
  ast (~> 2.4.1)
34
45
  pry (0.14.1)
35
46
  coderay (~> 1.1)
36
47
  method_source (~> 1.0)
37
- rainbow (3.0.0)
38
- rake (13.0.3)
39
- regexp_parser (2.1.1)
48
+ rainbow (3.1.1)
49
+ rake (13.0.6)
50
+ regexp_parser (2.3.1)
40
51
  rexml (3.2.5)
41
- rspec (3.10.0)
42
- rspec-core (~> 3.10.0)
43
- rspec-expectations (~> 3.10.0)
44
- rspec-mocks (~> 3.10.0)
45
- rspec-core (3.10.1)
46
- rspec-support (~> 3.10.0)
47
- rspec-expectations (3.10.1)
52
+ rspec (3.11.0)
53
+ rspec-core (~> 3.11.0)
54
+ rspec-expectations (~> 3.11.0)
55
+ rspec-mocks (~> 3.11.0)
56
+ rspec-core (3.11.0)
57
+ rspec-support (~> 3.11.0)
58
+ rspec-expectations (3.11.0)
48
59
  diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.10.0)
50
- rspec-mocks (3.10.2)
60
+ rspec-support (~> 3.11.0)
61
+ rspec-mocks (3.11.0)
51
62
  diff-lcs (>= 1.2.0, < 2.0)
52
- rspec-support (~> 3.10.0)
53
- rspec-support (3.10.2)
54
- rspec_junit_formatter (0.4.1)
63
+ rspec-support (~> 3.11.0)
64
+ rspec-support (3.11.0)
65
+ rspec_junit_formatter (0.5.1)
55
66
  rspec-core (>= 2, < 4, != 2.12.0)
56
- rubocop (1.16.1)
67
+ rubocop (1.28.2)
57
68
  parallel (~> 1.10)
58
- parser (>= 3.0.0.0)
69
+ parser (>= 3.1.0.0)
59
70
  rainbow (>= 2.2.2, < 4.0)
60
71
  regexp_parser (>= 1.8, < 3.0)
61
72
  rexml
62
- rubocop-ast (>= 1.7.0, < 2.0)
73
+ rubocop-ast (>= 1.17.0, < 2.0)
63
74
  ruby-progressbar (~> 1.7)
64
75
  unicode-display_width (>= 1.4.0, < 3.0)
65
- rubocop-ast (1.7.0)
66
- parser (>= 3.0.1.1)
67
- rubocop-rake (0.5.1)
68
- rubocop
69
- rubocop-rspec (2.4.0)
76
+ rubocop-ast (1.17.0)
77
+ parser (>= 3.1.1.0)
78
+ rubocop-rake (0.6.0)
70
79
  rubocop (~> 1.0)
71
- rubocop-ast (>= 1.1.0)
80
+ rubocop-rspec (2.10.0)
81
+ rubocop (~> 1.19)
72
82
  ruby-progressbar (1.11.0)
73
- ruby2_keywords (0.0.4)
83
+ ruby2_keywords (0.0.5)
74
84
  simplecov (0.21.2)
75
85
  docile (~> 1.1)
76
86
  simplecov-html (~> 0.11)
77
87
  simplecov_json_formatter (~> 0.1)
78
88
  simplecov-html (0.12.3)
79
- simplecov_json_formatter (0.1.2)
80
- unicode-display_width (2.0.0)
89
+ simplecov_json_formatter (0.1.3)
90
+ unicode-display_width (2.1.0)
91
+ zeitwerk (2.6.0)
81
92
 
82
93
  PLATFORMS
83
94
  ruby
84
95
  x86_64-darwin-19
96
+ x86_64-linux
85
97
 
86
98
  DEPENDENCIES
87
- codecov (~> 0.5)
99
+ codecov (~> 0.6)
88
100
  dotenv (~> 2)
89
101
  faraday (~> 1)
90
102
  pry (~> 0.14)
91
103
  rake (~> 13)
92
104
  rspec (~> 3)
93
- rspec_junit_formatter (~> 0.4)
105
+ rspec_junit_formatter (~> 0.5)
94
106
  rubocop (~> 1)
95
- rubocop-rake (~> 0.5)
107
+ rubocop-rake (~> 0.6)
96
108
  rubocop-rspec (~> 2)
97
109
  simplecov (~> 0.21)
98
110
  slack-ruby-block-kit!
data/README.md CHANGED
@@ -95,3 +95,15 @@ See [issues](https://github.com/CGA1123/slack-ruby-block-kit/issues) if you want
95
95
  ## License
96
96
 
97
97
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
98
+
99
+ ## Releasing
100
+
101
+ Releasing is automated via the `.github/workflows/release.yml` which allows for
102
+ an OTP code to be passed in to authorize the release with MFA. If GitHub
103
+ Actions is running slow it might take another attempt to make sure the OTP code
104
+ is still valid when the workflow tries to push.
105
+
106
+ - Update `CHANGELOG` for the latest version (remember to update the comparison links + add in an `Unreleased` section again)
107
+ - Update `lib/slack/block_kit/version.rb` and run `bundle` to update the `Gemfile.lock`
108
+ - Push that!
109
+ - Run the `Release` workflow
@@ -63,12 +63,13 @@ module Slack
63
63
  append(block)
64
64
  end
65
65
 
66
- def input(label:, hint: nil, block_id: nil, dispatch_action: nil)
66
+ def input(label:, hint: nil, block_id: nil, dispatch_action: nil, optional: nil)
67
67
  block = Layout::Input.new(
68
68
  label: label,
69
69
  hint: hint,
70
70
  block_id: block_id,
71
- dispatch_action: dispatch_action
71
+ dispatch_action: dispatch_action,
72
+ optional: optional
72
73
  )
73
74
 
74
75
  yield(block) if block_given?
@@ -9,7 +9,7 @@ module Slack
9
9
  # Date picker elements can be used inside of section and actions blocks.
10
10
  #
11
11
  # https://api.slack.com/reference/messaging/block-elements#datepicker
12
- class DatePicker
12
+ class Datepicker
13
13
  include Composition::ConfirmationDialog::Confirmable
14
14
 
15
15
  TYPE = 'datepicker'
@@ -15,25 +15,14 @@ module Slack
15
15
 
16
16
  TYPE = 'timepicker'
17
17
 
18
- def initialize(action_id:)
19
- @placeholder, @initial_time = nil
18
+ def initialize(action_id:, placeholder: nil, initial: nil, emoji: nil)
19
+ @placeholder = placeholder_text(placeholder, emoji) if placeholder
20
+ @initial_time = initial
20
21
  @action_id = action_id
21
22
 
22
23
  yield(self) if block_given?
23
24
  end
24
25
 
25
- def placeholder(text:, emoji: nil)
26
- @placeholder = Composition::PlainText.new(text: text, emoji: emoji)
27
-
28
- self
29
- end
30
-
31
- def initial_time(time_str)
32
- @initial_time = time_str
33
-
34
- self
35
- end
36
-
37
26
  def as_json(*)
38
27
  {
39
28
  type: TYPE,
@@ -43,6 +32,14 @@ module Slack
43
32
  confirm: confirm&.as_json
44
33
  }.compact
45
34
  end
35
+
36
+ private
37
+
38
+ def placeholder_text(text, emoji)
39
+ return unless text
40
+
41
+ Composition::PlainText.new(text: text, emoji: emoji)
42
+ end
46
43
  end
47
44
  end
48
45
  end
@@ -0,0 +1,124 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Slack
4
+ module BlockKit
5
+ # Formatting contains some utility functions to help formatting text
6
+ #
7
+ # See: https://api.slack.com/reference/surfaces/formatting
8
+ module Formatting
9
+ extend self # rubocop:disable Style/ModuleFunction
10
+
11
+ DATE_FORMAT_TOKENS = [
12
+ # 2014-02-18
13
+ DATE_NUM = '{date_num}',
14
+
15
+ # February 18th, 2014
16
+ DATE = '{date}',
17
+
18
+ # Feb 18, 2014
19
+ DATE_SHORT = '{date_short}',
20
+
21
+ # Tuesday, February 18th, 2014
22
+ DATE_LONG = '{date_long}',
23
+
24
+ # February 18th, 2014 but uses "yesterday", "today", or "tomorrow"
25
+ # where
26
+ # appropriate
27
+ DATE_PRETTY = '{date_pretty}',
28
+
29
+ # Feb 18, 2014 but uses "yesterday", "today", or "tomorrow" where
30
+ # appropriate
31
+ DATE_SHORT_PRETTY = '{date_short_pretty}',
32
+
33
+ # Tuesday, February 18th, 2014 but uses "yesterday", "today", or
34
+ # "tomorrow" where appropriate
35
+ DATE_LONG_PRETTY = '{date_long_pretty}',
36
+
37
+ # 6:39 AM or 6:39 PM / 06:39 or 18:39 (depending on user preferences)
38
+ TIME = '{time}',
39
+
40
+ # 6:39:45 AM 6:39:42 PM / 06:39:45 or 18:39:42 (depending on user
41
+ # preferences)
42
+ TIME_SECS = '{time_secs}'
43
+ ].freeze
44
+
45
+ # Format a URL
46
+ #
47
+ # See: https://api.slack.com/reference/surfaces/formatting#links
48
+ def link(url, link_text: nil)
49
+ "<#{[url, link_text].compact.join('|')}>"
50
+ end
51
+
52
+ # Format a mailto link
53
+ #
54
+ # See: https://api.slack.com/reference/surfaces/formatting#links
55
+ def mailto(address, link_text: nil)
56
+ "<mailto:#{[address, link_text].compact.join('|')}>"
57
+ end
58
+
59
+ # Link a public channel
60
+ #
61
+ # See: https://api.slack.com/reference/surfaces/formatting#linking-channels
62
+ def channel(identifier)
63
+ "<##{identifier}>"
64
+ end
65
+
66
+ # Mention a user
67
+ #
68
+ # See: https://api.slack.com/reference/surfaces/formatting#mentioning-users
69
+ def user(identifier)
70
+ "<@#{identifier}>"
71
+ end
72
+
73
+ # Mention a group
74
+ #
75
+ # See: https://api.slack.com/reference/surfaces/formatting#mentioning-groups
76
+ def group(identifier)
77
+ "<!subteam^#{identifier}>"
78
+ end
79
+
80
+ # Mention @here (all active users in the current channel)
81
+ #
82
+ # See: https://api.slack.com/reference/surfaces/formatting#special-mentions
83
+ def at_here
84
+ # additional "|here" is for supporting very old mobile clients apparently!
85
+ '<!here|here>'
86
+ end
87
+
88
+ # Mention @channel (all users in the current channel)
89
+ #
90
+ # See: https://api.slack.com/reference/surfaces/formatting#special-mentions
91
+ def at_channel
92
+ '<!channel>'
93
+ end
94
+
95
+ # Mention @everyone (all users in #general)
96
+ #
97
+ # See: https://api.slack.com/reference/surfaces/formatting#special-mentions
98
+ def at_everyone
99
+ '<!everyone>'
100
+ end
101
+
102
+ # Localise a UNIX timestamp to the user's local timezone
103
+ #
104
+ # See: https://api.slack.com/reference/surfaces/formatting#date-formatting
105
+ def date(timestamp, token_string:, link: nil, fallback_text: nil)
106
+ datetime_str = [timestamp, token_string, link].compact.join('^')
107
+ str = [datetime_str, fallback_text].compact.join('|')
108
+
109
+ "<!date^#{str}>"
110
+ end
111
+
112
+ # Escape special characters (<,>,&) with their HTML entity code so
113
+ # Slack's text parsers knows to interpret them as literals.
114
+ #
115
+ # See: https://api.slack.com/reference/surfaces/formatting#escaping
116
+ def escape(text)
117
+ text
118
+ .gsub('&', '&amp;')
119
+ .gsub('>', '&gt;')
120
+ .gsub('<', '&lt;')
121
+ end
122
+ end
123
+ end
124
+ end
@@ -46,7 +46,7 @@ module Slack
46
46
  append(element)
47
47
  end
48
48
 
49
- def converstation_select(placeholder:, action_id:, initial: nil, emoji: nil)
49
+ def conversation_select(placeholder:, action_id:, initial: nil, emoji: nil)
50
50
  element = Element::ConversationsSelect.new(
51
51
  placeholder: placeholder,
52
52
  action_id: action_id,
@@ -59,8 +59,21 @@ module Slack
59
59
  append(element)
60
60
  end
61
61
 
62
- def date_picker(action_id:, placeholder: nil, initial: nil, emoji: nil)
63
- element = Element::DatePicker.new(
62
+ def datepicker(action_id:, placeholder: nil, initial: nil, emoji: nil)
63
+ element = Element::Datepicker.new(
64
+ placeholder: placeholder,
65
+ action_id: action_id,
66
+ initial: initial,
67
+ emoji: emoji
68
+ )
69
+
70
+ yield(element) if block_given?
71
+
72
+ append(element)
73
+ end
74
+
75
+ def timepicker(action_id:, placeholder: nil, initial: nil, emoji: nil)
76
+ element = Element::Timepicker.new(
64
77
  placeholder: placeholder,
65
78
  action_id: action_id,
66
79
  initial: initial,
@@ -119,6 +132,16 @@ module Slack
119
132
  append(element)
120
133
  end
121
134
 
135
+ def checkboxes(action_id:)
136
+ element = Element::Checkboxes.new(
137
+ action_id: action_id
138
+ )
139
+
140
+ yield(element) if block_given?
141
+
142
+ append(element)
143
+ end
144
+
122
145
  def append(element)
123
146
  @elements << element
124
147
 
@@ -79,7 +79,7 @@ module Slack
79
79
  end
80
80
 
81
81
  def datepicker(action_id:, placeholder: nil, initial: nil, emoji: nil)
82
- @element = Element::DatePicker.new(
82
+ @element = Element::Datepicker.new(
83
83
  action_id: action_id,
84
84
  placeholder: placeholder,
85
85
  initial: initial,
@@ -91,6 +91,19 @@ module Slack
91
91
  self
92
92
  end
93
93
 
94
+ def timepicker(action_id:, placeholder: nil, initial: nil, emoji: nil)
95
+ @element = Element::Timepicker.new(
96
+ action_id: action_id,
97
+ placeholder: placeholder,
98
+ emoji: emoji,
99
+ initial: initial
100
+ )
101
+
102
+ yield(@element) if block_given?
103
+
104
+ self
105
+ end
106
+
94
107
  def multi_channels_select(placeholder:, action_id:, initial: nil, emoji: nil, max_selected_items: nil)
95
108
  @element = Element::MultiChannelsSelect.new(
96
109
  placeholder: placeholder,
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative './section/multi_select_elements'
4
-
5
3
  module Slack
6
4
  module BlockKit
7
5
  module Layout
@@ -94,8 +92,21 @@ module Slack
94
92
  accessorise(element)
95
93
  end
96
94
 
97
- def date_picker(action_id:, placeholder: nil, initial: nil, emoji: nil)
98
- element = Element::DatePicker.new(
95
+ def datepicker(action_id:, placeholder: nil, initial: nil, emoji: nil)
96
+ element = Element::Datepicker.new(
97
+ placeholder: placeholder,
98
+ action_id: action_id,
99
+ initial: initial,
100
+ emoji: emoji
101
+ )
102
+
103
+ yield(element) if block_given?
104
+
105
+ accessorise(element)
106
+ end
107
+
108
+ def timepicker(action_id:, placeholder: nil, initial: nil, emoji: nil)
109
+ element = Element::Timepicker.new(
99
110
  placeholder: placeholder,
100
111
  action_id: action_id,
101
112
  initial: initial,
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Slack
4
4
  module BlockKit
5
- VERSION = '0.15.0'
5
+ VERSION = '0.18.0'
6
6
  end
7
7
  end
@@ -8,12 +8,6 @@ module Slack
8
8
 
9
9
  module Layout; end
10
10
 
11
- Dir[File.join(__dir__, 'block_kit', 'composition', '*.rb')].sort.each { |file| require file }
12
- Dir[File.join(__dir__, 'block_kit', 'element', '*.rb')].sort.each { |file| require file }
13
- Dir[File.join(__dir__, 'block_kit', 'layout', '*.rb')].sort.each { |file| require file }
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 }
16
-
17
11
  module_function
18
12
 
19
13
  def blocks
@@ -1,3 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative './slack/block_kit'
3
+ require 'zeitwerk'
4
+
5
+ loader = Zeitwerk::Loader.new
6
+ loader.tag = 'slack-ruby-block-kit'
7
+ loader.push_dir(__dir__)
8
+ loader.ignore(__FILE__)
9
+ loader.inflector.inflect('version' => 'VERSION')
10
+ loader.setup
11
+
12
+ require 'slack/block_kit'
13
+
14
+ loader.eager_load
@@ -10,4 +10,4 @@ require 'slack-ruby-block-kit'
10
10
  require 'faraday'
11
11
  require 'pry'
12
12
 
13
- Pry.start
13
+ binding.pry # rubocop:disable Lint/Debugger
data/script/lint ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec rubocop -A
data/script/test ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ bundle exec rake
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'slack/block_kit/version'
3
+ require_relative 'lib/slack/block_kit/version'
6
4
 
7
5
  Gem::Specification.new do |spec|
8
6
  spec.name = 'slack-ruby-block-kit'
@@ -20,4 +18,8 @@ Gem::Specification.new do |spec|
20
18
  end
21
19
  spec.require_paths = ['lib']
22
20
  spec.required_ruby_version = '>= 2.5'
21
+ spec.metadata = {
22
+ 'rubygems_mfa_required' => 'true'
23
+ }
24
+ spec.add_dependency 'zeitwerk', '~> 2.6'
23
25
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-ruby-block-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.18.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: 2021-06-14 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2022-08-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: zeitwerk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.6'
13
27
  description:
14
28
  email:
15
29
  - c_arlt@hotmail.com
@@ -18,8 +32,11 @@ extensions: []
18
32
  extra_rdoc_files: []
19
33
  files:
20
34
  - ".deepsource.toml"
35
+ - ".devcontainer/Dockerfile"
36
+ - ".devcontainer/devcontainer.json"
21
37
  - ".github/dependabot.yml"
22
38
  - ".github/workflows/ci.yml"
39
+ - ".github/workflows/release.yml"
23
40
  - ".gitignore"
24
41
  - ".rspec"
25
42
  - ".rubocop.yml"
@@ -29,7 +46,6 @@ files:
29
46
  - LICENSE.txt
30
47
  - README.md
31
48
  - Rakefile
32
- - bin/console
33
49
  - lib/slack-ruby-block-kit.rb
34
50
  - lib/slack/block_kit.rb
35
51
  - lib/slack/block_kit/blocks.rb
@@ -44,7 +60,7 @@ files:
44
60
  - lib/slack/block_kit/element/channels_select.rb
45
61
  - lib/slack/block_kit/element/checkboxes.rb
46
62
  - lib/slack/block_kit/element/conversations_select.rb
47
- - lib/slack/block_kit/element/date_picker.rb
63
+ - lib/slack/block_kit/element/datepicker.rb
48
64
  - lib/slack/block_kit/element/external_select.rb
49
65
  - lib/slack/block_kit/element/image.rb
50
66
  - lib/slack/block_kit/element/multi_channels_select.rb
@@ -58,6 +74,7 @@ files:
58
74
  - lib/slack/block_kit/element/static_select.rb
59
75
  - lib/slack/block_kit/element/timepicker.rb
60
76
  - lib/slack/block_kit/element/users_select.rb
77
+ - lib/slack/block_kit/formatting.rb
61
78
  - lib/slack/block_kit/layout/actions.rb
62
79
  - lib/slack/block_kit/layout/context.rb
63
80
  - lib/slack/block_kit/layout/divider.rb
@@ -70,11 +87,15 @@ files:
70
87
  - lib/slack/surfaces/home.rb
71
88
  - lib/slack/surfaces/message.rb
72
89
  - lib/slack/surfaces/modal.rb
90
+ - script/console
91
+ - script/lint
92
+ - script/test
73
93
  - slack-ruby-block-kit.gemspec
74
94
  homepage: https://github.com/CGA1123/slack-ruby-block-kit
75
95
  licenses:
76
96
  - MIT
77
- metadata: {}
97
+ metadata:
98
+ rubygems_mfa_required: 'true'
78
99
  post_install_message:
79
100
  rdoc_options: []
80
101
  require_paths:
@@ -90,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
111
  - !ruby/object:Gem::Version
91
112
  version: '0'
92
113
  requirements: []
93
- rubygems_version: 3.1.4
114
+ rubygems_version: 3.3.21
94
115
  signing_key:
95
116
  specification_version: 4
96
117
  summary: A ruby wrapper for Slack's Block Kit