slack_widgets 0.1.0 → 0.2.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 +4 -4
- data/README.md +10 -4
- data/lib/slack_widgets.rb +5 -1
- data/lib/slack_widgets/version.rb +1 -1
- data/lib/slack_widgets/widgets/buttons/danger_button.rb +16 -0
- data/lib/slack_widgets/widgets/buttons/primary_button.rb +7 -0
- data/lib/slack_widgets/widgets/pickers/external_picker.rb +7 -0
- data/lib/slack_widgets/widgets/pickers/picker.rb +21 -0
- data/lib/slack_widgets/widgets/pickers/static_picker.rb +20 -0
- data/lib/slack_widgets/widgets/pickers/user_picker.rb +12 -0
- data/slack_widgets.gemspec +1 -0
- metadata +22 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a210e9e2dd1ddc77df25699aba3bf4a17a9bd4d8
|
|
4
|
+
data.tar.gz: b4e30434dc666b5d2720beb51270bf3b4c6974c5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bdab9d4c906cfb9c52b0911bbba5ccaf18850dd770cd25ff285b7173e3d39332360a553be8821e6baeda7178cee9d00d74f21341683cb7979f24fd0cb3f5115f
|
|
7
|
+
data.tar.gz: b244072fe1037656ebc1dab663841e3a753797b017ff51154b83d753c921c60f035ae07fdf21a7bde80de302e84e33e657b7a4525937f0198f0608d1e114af27
|
data/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# SlackWidgets
|
|
2
|
+
Developing a Slack app in Ruby? This gem will make your life a bit easier.
|
|
3
|
+
For Slack message attachments:
|
|
4
|
+
JSON button and pickers - lame :\
|
|
5
|
+
PORO button and pickers - Yeahy! :)
|
|
2
6
|
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/slack_widgets`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
7
|
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
|
6
8
|
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
@@ -22,7 +24,11 @@ Or install it yourself as:
|
|
|
22
24
|
|
|
23
25
|
## Usage
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
```ruby
|
|
28
|
+
SlackWidgets::DangerButton.create(name: 'test', text: 'text', value: 1, confirm_hash: 'POSITIVE??')
|
|
29
|
+
|
|
30
|
+
# => {:name=>"test", :text=>"text", :type=>"button", :value=>1, :style=>"danger", :confirm=>"POSITIVE??"}
|
|
31
|
+
```
|
|
26
32
|
|
|
27
33
|
## Development
|
|
28
34
|
|
|
@@ -32,7 +38,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
32
38
|
|
|
33
39
|
## Contributing
|
|
34
40
|
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
|
41
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/BennySitbon/slack_widgets.
|
|
36
42
|
|
|
37
43
|
|
|
38
44
|
## License
|
data/lib/slack_widgets.rb
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
require "slack_widgets/version"
|
|
2
|
-
require "slack_widgets/widgets
|
|
2
|
+
# require "slack_widgets/widgets/*"
|
|
3
|
+
require 'require_all'
|
|
4
|
+
|
|
5
|
+
require_all 'lib'
|
|
3
6
|
|
|
4
7
|
module SlackWidgets
|
|
5
8
|
# Your code goes here...
|
|
9
|
+
# Dir[File.dirname(__FILE__) + "/slack_widgets/**/*"].each{ |file| p file; require file }
|
|
6
10
|
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module SlackWidgets
|
|
2
|
+
class DangerButton < Button
|
|
3
|
+
def initialize(name:, text: nil, confirm_hash: nil, value: nil)
|
|
4
|
+
@confirm_hash = confirm_hash
|
|
5
|
+
super(name: name, text: text, value: value)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def render
|
|
9
|
+
super.merge('style': 'danger', 'confirm': @confirm_hash)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.create(name:, text: nil, confirm_hash: nil, value: nil)
|
|
13
|
+
new(name: name, text: text, confirm_hash: confirm_hash, value: value).render
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module SlackWidgets
|
|
2
|
+
# todo: should this be abstract?
|
|
3
|
+
class Picker
|
|
4
|
+
def initialize(name:, text: nil)
|
|
5
|
+
@name = name
|
|
6
|
+
@text = text
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def render
|
|
10
|
+
{
|
|
11
|
+
'type': 'select',
|
|
12
|
+
'name': @name,
|
|
13
|
+
'text': @text
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.create(name:, text: nil)
|
|
18
|
+
new(name: name, text: text).render
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module SlackWidgets
|
|
2
|
+
class StaticPicker < Picker
|
|
3
|
+
def initialize(name:, options:, text: nil, selected_index: nil, value: nil)
|
|
4
|
+
@options = options
|
|
5
|
+
@value = value
|
|
6
|
+
@pre_selection = selected_index ? options[selected_index] : nil
|
|
7
|
+
super(name: name, text: text)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def render
|
|
11
|
+
super.merge('data_source': 'static',
|
|
12
|
+
'options': @options,
|
|
13
|
+
'selected_options': [@pre_selection],
|
|
14
|
+
'value': @value)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
def self.create(name:, options:, text: nil, selected_index: nil, value: nil)
|
|
18
|
+
new(name: name, options: options, text: text, selected_index: selected_index, value: value).render
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module SlackWidgets
|
|
2
|
+
class UserPicker < Picker
|
|
3
|
+
def initialize(name:, text: nil, selected_options: nil)
|
|
4
|
+
super(name: name, text: text)
|
|
5
|
+
@selected = selected_options
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def render
|
|
9
|
+
super.merge('data_source': 'users', 'selected_options': @selected)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
data/slack_widgets.gemspec
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: slack_widgets
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Benny Sitbon
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-10-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -52,6 +52,20 @@ dependencies:
|
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: require_all
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
55
69
|
description:
|
|
56
70
|
email:
|
|
57
71
|
- benny.sitbon@gmail.com
|
|
@@ -70,6 +84,12 @@ files:
|
|
|
70
84
|
- lib/slack_widgets.rb
|
|
71
85
|
- lib/slack_widgets/version.rb
|
|
72
86
|
- lib/slack_widgets/widgets/buttons/button.rb
|
|
87
|
+
- lib/slack_widgets/widgets/buttons/danger_button.rb
|
|
88
|
+
- lib/slack_widgets/widgets/buttons/primary_button.rb
|
|
89
|
+
- lib/slack_widgets/widgets/pickers/external_picker.rb
|
|
90
|
+
- lib/slack_widgets/widgets/pickers/picker.rb
|
|
91
|
+
- lib/slack_widgets/widgets/pickers/static_picker.rb
|
|
92
|
+
- lib/slack_widgets/widgets/pickers/user_picker.rb
|
|
73
93
|
- slack_widgets.gemspec
|
|
74
94
|
homepage: https://github.com/BennySitbon/slack_widgets
|
|
75
95
|
licenses:
|