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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -0
  3. data/lib/teams/version.rb +1 -1
  4. data/lib/teams.rb +14 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c9f63d2b5337a6827e51664e6d268319433a36bb4edd9b9069627220ddcb71b
4
- data.tar.gz: 60f3324f4f9f577d591b01160f31feaa69d9b42b7016534137789d681a459353
3
+ metadata.gz: f9f032077f38bb966520725a0feb92f635c5080cceecf9a6e5de170a556728ea
4
+ data.tar.gz: 8510aef9b7ee62433421b09e07856533fa95621b66861d35d05541f0d027106a
5
5
  SHA512:
6
- metadata.gz: 7fb6ee0fa7f585cfe7bd42bdd42bd6ef848d3408f782d3cf90efacae820289d14a111a8c08518649924fbfc57b63899fe88c63e0ec3bb715f2c49aba3d349b0f
7
- data.tar.gz: c7620db001e2aa0c8dbd7e4d6152cf22cac1b1a8fcacaf9e4a543223c73a331df12a0ca28f1c1c4bbea82edf2b8ef6dec849c4e0ce71186d0fe60738d34f6afa
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
@@ -1,3 +1,3 @@
1
1
  class Teams
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
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 = { text: text, summary: options[:summary] || text }.to_json
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.3.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-06-20 00:00:00.000000000 Z
11
+ date: 2018-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler