traq_webhook 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 16615aeb9eacc25370851a85e1dcad3724a254aab055e637753c55333f2db258
4
+ data.tar.gz: 400711db9d91883997c299cbebdef2ff78c6a40ad0055dc5dba6ebcd5a0716b2
5
+ SHA512:
6
+ metadata.gz: 8d37aa1d018f8415a4eeadbf47a8666c46038ccb4ffa3dab58030b61b11c26b90744a5eaed90094bdee162e002f8bffb1bfa1ce0546a28a20513de23fd7df4f4
7
+ data.tar.gz: 20da2c0f373ccf9ad2376924b65650e09acf8c7609624af84c3e3c98b99950412349185241b57f812b798b221f07ffc5b6818c8b6f9ce31c14ea7eab153a60d7
data/.gitignore ADDED
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in traq_webhook.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 T Nagano
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # traQ_webhook-ruby
2
+ traQ Webhook用Rubyライブラリ
3
+
4
+ ----
5
+
6
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/traq_webhook`. To experiment with that code, run `bin/console` for an interactive prompt.
7
+
8
+ TODO: Delete this and the text above, and describe your gem
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'traq_webhook'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install traq_webhook
25
+
26
+ ## Usage
27
+
28
+ ```ruby
29
+ require 'traq_webhook'
30
+
31
+ client = TraqWebhook::Client.new do |config|
32
+ config.id = 'YOUR TRAQ_WEBHOOK_ID'
33
+ config.token = 'YOUR TRAQ_SECRET_TOKEN'
34
+ end
35
+
36
+ message = 'example message'
37
+ client.post(message)
38
+ ```
39
+
40
+ ## Development
41
+
42
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
43
+
44
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
45
+
46
+ ## Contributing
47
+
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/traq_webhook.
@@ -0,0 +1,3 @@
1
+ module TraqWebhook
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,35 @@
1
+ require "traq_webhook/version"
2
+ require "net/http"
3
+ require "uri"
4
+ require "openssl"
5
+
6
+ module TraqWebhook
7
+ class Client
8
+ attr_accessor :id, :token
9
+
10
+ def initialize
11
+ yield self if block_given?
12
+ end
13
+
14
+ def post(message)
15
+ signature = calc_hmacsha1(self.token, message)
16
+ uri = URI.parse('https://q.trap.jp/api/1.0/webhooks/' + self.id)
17
+ req = Net::HTTP::Post.new(uri.path)
18
+ req['Content-Type'] = 'text/plain; charset=utf-8'
19
+ req['X-TRAQ-Signature'] = signature
20
+ req.body = message
21
+ option = {
22
+ use_ssl: uri.scheme = "https"
23
+ }
24
+ res = Net::HTTP.start(uri.hostname, uri.port, option) do |http|
25
+ http.request(req)
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def calc_hmacsha1(token, body)
32
+ OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), token, body)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,33 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "traq_webhook/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "traq_webhook"
8
+ spec.version = TraqWebhook::VERSION
9
+ spec.authors = ["nagatech"]
10
+ spec.email = ["cheesecakebot@yahoo.co.jp"]
11
+
12
+ spec.summary = %q{traQ Webhook用ライブラリ}
13
+ spec.description = %q{デジタル創作同好会traPのSNSツールtraQのWebhookを簡単に扱うためのライブラリ}
14
+ spec.homepage = "https://github.com/nagatea/traQ_webhook-ruby"
15
+
16
+ if spec.respond_to?(:metadata)
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/nagatea/traQ_webhook-ruby"
19
+ else
20
+ raise "RubyGems 2.0 or newer is required to protect against " \
21
+ "public gem pushes."
22
+ end
23
+
24
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 2.0"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: traq_webhook
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - nagatech
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-05-15 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: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
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'
41
+ description: デジタル創作同好会traPのSNSツールtraQのWebhookを簡単に扱うためのライブラリ
42
+ email:
43
+ - cheesecakebot@yahoo.co.jp
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE
51
+ - README.md
52
+ - lib/traq_webhook.rb
53
+ - lib/traq_webhook/version.rb
54
+ - traq_webhook.gemspec
55
+ homepage: https://github.com/nagatea/traQ_webhook-ruby
56
+ licenses: []
57
+ metadata:
58
+ homepage_uri: https://github.com/nagatea/traQ_webhook-ruby
59
+ source_code_uri: https://github.com/nagatea/traQ_webhook-ruby
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.7.3
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: traQ Webhook用ライブラリ
80
+ test_files: []