diff -Nru ruby-slack-notifier-1.2.1/bin/test ruby-slack-notifier-1.5.1/bin/test --- ruby-slack-notifier-1.2.1/bin/test 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/bin/test 1970-01-01 00:00:00.000000000 +0000 @@ -1,27 +0,0 @@ -#!/usr/bin/env ruby - -require 'yaml' -YAML.load_file('.env').each do |key,var| - ENV[key] = var -end - -rubies = YAML.load_file('.travis.yml')['rvm'] -rubies.each do |ruby| - - # cleanup gemfile.locks - Dir[ 'spec*/**/*.lock' ].each do |lockfile| - puts "removing #{lockfile}" - system "rm #{lockfile}" - end - - pid = Process.fork do - exec "rvm #{ruby} do ruby spec/integration/ping_integration_test.rb" - end - - trap "INT" do - puts "exiting" - pid.send(:exit) - end - - Process.wait(pid) -end \ No newline at end of file diff -Nru ruby-slack-notifier-1.2.1/changelog.md ruby-slack-notifier-1.5.1/changelog.md --- ruby-slack-notifier-1.2.1/changelog.md 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/changelog.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ -# 1.2.1 -- use `#scrub` to (more selectively) strip invalid characters from strings before attempting to format. This allows valid japanese (and more) characters to be used. Thanks to @fukayatsu for reporting. - - This checks for the presence of the `scrub` method on string, so if on ruby < 2.1 you'll need to include & require the `string-scrub` gem to handle invalid characters. - -# 1.2.0 -- Strip invalid UTF-8 characters from message before attempting to format links. They are replaced with the unicode replacement character '[�](http://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character)'. [@ushu #26] - -# 1.1.0 -- add ability to pass `:http_options` to the initializer or `#ping`. this allows you to set options like `read_timeout` or `open_timeout`. See [issue #17](https://github.com/stevenosloan/slack-notifier/issues/17) for more information. - -# 1.0.0 -- [BREAKING!] To follow changes with slack, client is now initialized with a webhook url instead of team & token. For help upgrading read the [upgrade from 0.6.1 guide](docs/upgrade-from-0.6.1.md) - -# 0.6.1 -- fix bug in link_formatter to allow multiple links in a message - -# 0.6.0 -- add ability to pass in your own http client -- [BREAKING!] hook name moves to options array - -# 0.5.0 -- allow defaults to be set on initialization -- remove channel formatting [#8] - -# 0.4.1 -- allow default channel's to start with a "@" or "#" [#7] - -# 0.4.0 -- try and correct for a channel name being set without a leading "#" [@dlackty] - -# 0.3.2 -- add Net::HTTP wrapper to include support for ruby 1.9.3 - -# 0.3.1 -- remove requirement for channel, no longer required by slack [@dlackty] - -# 0.3.0 -- add custom hook endpoint parameter [@razielgn] - -# 0.2.0 -- remove HTTParty dependency - -# 0.1.1 -- loosen httparty dependency -- refactor codebase & add specs - -# 0.1.0 -- now formats html or markdown links in your message to match slack's format - -# 0.0.2 -- fix a fat finger if a default channel is set - -# 0.0.1 -- initial release diff -Nru ruby-slack-notifier-1.2.1/debian/changelog ruby-slack-notifier-1.5.1/debian/changelog --- ruby-slack-notifier-1.2.1/debian/changelog 2015-06-28 05:47:32.000000000 +0000 +++ ruby-slack-notifier-1.5.1/debian/changelog 2017-07-06 09:39:04.000000000 +0000 @@ -1,3 +1,12 @@ +ruby-slack-notifier (1.5.1-1) unstable; urgency=medium + + * Team upload. + * New upstream release + * Update debian/watch to download github.com tarballs + * Bump standards version to 4.0.0 (no changes) + + -- Pirate Praveen Thu, 06 Jul 2017 15:09:04 +0530 + ruby-slack-notifier (1.2.1-1) unstable; urgency=medium * Initial release (Closes: #785593) diff -Nru ruby-slack-notifier-1.2.1/debian/compat ruby-slack-notifier-1.5.1/debian/compat --- ruby-slack-notifier-1.2.1/debian/compat 2015-05-27 21:30:32.000000000 +0000 +++ ruby-slack-notifier-1.5.1/debian/compat 2017-07-06 09:39:04.000000000 +0000 @@ -1 +1 @@ -7 +9 diff -Nru ruby-slack-notifier-1.2.1/debian/control ruby-slack-notifier-1.5.1/debian/control --- ruby-slack-notifier-1.2.1/debian/control 2015-06-28 06:49:30.000000000 +0000 +++ ruby-slack-notifier-1.5.1/debian/control 2017-07-06 09:39:04.000000000 +0000 @@ -3,10 +3,13 @@ Priority: optional Maintainer: Debian Ruby Extras Maintainers Uploaders: Balasankar C -Build-Depends: debhelper (>= 7.0.50~), gem2deb, rake, ruby-rspec (>= 3.0.0) -Standards-Version: 3.9.6 -Vcs-Git: git://anonscm.debian.org/pkg-ruby-extras/ruby-slack-notifier.git -Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-ruby-extras/ruby-slack-notifier.git;a=summary +Build-Depends: debhelper (>= 9~), + gem2deb, + rake, + ruby-rspec (>= 3.0.0) +Standards-Version: 4.0.0 +Vcs-Git: https://anonscm.debian.org/git/pkg-ruby-extras/ruby-slack-notifier.git +Vcs-Browser: https://anonscm.debian.org/cgit/pkg-ruby-extras/ruby-slack-notifier.git Homepage: http://github.com/stevenosloan/slack-notifier Testsuite: autopkgtest-pkg-ruby XS-Ruby-Versions: all @@ -14,7 +17,9 @@ Package: ruby-slack-notifier Architecture: all XB-Ruby-Versions: ${ruby:Versions} -Depends: ruby | ruby-interpreter, ${misc:Depends}, ${shlibs:Depends} +Depends: ruby | ruby-interpreter, + ${misc:Depends}, + ${shlibs:Depends} Description: Ruby wrapper for posting to slack webhooks This gem provides a slim Ruby wrapper for posting to slack webhooks. Slack is a team communication tool that offers persistent chat rooms organized by topic, diff -Nru ruby-slack-notifier-1.2.1/debian/ruby-tests.rake ruby-slack-notifier-1.5.1/debian/ruby-tests.rake --- ruby-slack-notifier-1.2.1/debian/ruby-tests.rake 2015-05-27 21:30:32.000000000 +0000 +++ ruby-slack-notifier-1.5.1/debian/ruby-tests.rake 2017-07-06 09:39:04.000000000 +0000 @@ -1,7 +1,5 @@ -require 'rspec/core/rake_task' +require 'gem2deb/rake/spectask' -RSpec::Core::RakeTask.new(:spec) do |spec| +Gem2Deb::Rake::RSpecTask.new do |spec| spec.pattern = './spec/**/*_spec.rb' end - -task :default => :spec diff -Nru ruby-slack-notifier-1.2.1/debian/rules ruby-slack-notifier-1.5.1/debian/rules --- ruby-slack-notifier-1.2.1/debian/rules 2015-06-28 05:47:32.000000000 +0000 +++ ruby-slack-notifier-1.5.1/debian/rules 2017-07-06 09:39:04.000000000 +0000 @@ -1,8 +1,7 @@ #!/usr/bin/make -f %: dh $@ --buildsystem=ruby --with ruby + override_dh_install: dh_install rm -rf debian/ruby-slack-notifier/usr/bin -override_dh_installchangelogs: - dh_installchangelogs changelog.md diff -Nru ruby-slack-notifier-1.2.1/debian/watch ruby-slack-notifier-1.5.1/debian/watch --- ruby-slack-notifier-1.2.1/debian/watch 2015-05-27 21:30:32.000000000 +0000 +++ ruby-slack-notifier-1.5.1/debian/watch 2017-07-06 09:39:04.000000000 +0000 @@ -1,2 +1,5 @@ version=3 -http://pkg-ruby-extras.alioth.debian.org/cgi-bin/gemwatch/slack-notifier .*/slack-notifier-(.*).tar.gz +opts=\ +dversionmangle=s/\+(debian|dfsg|ds|deb)(\.\d+)?$//,\ +filenamemangle=s/.*\/v?([\d\.-]+)\.tar\.gz/slack-notifier-$1.tar.gz/ \ +http://github.com/stevenosloan/slack-notifier/tags .*/archive/v?([\d\.]+).tar.gz diff -Nru ruby-slack-notifier-1.2.1/docs/upgrade-from-0.6.1.md ruby-slack-notifier-1.5.1/docs/upgrade-from-0.6.1.md --- ruby-slack-notifier-1.2.1/docs/upgrade-from-0.6.1.md 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/docs/upgrade-from-0.6.1.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,26 +0,0 @@ -Recently slack changed the way incoming webhooks are handled. Instead of taking a team name and token, they now provide a unique (obfuscated) webhook url. - -To upgrade the slack-notifier gem, you'll need to find your webhook url. In slack: -- go to you're configured integrations (https://team-name.slack.com/services) -- select **Incoming Webhooks** -- select the webhook that uses the slack-notifier gem -- find the webhook url under the heading **Integration Settings** - -You'll then change the way you initialize your notifier - -From: -```ruby -notifier = Slack::Notifier.new 'team', 'token' -``` - -To: -```ruby -notifier = Slack::Notifier.new 'WEBHOOK_URL' -``` - -Defaults & attachemnts will continue to work like they have - -```ruby -notifier = Slack::Notifier.new 'WEBHOOK_URL', icon_emoji: ":ghost:" -notifier.ping "I'm feeling spooky" -``` diff -Nru ruby-slack-notifier-1.2.1/.editorconfig ruby-slack-notifier-1.5.1/.editorconfig --- ruby-slack-notifier-1.2.1/.editorconfig 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/.editorconfig 1970-01-01 00:00:00.000000000 +0000 @@ -1,10 +0,0 @@ -; EditorConfig is awesome: http://EditorConfig.org - -root = true ; top-most EditorConfig file - -; Unix-style newlines with a newline ending every file -[*] -end_of_line = lf -indent_style = space -indent_size = 2 -insert_final_newline = true diff -Nru ruby-slack-notifier-1.2.1/.env-example ruby-slack-notifier-1.5.1/.env-example --- ruby-slack-notifier-1.2.1/.env-example 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/.env-example 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -SLACK_WEBHOOK_URL: "https://example.com" \ No newline at end of file diff -Nru ruby-slack-notifier-1.2.1/Gemfile ruby-slack-notifier-1.5.1/Gemfile --- ruby-slack-notifier-1.2.1/Gemfile 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/Gemfile 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -source 'https://rubygems.org' - -gemspec - -group :development do - if RUBY_VERSION >= '2.0.0' - gem 'pry-byebug' - else - gem 'pry-debugger' - end - gem 'wwtd' - gem 'travis' -end - -group :test do - gem 'rake', '~> 10.1' - gem 'rspec', '~> 3.0.0' -end diff -Nru ruby-slack-notifier-1.2.1/.gitignore ruby-slack-notifier-1.5.1/.gitignore --- ruby-slack-notifier-1.2.1/.gitignore 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/.gitignore 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -.DS_Store -Gemfile.lock -.rvmrc -.ruby-version -.ruby-gemset -.env -*.gem -coverage \ No newline at end of file diff -Nru ruby-slack-notifier-1.2.1/lib/slack-notifier/link_formatter.rb ruby-slack-notifier-1.5.1/lib/slack-notifier/link_formatter.rb --- ruby-slack-notifier-1.2.1/lib/slack-notifier/link_formatter.rb 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/lib/slack-notifier/link_formatter.rb 2015-12-19 13:54:39.000000000 +0000 @@ -47,12 +47,14 @@ return out end + # http://rubular.com/r/19cNXW5qbH def html_pattern / (.+?) <\/a> /x end + # http://rubular.com/r/guJbTK6x1f def markdown_pattern - /\[(.*?)\]\((.+?)\)/ + /\[ ([^\[\]]*?) \] \( ((https?:\/\/.*?) | (mailto:.*?)) \) /x end end diff -Nru ruby-slack-notifier-1.2.1/lib/slack-notifier/version.rb ruby-slack-notifier-1.5.1/lib/slack-notifier/version.rb --- ruby-slack-notifier-1.2.1/lib/slack-notifier/version.rb 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/lib/slack-notifier/version.rb 2015-12-19 13:54:39.000000000 +0000 @@ -1,5 +1,5 @@ module Slack class Notifier - VERSION = "1.2.1" + VERSION = "1.5.1" end end diff -Nru ruby-slack-notifier-1.2.1/lib/slack-notifier.rb ruby-slack-notifier-1.5.1/lib/slack-notifier.rb --- ruby-slack-notifier-1.2.1/lib/slack-notifier.rb 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/lib/slack-notifier.rb 2015-12-19 13:54:39.000000000 +0000 @@ -15,11 +15,26 @@ end def ping message, options={} - message = LinkFormatter.format(message) - payload = default_payload.merge(options).merge(text: message) + if message.is_a?(Hash) + message, options = nil, message + end + + if attachments = options[:attachments] || options["attachments"] + wrap_array(attachments).each do |attachment| + ["text", :text].each do |key| + attachment[key] = LinkFormatter.format(attachment[key]) if attachment.has_key?(key) + end + end + end + + payload = default_payload.merge(options) client = payload.delete(:http_client) || http_client http_options = payload.delete(:http_options) + unless message.nil? + payload.merge!(text: LinkFormatter.format(message)) + end + params = { payload: payload.to_json } params[:http_options] = http_options if http_options @@ -46,5 +61,21 @@ default_payload[:username] = username end + HTML_ESCAPE_REGEXP = /[&><]/ + HTML_ESCAPE = { '&' => '&', '>' => '>', '<' => '<' } + + def escape(text) + text.gsub(HTML_ESCAPE_REGEXP, HTML_ESCAPE) + end + + def wrap_array(object) + if object.nil? + [] + elsif object.respond_to?(:to_ary) + object.to_ary || [object] + else + [object] + end + end end end diff -Nru ruby-slack-notifier-1.2.1/LICENSE ruby-slack-notifier-1.5.1/LICENSE --- ruby-slack-notifier-1.2.1/LICENSE 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/LICENSE 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Steven Sloan - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff -Nru ruby-slack-notifier-1.2.1/metadata.yml ruby-slack-notifier-1.5.1/metadata.yml --- ruby-slack-notifier-1.2.1/metadata.yml 1970-01-01 00:00:00.000000000 +0000 +++ ruby-slack-notifier-1.5.1/metadata.yml 2015-12-19 13:54:39.000000000 +0000 @@ -0,0 +1,58 @@ +--- !ruby/object:Gem::Specification +name: slack-notifier +version: !ruby/object:Gem::Version + version: 1.5.1 +platform: ruby +authors: +- Steven Sloan +autorequire: +bindir: bin +cert_chain: [] +date: 2015-12-01 00:00:00.000000000 Z +dependencies: [] +description: " A slim ruby wrapper for posting to slack webhooks " +email: +- stevenosloan@gmail.com +executables: [] +extensions: [] +extra_rdoc_files: [] +files: +- lib/slack-notifier.rb +- lib/slack-notifier/default_http_client.rb +- lib/slack-notifier/link_formatter.rb +- lib/slack-notifier/version.rb +- spec/integration/ping_integration_test.rb +- spec/lib/slack-notifier/default_http_client_spec.rb +- spec/lib/slack-notifier/link_formatter_spec.rb +- spec/lib/slack-notifier_spec.rb +- spec/spec_helper.rb +homepage: http://github.com/stevenosloan/slack-notifier +licenses: +- MIT +metadata: {} +post_install_message: +rdoc_options: [] +require_paths: +- lib +required_ruby_version: !ruby/object:Gem::Requirement + requirements: + - - ">=" + - !ruby/object:Gem::Version + version: '0' +required_rubygems_version: !ruby/object:Gem::Requirement + requirements: + - - ">=" + - !ruby/object:Gem::Version + version: '0' +requirements: [] +rubyforge_project: +rubygems_version: 2.4.5.1 +signing_key: +specification_version: 4 +summary: A slim ruby wrapper for posting to slack webhooks +test_files: +- spec/integration/ping_integration_test.rb +- spec/lib/slack-notifier/default_http_client_spec.rb +- spec/lib/slack-notifier/link_formatter_spec.rb +- spec/lib/slack-notifier_spec.rb +- spec/spec_helper.rb diff -Nru ruby-slack-notifier-1.2.1/Rakefile ruby-slack-notifier-1.5.1/Rakefile --- ruby-slack-notifier-1.2.1/Rakefile 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/Rakefile 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -require 'rspec/core/rake_task' - -RSpec::Core::RakeTask.new(:spec) - -task :default => :spec diff -Nru ruby-slack-notifier-1.2.1/readme.md ruby-slack-notifier-1.5.1/readme.md --- ruby-slack-notifier-1.2.1/readme.md 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/readme.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,183 +0,0 @@ -A simple wrapper to send notifications to [Slack](https://slack.com/) webhooks. - -[![Build Status](https://travis-ci.org/stevenosloan/slack-notifier.svg?branch=master)](https://travis-ci.org/stevenosloan/slack-notifier) [![Code Climate](https://codeclimate.com/github/stevenosloan/slack-notifier.svg)](https://codeclimate.com/github/stevenosloan/slack-notifier) - - -## Example - -```ruby -require 'slack-notifier' - -notifier = Slack::Notifier.new "WEBHOOK_URL" -notifier.ping "Hello World" -# => if your webhook is setup, will message "Hello World" -# => to the default channel you set in slack -``` - - -#### Setting Defaults - -On initialization you can set default payloads by passing an options hash. - -```ruby -notifier = Slack::Notifier.new "WEBHOOK_URL", channel: '#default', - username: 'notifier' - -notifier.ping "Hello default" -# => will message "Hello default" -# => to the "#default" channel as 'notifier' -``` - -Once a notifier has been initialized, you can update the default channel and/or user. - -```ruby -notifier.channel = '#default' -notifier.username = 'notifier' -notifier.ping "Hello default" -# => will message "Hello default" -# => to the "#default" channel as 'notifier' -``` - -These defaults are over-ridable for any individual ping. - -```ruby -notifier.channel = "#default" -notifier.ping "Hello random", channel: "#random" -# => will ping the "#random" channel -``` - - -## Links - -Slack requires links to be formatted a certain way, so slack-notifier will look through your message and attempt to convert any html or markdown links to slack's format before posting. - -Here's what it's doing under the covers: - -```ruby -message = "Hello world, [check](http://example.com) it out" -Slack::Notifier::LinkFormatter.format(message) -# => "Hello world, it " -``` - -## Formatting - -Slack supports various different formatting options. For example, if you want to alert an entire channel you include `` in your message - -```ruby -message = " hey check this out" -notifier.ping message - -#ends up posting "@channel hey check this out" in your Slack channel -``` - -You can see [Slacks message documentation here](https://api.slack.com/docs/formatting) - -## Additional parameters - -Any key passed to the `ping` method is posted to the webhook endpoint. Check out the [Slack webhook documentation](https://my.slack.com/services/new/incoming-webhook) for the available parameters. - -Setting an icon: - -```ruby -notifier.ping "feeling spooky", icon_emoji: ":ghost:" -# or -notifier.ping "feeling chimpy", icon_url: "http://static.mailchimp.com/web/favicon.png" -``` - -Adding attachments: - -```ruby -a_ok_note = { - fallback: "Everything looks peachy", - text: "Everything looks peachy", - color: "good" -} -notifier.ping "with an attachment", attachments: [a_ok_note] -``` - - -## HTTP options - -With the default HTTP client, you can send along options to customize it's behavior as `:http_options` params when you ping or initialize the notifier. - -```ruby -notifier = Slack::Notifier.new 'WEBHOOK_URL', http_options: { open_timeout: 5 } -notifier.ping "hello", http_options: { open_timeout: 10 } -``` - -**Note**: you should only send along options that [`Net::HTTP`](http://ruby-doc.org/stdlib-2.2.0/libdoc/net/http/rdoc/Net/HTTP.html) has as setters, otherwise the option will be ignored and show a warning. - - -## Custom HTTP Client - -There is a packaged default client wrapping Net::HTTP, but your HTTP needs might be a little different. In that case, you can pass in your own wrapper to handle sending the notifications. It just needs to respond to `::post` with the arguments of the endpoint URI, and the payload [pretty much the same as Net:HTTP.post_form](http://ruby-doc.org/stdlib-2.1.2/libdoc/net/http/rdoc/Net/HTTP.html#method-c-post_form). - -A simple example: -```ruby -module Client - def self.post uri, params={} - Net::HTTP.post_form uri, params - end -end - -notifier = Slack::Notifier.new 'WEBHOOK_URL', http_client: Client -``` - -It's also encouraged for any custom HTTP implementations to accept the `:http_options` key in params. - -**Setting client per ping** - -You can also set the http_client per-ping if you need to special case certain pings. - -```ruby -notifier.ping "hello", http_client: CustomClient -``` - -**Setting a No-Op client** - -In development (or testing), you may want to watch the behavior of the notifier without posting to slack. This can be handled with a no-op client. - -```ruby -class NoOpHTTPClient - def self.post uri, params={} - # bonus, you could log or observe posted params here - end -end - -notifier = Slack::Notifier.new 'WEBHOOK_URL', http_client: NoOpHTTPClient -``` - - -Testing -------- - -```bash -$ rspec -``` - -There is also an integration test setup to just double check pinging across the supported rubies. To run: - -1. Copy the `.env-example` file to `.env` and replace with your details. -2. Make sure `bin/test` is executable -3. then run and watch for the pings in your slack room - -```bash -$ bin/test -``` - - -Contributing ------------- - -If there is any thing you'd like to contribute or fix, please: - -- Fork the repo -- Add tests for any new functionality -- Make your changes -- Verify all new &existing tests pass -- Make a pull request - - -License -------- -The slack-notifier gem is distributed under the MIT License. diff -Nru ruby-slack-notifier-1.2.1/.rspec ruby-slack-notifier-1.5.1/.rspec --- ruby-slack-notifier-1.2.1/.rspec 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/.rspec 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ ---color --format 'documentation' \ No newline at end of file diff -Nru ruby-slack-notifier-1.2.1/slack-notifier.gemspec ruby-slack-notifier-1.5.1/slack-notifier.gemspec --- ruby-slack-notifier-1.2.1/slack-notifier.gemspec 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/slack-notifier.gemspec 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -require File.expand_path( "../lib/slack-notifier/version", __FILE__ ) - -Gem::Specification.new do |s| - - s.name = 'slack-notifier' - s.version = Slack::Notifier::VERSION - s.platform = Gem::Platform::RUBY - - s.summary = 'A slim ruby wrapper for posting to slack webhooks' - s.description = %q{ A slim ruby wrapper for posting to slack webhooks } - s.authors = ["Steven Sloan"] - s.email = ["stevenosloan@gmail.com"] - s.homepage = "http://github.com/stevenosloan/slack-notifier" - s.license = 'MIT' - - s.files = Dir["{lib}/**/*.rb"] - s.test_files = Dir["spec/**/*.rb"] - s.require_path = "lib" - -end \ No newline at end of file diff -Nru ruby-slack-notifier-1.2.1/spec/integration/ping_integration_test.rb ruby-slack-notifier-1.5.1/spec/integration/ping_integration_test.rb --- ruby-slack-notifier-1.2.1/spec/integration/ping_integration_test.rb 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/spec/integration/ping_integration_test.rb 2015-12-19 13:54:39.000000000 +0000 @@ -4,3 +4,4 @@ notifier = Slack::Notifier.new ENV['SLACK_WEBHOOK_URL'], username: 'notifier' puts "testing with ruby #{RUBY_VERSION}" notifier.ping "hello/こんにちは from notifier test script on ruby: #{RUBY_VERSION}\225" +notifier.ping attachments: [{color:"#1BF5AF",fallback:"fallback",text:"attachment"}] diff -Nru ruby-slack-notifier-1.2.1/spec/lib/slack-notifier/link_formatter_spec.rb ruby-slack-notifier-1.5.1/spec/lib/slack-notifier/link_formatter_spec.rb --- ruby-slack-notifier-1.2.1/spec/lib/slack-notifier/link_formatter_spec.rb 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/spec/lib/slack-notifier/link_formatter_spec.rb 2015-12-19 13:54:39.000000000 +0000 @@ -15,6 +15,11 @@ expect( formatted ).to include("") end + it "formats markdown links in brackets" do + formatted = described_class.format("Hello World, enjoy [[this](http://example.com) in brackets].") + expect( formatted ).to eq("Hello World, enjoy [ in brackets].") + end + it "formats markdown links with no title" do formatted = described_class.format("Hello World, enjoy [](http://example.com).") expect( formatted ).to include("") @@ -58,6 +63,16 @@ expect(formatted).to eq "こんにちは" end + it "handles mailto links in markdown" do + formatted = described_class.format("[John](mailto:john@example.com)") + expect(formatted).to eq "" + end + + it "handles mailto links in html" do + formatted = described_class.format("John") + expect(formatted).to eq "" + end + end end diff -Nru ruby-slack-notifier-1.2.1/spec/lib/slack-notifier_spec.rb ruby-slack-notifier-1.5.1/spec/lib/slack-notifier_spec.rb --- ruby-slack-notifier-1.2.1/spec/lib/slack-notifier_spec.rb 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/spec/lib/slack-notifier_spec.rb 2015-12-19 13:54:39.000000000 +0000 @@ -32,6 +32,49 @@ described_class.new('http://example.com').ping "the message", channel: 'foo' end + it "passes attachment messages through LinkFormatter" do + expect( Slack::Notifier::LinkFormatter ).to receive(:format) + .with("the message") + expect( Slack::Notifier::LinkFormatter ).to receive(:format) + .with("attachment message") + + described_class.new('http://example.com').ping "the message", channel: 'foo', + attachments: [{ + color: "#000", + text: "attachment message", + fallback: "fallback message" + }] + end + + it "allows sending only an attachment" do + expect( Slack::Notifier::DefaultHTTPClient ).to receive(:post).with( + URI.parse('http://example.com'), + payload: '{"channel":"foo","attachments":[{"text":"attachment","fallback":"fallback"}]}' + ) + + expect{ + described_class.new('http://example.com') + .ping channel: 'foo', + attachments: [{ + text: 'attachment', + fallback: 'fallback' + }] + }.not_to raise_error + end + + it "passes attachment messages through LinkFormatter, even if a single value is passed" do + expect( Slack::Notifier::LinkFormatter ).to receive(:format) + .with("a random message") + expect( Slack::Notifier::LinkFormatter ).to receive(:format) + .with("attachment message") + attachment = { + color: "#000", + text: "attachment message", + fallback: "fallback message" + } + subject.ping "a random message", attachments: attachment + end + context "with a default channel set" do before :each do @@ -109,4 +152,12 @@ expect( subject.username ).to eq "foo" end end + + describe "#escape" do + it "escapes sequences of < > &, but not quotes" do + message = %q(I've heard "Do > with <" & that sounds ridiculous.) + expected = %q(I've heard "Do > with <" & that sounds ridiculous.) + expect( subject.escape(message) ).to eq expected + end + end end diff -Nru ruby-slack-notifier-1.2.1/.travis.yml ruby-slack-notifier-1.5.1/.travis.yml --- ruby-slack-notifier-1.2.1/.travis.yml 2015-05-18 02:29:38.000000000 +0000 +++ ruby-slack-notifier-1.5.1/.travis.yml 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -language: ruby -sudo: false -cache: bundler -bundler_args: "--without development" -rvm: -- 2.2 -- 2.1 -- 2.0 -- 1.9.3 -- jruby-19mode -- rbx-2.2.7 -matrix: - allow_failures: - - rvm: jruby-19mode - - rvm: rbx-2.2.7 -notifications: - slack: - secure: Ld0tGBmwLG/ADOlLjO6ILq98+u/iq5qkuxAwN1E0SBOooALZZEJSc74jEMpgpnb22tk8QimUmLiCTE+8tWKaGiXTrvK6uvvfP6iiL9850NezHCxA3YMuWPnQQtJpTJ4135MMO8gJXu9vcswb9vW9N3v/A7VJdHbVZyT0vIMGas0=