dingtalk-client 0.2.0 → 0.2.1
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/.rubocop.yml +2 -0
- data/Gemfile.lock +1 -1
- data/bin/console +1 -0
- data/lib/dingtalk/client.rb +3 -5
- data/lib/dingtalk/client/configurable.rb +2 -0
- data/lib/dingtalk/client/group_robot_client.rb +1 -1
- data/lib/dingtalk/client/group_robot_client/notify_markdown.rb +6 -3
- data/lib/dingtalk/client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaaf81ec39e4791acf07d6ec576a1f7d4e1642150d76287db4ce8b0923e4f632
|
4
|
+
data.tar.gz: 51e7d96894aa96882eefbeb4085cb637da3db2d0bf8bd3b1811500edc1dd25c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddac72dcf29874c2fdedd1fafc0a7612b046b61ed278a5b55813725baf554cde61a09e7c576d6fa7e6e2bf030f0e4d67ac976110d5f5844a266bd5a1f69b8a15
|
7
|
+
data.tar.gz: c4cbd1f9b659b3c8a461c91ab822867c63e0dab546fe0ee879342c9db7ccbbea747486725d43159fab919a420e8d959455c938c969cda996085d5efacbd4e614
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/bin/console
CHANGED
data/lib/dingtalk/client.rb
CHANGED
@@ -4,18 +4,16 @@ require 'httparty'
|
|
4
4
|
require 'active_support/all'
|
5
5
|
require 'dingtalk/client/errors'
|
6
6
|
require 'dingtalk/client/result'
|
7
|
-
require 'dingtalk/client/configurable'
|
8
7
|
|
9
8
|
module Dingtalk
|
10
9
|
# DingTalk Client
|
11
10
|
# @see https://open-doc.dingtalk.com/
|
12
11
|
module Client
|
13
12
|
extend ActiveSupport::Autoload
|
13
|
+
autoload :Configurable
|
14
14
|
autoload :GroupRobotClient
|
15
15
|
include Configurable
|
16
|
-
|
17
|
-
|
18
|
-
base.include GroupRobotClient
|
19
|
-
end
|
16
|
+
include GroupRobotClient
|
17
|
+
extend self
|
20
18
|
end
|
21
19
|
end
|
@@ -28,10 +28,12 @@ module Dingtalk
|
|
28
28
|
# @see Configurable
|
29
29
|
class Configuration
|
30
30
|
attr_writer :group_robot_tokens, :group_robot_webhook_prefix, :template_dir
|
31
|
+
attr_accessor :is_debugging
|
31
32
|
|
32
33
|
def initialize
|
33
34
|
@group_robot_webhook_prefix = 'https://oapi.dingtalk.com/robot/send?access_token='
|
34
35
|
@template_dir = '.'
|
36
|
+
@is_debugging = false
|
35
37
|
end
|
36
38
|
|
37
39
|
def group_robot_tokens
|
@@ -16,7 +16,7 @@ module Dingtalk
|
|
16
16
|
include NotifyFeedcard
|
17
17
|
base_uri Dingtalk::Client.config.group_robot_webhook_prefix
|
18
18
|
headers 'Content-Type' => 'application/json'
|
19
|
-
logger ::Logger.new($stdout), :debug, :curl
|
19
|
+
logger ::Logger.new($stdout), :debug, :curl if Dingtalk::Client.config.is_debugging
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -10,7 +10,8 @@ module Dingtalk
|
|
10
10
|
# @option options [String] template_file (code) without file suffix
|
11
11
|
# @option options [Boolean] is_at_all (false)
|
12
12
|
# @option options [Array] at_mobiles ([])
|
13
|
-
|
13
|
+
# @yield a block which will execute in template locale environment
|
14
|
+
def notify_markdown(code, title, **options, &block)
|
14
15
|
options.with_defaults!(
|
15
16
|
template_file: code,
|
16
17
|
is_at_all: false,
|
@@ -22,7 +23,7 @@ module Dingtalk
|
|
22
23
|
template_file = String(options[:template_file])
|
23
24
|
is_at_all = is_at_all != false
|
24
25
|
at_mobiles = Array(at_mobiles)
|
25
|
-
content = get_markdown_content(template_file)
|
26
|
+
content = get_markdown_content(template_file, &block)
|
26
27
|
body = get_markdown_body(title, content, is_at_all, at_mobiles)
|
27
28
|
notify(token, body)
|
28
29
|
end
|
@@ -30,7 +31,9 @@ module Dingtalk
|
|
30
31
|
private
|
31
32
|
|
32
33
|
# @param template_file [String]
|
33
|
-
|
34
|
+
# @yield a block which will execute in template locale environment
|
35
|
+
def get_markdown_content(template_file, &block)
|
36
|
+
instance_eval(&block) if block
|
34
37
|
path = "#{Dingtalk::Client.config.template_dir}/#{template_file}.markdown.erb"
|
35
38
|
ERB.new(File.read(path)).result(binding)
|
36
39
|
rescue Errno::ENOENT
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dingtalk-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
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-10-
|
11
|
+
date: 2018-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|