mina_slack_notify 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9da4af26e463afd7dd12fb075b9e41c506730857
4
+ data.tar.gz: 940f99745412a35279edc254066f545a8a3b5dea
5
+ SHA512:
6
+ metadata.gz: 594ecf9ac53cb79dc8319612c19985d27b55f049ccc9f0cd96aefb032181bce66c42cbb1f2688ae074413a76cb489aa7b1dc82d0dcb44a1168d366fabe82f88e
7
+ data.tar.gz: 1a89726770e3d88eebc5e768617c14cc7623c2e22ea1bf120417f444c60dc7eb300a5d45525150187a9408a07a650c452916b55ae347609f3588646fbf12fa2b
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ # Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mina_slack_notify.gemspec
4
+ gemspec
5
+
6
+ gem 'httparty'
data/Gemfile.lock ADDED
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mina_slack_notify (0.1.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ httparty (0.13.7)
10
+ json (~> 1.8)
11
+ multi_xml (>= 0.5.2)
12
+ json (1.8.3)
13
+ multi_xml (0.5.5)
14
+ rake (10.4.2)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ bundler (~> 1.10)
21
+ httparty
22
+ mina_slack_notify!
23
+ rake (~> 10.0)
24
+
25
+ BUNDLED WITH
26
+ 1.10.6
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Tam Nguyen
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.
22
+
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Tam Nguyen
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,95 @@
1
+ # MinaSlackNotify
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/mina_slack_notify`. 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 'mina_slack_notify'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install mina_slack_notify
22
+
23
+ ## Usage example
24
+
25
+ require 'mina_slack_notify/tasks'
26
+ ...
27
+ # Required mina_slack_notify options
28
+ ...
29
+ set :application, "app_name"
30
+ ...
31
+
32
+ ...
33
+ # example: mina deploy env=developmet
34
+ if !ENV['env'].nil? && ENV['env'] == "production"
35
+ set :domain, '[ip_or_domain_production]'
36
+ set :server_name, "production"
37
+ puts "You are running on producion"
38
+ else
39
+ set :domain, '[ip_or_domain_development]'
40
+ set :server_name, "development"
41
+ puts "You are running on developmet"
42
+ end
43
+ ...
44
+ set :slack_api_token, 'xxxyyyzzz'
45
+ set :slack_channels, ['#general', '@mbajur', '#nerd']
46
+ set :slack_team_domain, 'team_domain'
47
+ set :slack_author, %x[git config user.email]
48
+
49
+ task :deploy do
50
+ deploy do
51
+ invoke :'slack:notify_deploy_started'
52
+ ...
53
+
54
+ to :launch do
55
+ ...
56
+ invoke :'slack:notify_deploy_finished'
57
+ end
58
+ end
59
+ end
60
+
61
+ ## Available Tasks
62
+
63
+ * `slack:notify_deploy_started`
64
+ * `slack:notify_deploy_finished`
65
+
66
+ ## Available Options
67
+
68
+ | Option | Description |
69
+ | ------------------------- | ------------------------------------------------------------------------------------ |
70
+ | __slack_api_token__ | API auth token. |
71
+ | __slack_channels__ | Array of channels (or users) where notifications will be sent to. |
72
+ | slack_username | Name of bot. <br> _default: Deploy_ |
73
+ | slack_author | Author of a deploy displayed in deploy messages. <br> _default: Someone_ |
74
+ | slack_link_names | Find and link channel names and usernames. <br> _default: 1_ |
75
+ | slack_parse | Change how messages are treated. [Read more] (https://api.slack.com/docs/formatting) <br> _default: full_ |
76
+ | slack_icon_url | URL to an image to use as the icon for this message <br> _default: nil_ |
77
+ | slack_icon_emoji | emoji to use as the icon for this message. Overrides `slack_icon_url`. <br> _default: :slack:_ |
78
+
79
+ __* required options__
80
+
81
+ ## Development
82
+
83
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
84
+
85
+ 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).
86
+
87
+ ## Contributing
88
+
89
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ntamvl/mina_slack_notify. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
90
+
91
+
92
+ ## License
93
+
94
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
95
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mina_slack_notify"
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,103 @@
1
+ require 'json'
2
+ require 'httparty'
3
+
4
+ # ## Settings
5
+ # Any and all of these settings can be overriden in your `deploy.rb`.
6
+
7
+ # ### slack_api_token
8
+ # Sets the slack api auth token.
9
+ set_default :slack_api_token, ''
10
+ set_default :slack_team_domain, ''
11
+
12
+ # ### slack_channels
13
+ # Sets the channels where notifications will be sent to.
14
+ set_default :slack_channels, []
15
+
16
+ # ### slack_username
17
+ # Sets the notification 'from' user label
18
+ set_default :slack_username, 'Mina'
19
+
20
+ # slack_author
21
+ # Sets the deployment author name
22
+ set_default :slack_author, 'Mina'
23
+
24
+ # ### slack_link_names
25
+ # Sets the deployment author name
26
+ set_default :slack_link_names, 1
27
+
28
+ # slack_parse
29
+ # Sets the deployment author name
30
+ set_default :slack_parse, 'full'
31
+
32
+ # icon_url
33
+ # URL to an image to use as the icon for this message
34
+ set_default :slack_icon_url, ''
35
+
36
+ # icon_emoji
37
+ # Sets emoji to use as the icon for this message. Overrides `slack_icon_url`
38
+ set_default :slack_icon_emoji, ':slack:'
39
+
40
+ # Control Tasks
41
+ namespace :slack do
42
+
43
+ # slack:notify_deploy_started
44
+ desc "Send slack notification about new deploy start"
45
+ task :notify_deploy_started => :environment do
46
+ queue %[echo "-----> Sending start notification to Slack"]
47
+ text = "[Deploying] #{slack_author} is deploying #{application} on #{domain}...\n"
48
+
49
+ for channel in slack_channels
50
+ send_message(
51
+ channel: channel,
52
+ text: text
53
+ )
54
+ end
55
+ end
56
+
57
+ # slack:notify_deploy_finished
58
+ desc "Send slack notification about deploy finish"
59
+ task :notify_deploy_finished => :environment do
60
+ queue %[echo "-----> Sending finish notification to Slack"]
61
+
62
+ text = "#{slack_author} finished deploying #{application}."
63
+ text += " on server #{domain} \n" if domain != nil
64
+
65
+ for channel in slack_channels
66
+ send_message(
67
+ channel: channel,
68
+ text: text,
69
+ attachments: attachments
70
+ )
71
+ end
72
+ end
73
+
74
+ # slack:notify_deploy_finished
75
+ desc "Send slack notification about deploying"
76
+ task :notify_deploying => :environment do
77
+ queue %[echo "-----> Sending finish notification to Slack"]
78
+
79
+ # text = "[auto deployment] *#{slack_author}* finished deploying *#{application}*."
80
+ # text += " on server #{domain} \n" if domain != nil
81
+ # git_logs = %x[git log --stat]
82
+
83
+ git_logs = %x[git log --pretty=format:"%an (%h) %s" -n 5]
84
+ text = "*#{slack_author.delete!("\n")}* deployed #{application} in #{server_name} (#{domain}) \n"
85
+ git_logs.each_line do |line|
86
+ text += "> #{line}"
87
+ end
88
+
89
+ for channel in slack_channels
90
+ send_message(
91
+ channel: channel,
92
+ text: text,
93
+ attachments: attachments
94
+ )
95
+ end
96
+ end
97
+
98
+ def send_message(params = {})
99
+ slack_url = "https://#{slack_team_domain}.slack.com/services/hooks/slackbot?token=#{slack_api_token}&channel=%23#{params[:channel]}"
100
+ HTTParty.post(slack_url, {body: params[:text]})
101
+ end
102
+
103
+ end
@@ -0,0 +1,3 @@
1
+ module MinaSlackNotify
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "mina_slack_notify/version"
2
+
3
+ module MinaSlackNotify
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mina_slack_notify/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mina_slack_notify"
8
+ spec.version = MinaSlackNotify::VERSION
9
+ spec.authors = ["Tam Nguyen"]
10
+ spec.email = ["nguyentamvinhlong@gmail.com"]
11
+
12
+ spec.summary = "Adds tasks to aid in the Slack notifications"
13
+ spec.description = "Mina bindings for Slack"
14
+ spec.homepage = "https://github.com/ntamvl/mina_slack_notify"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://feels.com'"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.10"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "httparty"
33
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mina_slack_notify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Tam Nguyen
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-12-24 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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
+ - !ruby/object:Gem::Dependency
42
+ name: httparty
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Mina bindings for Slack
56
+ email:
57
+ - nguyentamvinhlong@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - CODE_OF_CONDUCT.md
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - LICENSE
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - lib/mina_slack_notify.rb
73
+ - lib/mina_slack_notify/tasks.rb
74
+ - lib/mina_slack_notify/version.rb
75
+ - mina_slack_notify.gemspec
76
+ homepage: https://github.com/ntamvl/mina_slack_notify
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.4.8
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Adds tasks to aid in the Slack notifications
100
+ test_files: []