msteams-ruby-client 0.1.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27a007db1684e5b9f9d4be975f9dcced956ae12de5bf483fb4796af6481c0cc0
4
- data.tar.gz: 29fcfbbb492750b288242fb5ce83c56fabeb83f6a0d729fb73c72b6e652e865a
3
+ metadata.gz: d7a10378121e4bef5e05ef6e6b618ccab1bf82f6e30aa3c69a27853885391df6
4
+ data.tar.gz: 00156ccb5e0c8bd106cce98cf1c77d78be26ad1a519f9b08275c3df186879c35
5
5
  SHA512:
6
- metadata.gz: 862c56babb93f0370dc1db323d8c802160ce12d2ec8992ed2d8d4a1677ca1fd66eef1b8883cefcf25b983ce60c5b405725145ee24eafc08736a75a89d0dde530
7
- data.tar.gz: d5a11f4a0ea583c930c175f9d094a493b09c0241562c13af42d34d7652e1b97eeeba5d9462ab2e0b5b0cf1109530cd969abe2121a3970bea4169be7f022ba041
6
+ metadata.gz: 41c9a0786dd3a78d4d0aedbaceee83c40a82a10b007f9ee76f57a96d238bc3bf07c91040cc5bc5c9b1b88b85dc5ebc2bece1fead1aff493930bf6f44105d329c
7
+ data.tar.gz: a55301185252b97e9de51c064543eafe2e69c3bce2226dd93812f6e6e3c01775986aaa670f78cab6c56518c2bf1b75d2f8cc08d770355fc0ad595dc13ea42382
@@ -3,5 +3,5 @@ require 'net/http'
3
3
  require 'openssl'
4
4
  require 'uri'
5
5
 
6
- require_relative 'msteams/ruby/client/version'
7
- require_relative 'msteams/ruby/client'
6
+ require_relative 'teams/version'
7
+ require_relative 'teams'
@@ -0,0 +1,3 @@
1
+ class Teams
2
+ VERSION = '1.1.0'.freeze
3
+ end
data/lib/teams.rb ADDED
@@ -0,0 +1,32 @@
1
+ class Teams
2
+ def initialize(webhook_url = nil)
3
+ @webhook_url = webhook_url || ENV['TEAMS_WEBHOOK_URL'] || ENV['MSTEAMS_RUBY_CLIENT_WEBHOOK_URL']
4
+ end
5
+
6
+ def post(text, options = {})
7
+ uri = URI.parse(@webhook_url)
8
+
9
+ request = Net::HTTP::Post.new(uri.request_uri)
10
+ request['Content-Type'] = 'application/json'
11
+ request.body = {
12
+ title: options[:title],
13
+ text: options[:text2html] ? text2html(text) : text,
14
+ themeColor: options[:themeColor],
15
+ summary: options[:summary] || text
16
+ }.to_json
17
+
18
+ http = Net::HTTP.new(uri.host, uri.port)
19
+ http.use_ssl = true
20
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
21
+ http.start { |h| h.request(request) }
22
+ end
23
+
24
+ def text2html(text)
25
+ html = text.clone
26
+ URI::DEFAULT_PARSER.extract(text, %w[http https]).uniq.each do |url|
27
+ html.gsub!(url, %(<a href="#{url}">#{url}</a>))
28
+ end
29
+ html.gsub!("\n", "<br>\n")
30
+ html
31
+ end
32
+ end
metadata CHANGED
@@ -1,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msteams-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - oooooooo
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-26 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.16'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.16'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
11
+ date: 2020-12-27 00:00:00.000000000 Z
12
+ dependencies: []
41
13
  description: Microsoft Teams API Client.
42
14
  email:
43
15
  - 60764+oooooooo@users.noreply.github.com
@@ -45,20 +17,10 @@ executables: []
45
17
  extensions: []
46
18
  extra_rdoc_files: []
47
19
  files:
48
- - ".gitignore"
49
- - Gemfile
50
- - LICENSE.txt
51
- - README.md
52
- - Rakefile
53
- - bin/console
54
- - bin/setup
55
- - examples/post/Gemfile
56
- - examples/post/post.rb
57
20
  - lib/msteams-ruby-client.rb
58
- - lib/msteams/ruby/client.rb
59
- - lib/msteams/ruby/client/version.rb
60
21
  - lib/msteams_ruby_client.rb
61
- - msteams-ruby-client.gemspec
22
+ - lib/teams.rb
23
+ - lib/teams/version.rb
62
24
  homepage: https://github.com/oooooooo/msteams-ruby-client
63
25
  licenses:
64
26
  - MIT
@@ -78,8 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
40
  - !ruby/object:Gem::Version
79
41
  version: '0'
80
42
  requirements: []
81
- rubyforge_project:
82
- rubygems_version: 2.7.6
43
+ rubygems_version: 3.1.4
83
44
  signing_key:
84
45
  specification_version: 4
85
46
  summary: Teams API Client.
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- *.gem
2
- /.bundle/
3
- /.yardoc
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- Gemfile.lock
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in msteams-ruby-client.gemspec
6
- gemspec
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2018 oooooooo
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/README.md DELETED
@@ -1,38 +0,0 @@
1
- # Msteams::Ruby::Client
2
-
3
- Ruby Wrapper Library to send requests to Microsoft Teams Webhooks.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'msteams-ruby-client'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install msteams-ruby-client
20
-
21
- ## Usage
22
-
23
- ```ruby
24
- require 'msteams-ruby-client'
25
-
26
- msteams = Msteams::Ruby::Client.new('<webhook url>')
27
- msteams.post('hello')
28
- ```
29
-
30
- Or
31
-
32
- ```bash
33
- $ MSTEAMS_RUBY_CLIENT_WEBHOOK_URL=https://outlook.office.com/webhook/... examples/post/post.rb
34
- ```
35
-
36
- ## License
37
-
38
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile DELETED
@@ -1,2 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- task default: :spec
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'msteams/ruby/client'
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require 'irb'
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,3 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gem 'msteams-ruby-client', path: '../..'
@@ -1,4 +0,0 @@
1
- require 'msteams-ruby-client'
2
-
3
- msteams = Msteams::Ruby::Client.new
4
- msteams.post('hello')
@@ -1,7 +0,0 @@
1
- module Msteams
2
- module Ruby
3
- class Client
4
- VERSION = '0.1.0'.freeze
5
- end
6
- end
7
- end
@@ -1,22 +0,0 @@
1
- module Msteams
2
- module Ruby
3
- class Client
4
- def initialize(webhook_url = '')
5
- @webhook_url = webhook_url || ENV['MSTEAMS_RUBY_CLIENT_WEBHOOK_URL']
6
- end
7
-
8
- def post(text)
9
- uri = URI.parse(@webhook_url)
10
-
11
- request = Net::HTTP::Post.new(uri.request_uri)
12
- request['Content-Type'] = 'application/json'
13
- request.body = { text: text }.to_json
14
-
15
- http = Net::HTTP.new(uri.host, uri.port)
16
- http.use_ssl = true
17
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
18
- http.start { |h| h.request(request) }
19
- end
20
- end
21
- end
22
- end
@@ -1,37 +0,0 @@
1
-
2
- lib = File.expand_path('lib', __dir__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'msteams/ruby/client/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'msteams-ruby-client'
8
- spec.version = Msteams::Ruby::Client::VERSION
9
- spec.authors = ['oooooooo']
10
- spec.email = ['60764+oooooooo@users.noreply.github.com']
11
-
12
- spec.summary = 'Teams API Client.'
13
- spec.description = 'Microsoft Teams API Client.'
14
- spec.homepage = 'https://github.com/oooooooo/msteams-ruby-client'
15
- spec.license = 'MIT'
16
-
17
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
- # to allow pushing to a single host or delete this section to allow pushing to any host.
19
- # if spec.respond_to?(:metadata)
20
- # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
- # else
22
- # raise 'RubyGems 2.0 or newer is required to protect against ' \
23
- # 'public gem pushes.'
24
- # end
25
-
26
- # Specify which files should be added to the gem when it is released.
27
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
29
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
- end
31
- spec.bindir = 'exe'
32
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
- spec.require_paths = ['lib']
34
-
35
- spec.add_development_dependency 'bundler', '~> 1.16'
36
- spec.add_development_dependency 'rake', '~> 10.0'
37
- end