active_notifier 0.4.1 → 0.4.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 254bfd0c06440a25f2cf53153898e2010418ca96a56cbe6c7827825e5f9e818a
|
4
|
+
data.tar.gz: 258b87d6e0eb00c59eb50f52d2bc42f2394e9ee04f8d0bee741521f97c1d81dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9663e46179b67b36a7e6ac2314e1543f2e5e36e45e664e679aaf0d2df111c3007dc294fad8c806cf800b00735ff6bf87efa53b502cf5b404505ad26c2d9eb949
|
7
|
+
data.tar.gz: ed3b18444058d482c8876325611b9cee248ae8e628d4828009515db942ffd90fbd259819b3d7afef0318600309904f234e8ed9d495666cbe83b168b0b9da0b42
|
data/README.md
CHANGED
@@ -16,47 +16,72 @@ gem 'active_notifier'
|
|
16
16
|
|
17
17
|
And then execute:
|
18
18
|
|
19
|
-
|
19
|
+
```shell
|
20
|
+
$ bundle
|
21
|
+
```
|
20
22
|
|
21
23
|
Or install it yourself as:
|
22
24
|
|
23
|
-
|
25
|
+
```shell
|
26
|
+
$ gem install active_notifier
|
27
|
+
```
|
28
|
+
|
29
|
+
## Support
|
30
|
+
|
31
|
+
| Notifier adapter | message type | support options |
|
32
|
+
| ---------------- | -------------- | --------------- |
|
33
|
+
| Dingtalk | text, markdown | all |
|
24
34
|
|
25
35
|
## Basic Usage
|
26
36
|
|
27
37
|
Just notify the message through a webhook token, ActiveNotifier use Dingtalk by default, the webhook token
|
28
38
|
need be a accessible dingtalk webhook token.
|
29
39
|
|
40
|
+
In your IRB environment:
|
41
|
+
|
30
42
|
```ruby
|
31
43
|
ActiveNotifier.exec(token: "your-webhook-token", message: "your-message")
|
32
44
|
```
|
33
45
|
|
34
46
|
Is it too much trouble to set the token and message always? You can save commonly used ones and access them via better ways.
|
35
|
-
For token, ActiveNotifier use channel_tokens to store it, and for message, we can use the ERB template and locals data, like the familiar ActiveView does.
|
36
47
|
|
48
|
+
For token, ActiveNotifier use `channel_tokens` to store it, and for message, we can use the ERB template and `data` option for locals, like the familiar Rails does.
|
49
|
+
|
50
|
+
In any file you want to config ActiveNotifier:
|
37
51
|
|
38
52
|
```ruby
|
39
53
|
ActiveNotifier.configure do |config|
|
40
54
|
config.channel_tokens = { my_channel: "xxx" }
|
41
|
-
config.template_home =
|
55
|
+
config.template_home = SOME_DIR
|
42
56
|
end
|
43
57
|
```
|
44
58
|
|
59
|
+
Edit the template of `my_channel`:
|
60
|
+
|
45
61
|
```shell
|
46
|
-
echo "## #{data[:title]\n> #{data[:body]}}" >
|
62
|
+
$ echo "## #{data[:title]\n> #{data[:body]}}" > SOME_DIR/my_channel.markdown.erb
|
47
63
|
```
|
48
64
|
|
65
|
+
Then execute it in IRB:
|
66
|
+
|
49
67
|
```ruby
|
50
68
|
ActiveNotifier.exec(token_channel: :my_channel, template: :my_channel, data: { title: "Message Title", body: "Message Body" })
|
51
69
|
```
|
52
70
|
|
53
|
-
Also when token_channel and template is the same, we can simplify it by using the first optional argument channel
|
71
|
+
Also when token_channel name and template name is the same, we can simplify it by using the first optional argument `channel`
|
54
72
|
|
55
73
|
```ruby
|
56
74
|
ActiveNotifier.exec(:my_channel, data: { title: "Message Title", body: "Message Body" })
|
57
75
|
```
|
76
|
+
### For Rails application
|
77
|
+
|
78
|
+
There are generators that simplify the above operations:
|
79
|
+
|
80
|
+
```shell
|
81
|
+
$ rails generate active_notifier:install
|
82
|
+
```
|
58
83
|
|
59
|
-
##
|
84
|
+
## More knowledge
|
60
85
|
|
61
86
|
### Send message with dynamic type
|
62
87
|
|
@@ -103,7 +128,7 @@ Notifer.exec(...)
|
|
103
128
|
|
104
129
|
* [More Examples](https://github.com/pinewong/active_notifier/blob/master/spec/active_notifier_spec.rb)
|
105
130
|
* [RDoc](https://www.rubydoc.info/github/pinewong/active_notifier)
|
106
|
-
* [Gem RDoc](http://www.rubydoc.info/gems/active_notifier/0.4.
|
131
|
+
* [Gem RDoc](http://www.rubydoc.info/gems/active_notifier/0.4.2)
|
107
132
|
|
108
133
|
## Development
|
109
134
|
|
data/active_notifier.gemspec
CHANGED
@@ -30,6 +30,8 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
|
+
spec.required_ruby_version = ">= 2.3"
|
34
|
+
|
33
35
|
spec.add_dependency "active_adapter", "~> 0.1.0"
|
34
36
|
spec.add_dependency "activesupport", "~> 5.0"
|
35
37
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ActiveNotifier
|
2
|
+
module Generators
|
3
|
+
# ActiveNotifier generator for Rails application
|
4
|
+
class InstallGenerator < ::Rails::Generators::Base
|
5
|
+
desc "Generates ActiveNotifier configuration files."
|
6
|
+
source_root File.expand_path("../../", __dir__)
|
7
|
+
|
8
|
+
def copy_initializer
|
9
|
+
template "generators/active_notifier/templates/active_notifier.rb", "config/initializers/active_notifier.rb"
|
10
|
+
end
|
11
|
+
|
12
|
+
def copy_templates
|
13
|
+
directory "active_notifier/templates", "app/views/active_notifier"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
ActiveNotifier.configure do |config|
|
2
|
+
# Set alias const for ActiveNotifier
|
3
|
+
# Default: :Notifier
|
4
|
+
# config.const_name = :Notifier
|
5
|
+
#
|
6
|
+
# Set message Adapter
|
7
|
+
# Default: :dingtalk
|
8
|
+
# config.adapter = :dingtalk
|
9
|
+
#
|
10
|
+
# The webhook tokens of channel
|
11
|
+
# config.channel_tokens = {
|
12
|
+
# default: "dingtalk_token_xxxxxxxxxxxxxxxxx",
|
13
|
+
# order: "dingtalk_token_for_order_xxxxxxx",
|
14
|
+
# }
|
15
|
+
#
|
16
|
+
# The template home directory
|
17
|
+
config.template_home = Rails.root.join("app", "views", "active_notifier")
|
18
|
+
#
|
19
|
+
# The priority type for message, if notifier execute without type option and there are multiple valid types,
|
20
|
+
# then ActiveNotifier will use the template with this type first
|
21
|
+
# Default: :markdown
|
22
|
+
# config.priority_type = :markdown
|
23
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pine Wong
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_adapter
|
@@ -67,6 +67,8 @@ files:
|
|
67
67
|
- lib/active_notifier/templates/default.markdown.erb
|
68
68
|
- lib/active_notifier/templates/default.text.erb
|
69
69
|
- lib/active_notifier/version.rb
|
70
|
+
- lib/generators/active_notifier/install_generator.rb
|
71
|
+
- lib/generators/active_notifier/templates/active_notifier.rb
|
70
72
|
homepage: https://github.com/pinewong/active_notifier
|
71
73
|
licenses: []
|
72
74
|
metadata: {}
|
@@ -78,7 +80,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
80
|
requirements:
|
79
81
|
- - ">="
|
80
82
|
- !ruby/object:Gem::Version
|
81
|
-
version: '
|
83
|
+
version: '2.3'
|
82
84
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
85
|
requirements:
|
84
86
|
- - ">="
|