msteams-ruby-client 0.3.0 → 0.4.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 -0
- data/lib/teams/version.rb +1 -1
- data/lib/teams.rb +14 -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: f9f032077f38bb966520725a0feb92f635c5080cceecf9a6e5de170a556728ea
|
4
|
+
data.tar.gz: 8510aef9b7ee62433421b09e07856533fa95621b66861d35d05541f0d027106a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a763cb5df695a1ac348e153fea46985da7e1d23cf96d072a2c765b223e3e043fa130828d1c6791ee963413140eca72867d09b11d61a138153f78452971127031
|
7
|
+
data.tar.gz: 3b8be43ea8fe3c49715d88dc4438bd58dd5861b5153d4e2e13b915ee1631f706499c4bd8910f0a3ade1589f8b8562fc733ff908c3d475354ba742c9fd94d5790
|
data/README.md
CHANGED
@@ -35,6 +35,16 @@ Or
|
|
35
35
|
$ MSTEAMS_RUBY_CLIENT_WEBHOOK_URL=https://outlook.office.com/webhook/... bundle exec ruby examples/post/post.rb
|
36
36
|
```
|
37
37
|
|
38
|
+
## Options
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
teams.post('hello',
|
42
|
+
summary: 'world', # default is 1st argument ( Ex. hello )
|
43
|
+
text2html: true, # default is false
|
44
|
+
title: 'Title' # default is blabk, \n to <br> and autolink
|
45
|
+
)
|
46
|
+
```
|
47
|
+
|
38
48
|
## License
|
39
49
|
|
40
50
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/teams/version.rb
CHANGED
data/lib/teams.rb
CHANGED
@@ -8,11 +8,24 @@ class Teams
|
|
8
8
|
|
9
9
|
request = Net::HTTP::Post.new(uri.request_uri)
|
10
10
|
request['Content-Type'] = 'application/json'
|
11
|
-
request.body = {
|
11
|
+
request.body = {
|
12
|
+
title: options[:title],
|
13
|
+
text: options[:text2html] ? text2html(text) : text,
|
14
|
+
summary: options[:summary] || text
|
15
|
+
}.to_json
|
12
16
|
|
13
17
|
http = Net::HTTP.new(uri.host, uri.port)
|
14
18
|
http.use_ssl = true
|
15
19
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
16
20
|
http.start { |h| h.request(request) }
|
17
21
|
end
|
22
|
+
|
23
|
+
def text2html(text)
|
24
|
+
html = text.clone
|
25
|
+
URI::DEFAULT_PARSER.extract(text, %w[http https]).uniq.each do |url|
|
26
|
+
html.gsub!(url, %(<a href="#{url}">#{url}</a>))
|
27
|
+
end
|
28
|
+
html.gsub!("\n", "<br>\n")
|
29
|
+
html
|
30
|
+
end
|
18
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: msteams-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- oooooooo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|