slackpost 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b3af1268aea6ef6f47d8779c6cd8c847098deb5b9b7f76c307a85c822bfe921d
4
+ data.tar.gz: e2dbd4647b2341078821d1538848889fa520d29b3f126598c1f96b8fa4919867
5
+ SHA512:
6
+ metadata.gz: 5df6cd0a6298ac14745bde2ec00e715875300679a957a4e3dd2269b89d411eefe63d8185993b21dab10b3c2eb98a2c74d990b36c77a9b9a311b43bbe756a0b26
7
+ data.tar.gz: f4b1929a53f19010bdfc1b9692e8dcd97c20655891a716a95fd48c752b7283f3d5c90f54c162228601823ecc9221b20c95635bbf635c39f194c94c7802e43d3b
checksums.yaml.gz.sig ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /.idea
10
+ /certs
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 2.0.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in slackpost.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ slackpost (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ minitest (5.11.3)
10
+ rake (12.3.2)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ bundler (~> 2.0)
17
+ minitest (~> 5.11)
18
+ rake (~> 12.3)
19
+ slackpost!
20
+
21
+ BUNDLED WITH
22
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Guillermo Mora
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 ADDED
@@ -0,0 +1,43 @@
1
+ # Slackpost
2
+
3
+ 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/slackpost`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'slackpost'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install slackpost
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/slackpost. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Slackpost project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/slackpost/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'slackpost'
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 ADDED
@@ -0,0 +1,8 @@
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
@@ -0,0 +1,25 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIESDCCArCgAwIBAgI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uAcYQ35c3sR
18
+ bZ8nu4TZDlCIcPeyDkDV82sIQkgprV7HfdDoOL4WKTmu8spOKNgvUGBtia2WJPeP
19
+ xGzfbirp6EVwxRbIi40VF3QrIPhJSmOqgJ4hkS9eo7a/cvs1TTxqD8urGUJFEqxc
20
+ 1q4VKAy83+WIUo97EDZY+Z/clTgIdb1dnp1ssRSA7/qxWwi5eb9ZB7xaRyacLIQU
21
+ lhbgzWi7Rt2YNWmn6xbCbV66wY5hvkhx+K9Q4ftwSaJPB/YKtb068AOQdw9X7gNs
22
+ qwC8vhUr+6lvVCDzCAAR35FdI1dlDYcw65K5LsimEUIlkEp4u5TKByU6FHmpOMOG
23
+ VJKihJu6eL/ifYWEu1J1/X0dTrOJd3mNiwW4P/CWon8w8et7wE4L35A0p4eQHQ2J
24
+ 93X3evWNzWFE6rCL91ypRV0bIIIsQZxoPXjOARyGpRSF15IdjDSA4wjLFCw=
25
+ -----END CERTIFICATE-----
@@ -0,0 +1,10 @@
1
+ module Slackpost
2
+ # Holds gem configuration
3
+ class Configuration
4
+ attr_accessor :slack_token
5
+
6
+ def initialize
7
+ @slack_token = :slack_token
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module Slackpost
2
+ class SlackpostError < StandardError; end
3
+ end
@@ -0,0 +1,3 @@
1
+ module Slackpost
2
+ VERSION = '0.1.1'.freeze
3
+ end
data/lib/slackpost.rb ADDED
@@ -0,0 +1,52 @@
1
+ require 'slackpost/version'
2
+ require 'slackpost/configuration'
3
+ require 'slackpost/exceptions'
4
+
5
+ require 'uri'
6
+ require 'json'
7
+ require 'net/http'
8
+ require 'net/https'
9
+
10
+ # docs
11
+ module Slackpost
12
+ class << self
13
+ def config
14
+ @config ||= Configuration.new
15
+ end
16
+
17
+ def configure
18
+ yield(config)
19
+ end
20
+
21
+ def simple_msg_to_channel(msg, channel)
22
+ body = { channel: channel,
23
+ link_names: 1,
24
+ text: msg }
25
+ send_slackpost(body)
26
+ end
27
+
28
+ def attachment_msg_to_channel(msg, channel, att_title, att_value, att_color)
29
+ body = { channel: channel,
30
+ link_names: 1,
31
+ text: msg,
32
+ attachments: [{ fallback: "#{att_title} #{att_value}",
33
+ color: att_color,
34
+ fields: [{ title: att_title,
35
+ value: att_value }] }] }
36
+ send_slackpost(body)
37
+ end
38
+
39
+ def send_slackpost(body)
40
+ uri = URI.parse("https://hooks.slack.com/services/#{config.slack_token}")
41
+ response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
42
+ request = Net::HTTP::Post.new(uri)
43
+ request['Content-Type'] = 'application/json'
44
+ request.body = body.to_json
45
+ http.request(request)
46
+ end
47
+ raise SlackpostError if response.code != '200'
48
+
49
+ response
50
+ end
51
+ end
52
+ end
data/slackpost.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'slackpost/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'slackpost'
7
+ spec.version = Slackpost::VERSION
8
+ spec.authors = ['Guillermo Mora']
9
+ spec.email = ['guillermo@cleverppc.com']
10
+
11
+ spec.summary = 'Post messages in slack channels.'
12
+ spec.description = 'The simplest way of posting messages and attachments to your slack channels.'
13
+ spec.homepage = 'https://github.com/guillermijas/slackpost'
14
+ spec.license = 'MIT'
15
+
16
+ if spec.respond_to?(:metadata)
17
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = 'https://github.com/guillermijas/slackpost'
20
+ spec.metadata['changelog_uri'] = 'https://github.com/guillermijas/slackpost'
21
+ else
22
+ raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
23
+ end
24
+
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ end
28
+
29
+ spec.bindir = 'exe'
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ['lib']
32
+ spec.cert_chain = ['certs/slackpost-cert.pem']
33
+ spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $PROGRAM_NAME =~ /gem\z/
34
+ spec.add_development_dependency 'bundler', '~> 2.0'
35
+ spec.add_development_dependency 'minitest', '~> 5.11'
36
+ spec.add_development_dependency 'rake', '~> 12.3'
37
+ end
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ O�4D� �!.����<����{���2_��җ����f�t��|dg���-TNrB�
2
+ ['��[�g��@i��8K;�1�ָG�i�u-��. �
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: slackpost
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Guillermo Mora
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIESDCCArCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAnMSUwIwYDVQQDDBxndWls
14
+ bGVybWlqYXMvREM9Z21haWwvREM9Y29tMB4XDTE5MDIxNDExNDQxNFoXDTIwMDIx
15
+ NDExNDQxNFowJzElMCMGA1UEAwwcZ3VpbGxlcm1pamFzL0RDPWdtYWlsL0RDPWNv
16
+ bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAKuO98KglvP06NXgNW8K
17
+ 0Pl8xXngSoIqYVEMyt4kTpOKU634q95OpKq917DVrAjKpLTmy97pBIXmhar6iRc8
18
+ lj08uVs5ZW6DoTwjHk+yrl7r/wk0V4u0iMzR7kbmF1YcqvkcHUmU0g8I/QPcwlt+
19
+ M8qPpBVWLdsdMTwGw4K5E7kH57I0WaJlxM79BJk4LfHW6ZIDbgzwchS1e8W9mp/K
20
+ NVfOc7Dj1pOLEvxQiIOsdxRz/mw7KxR8rX4fr4oxY5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END CERTIFICATE-----
37
+ date: 2019-02-21 00:00:00.000000000 Z
38
+ dependencies:
39
+ - !ruby/object:Gem::Dependency
40
+ name: bundler
41
+ requirement: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - "~>"
44
+ - !ruby/object:Gem::Version
45
+ version: '2.0'
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '2.0'
53
+ - !ruby/object:Gem::Dependency
54
+ name: minitest
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '5.11'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '5.11'
67
+ - !ruby/object:Gem::Dependency
68
+ name: rake
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '12.3'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '12.3'
81
+ description: The simplest way of posting messages and attachments to your slack channels.
82
+ email:
83
+ - guillermo@cleverppc.com
84
+ executables: []
85
+ extensions: []
86
+ extra_rdoc_files: []
87
+ files:
88
+ - ".gitignore"
89
+ - ".travis.yml"
90
+ - Gemfile
91
+ - Gemfile.lock
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - bin/console
96
+ - bin/setup
97
+ - certs/slackpost-cert.pem
98
+ - lib/slackpost.rb
99
+ - lib/slackpost/configuration.rb
100
+ - lib/slackpost/exceptions.rb
101
+ - lib/slackpost/version.rb
102
+ - slackpost.gemspec
103
+ homepage: https://github.com/guillermijas/slackpost
104
+ licenses:
105
+ - MIT
106
+ metadata:
107
+ allowed_push_host: https://rubygems.org
108
+ homepage_uri: https://github.com/guillermijas/slackpost
109
+ source_code_uri: https://github.com/guillermijas/slackpost
110
+ changelog_uri: https://github.com/guillermijas/slackpost
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.7.8
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Post messages in slack channels.
131
+ test_files: []
metadata.gz.sig ADDED
Binary file