mina_slack_notify 0.2.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00b1b97a9d9a7b029dc724713261572d007a7fd5
4
- data.tar.gz: d3d4439cc25704dad9955c3211c646acb30fa997
3
+ metadata.gz: 78173890dc6d8b14532256af0272e21c1de5e419
4
+ data.tar.gz: d7d82275c654840b7dd00f784edfe21f97897de9
5
5
  SHA512:
6
- metadata.gz: 12e496d57b679bbf5955f3a89be2c0719ac9be624b1e58c0e5f34a15b7dade389f3b253381284bbde4b2c9e037ab5be6aff8f312e7afd902f2083d3c327833ef
7
- data.tar.gz: 9fd0b87f9af17447462bf06c8a9709c4d26d4f824c09f81883d27927fef79e9b982b8e98ee769ea5a54fbe3a623ed2e1a10c24d08130403407ec6c015c50706c
6
+ metadata.gz: d8b740c571e72dc1bbb584cd5877f3f224843808d350eee11821c2adbb984d1434963220c15388bcf7c4db98d5f57043ddc2e1ed2254429c2d4589aba374e7dc
7
+ data.tar.gz: 45f71698a690fa465f67787d3817c090bd21bcf9b95d06e0887ec4e8fd3fc1b1d3097e1b92b605e7d9ed5b8400247832545de5011305a4ec7a41af9853c2102a
@@ -1,4 +1,5 @@
1
1
  require "mina_slack_notify/version"
2
+ require "mina_slack_notify/tasks"
2
3
  require "mina_slack_notify/hooks/plugin"
3
4
 
4
5
  if defined?(Mina) && self.respond_to?(:mina_cleanup!)
@@ -6,5 +7,4 @@ if defined?(Mina) && self.respond_to?(:mina_cleanup!)
6
7
  end
7
8
 
8
9
  module MinaSlackNotify
9
- # Your code goes here...
10
10
  end
@@ -1,52 +1,56 @@
1
+ require "mina/bundler"
2
+ require "mina/rails"
1
3
  require 'json'
2
4
  require 'httparty'
3
5
 
4
- # ## Settings
5
- # Any and all of these settings can be overriden in your `deploy.rb`.
6
+ # Control Tasks
7
+ namespace :slack do
8
+ # ## Settings
9
+ # Any and all of these settings can be overriden in your `deploy.rb`.
6
10
 
7
- # ### slack_api_token
8
- # Sets the slack api auth token.
9
- set_default :slack_api_token, ''
10
- set_default :slack_team_domain, ''
11
+ # ### slack_api_token
12
+ # Sets the slack api auth token.
13
+ set :slack_api_token, ''
14
+ set :slack_team_domain, ''
11
15
 
12
- # ### slack_channels
13
- # Sets the channels where notifications will be sent to.
14
- set_default :slack_channels, []
16
+ # ### slack_channels
17
+ # Sets the channels where notifications will be sent to.
18
+ set :slack_channels, []
15
19
 
16
- # ### slack_username
17
- # Sets the notification 'from' user label
18
- set_default :slack_username, 'Mina'
20
+ # ### slack_username
21
+ # Sets the notification 'from' user label
22
+ set :slack_username, 'Mina'
19
23
 
20
- # slack_author
21
- # Sets the deployment author name
22
- set_default :slack_author, 'Mina'
24
+ # slack_author
25
+ # Sets the deployment author name
26
+ set :slack_author, 'Mina'
23
27
 
24
- # ### slack_link_names
25
- # Sets the deployment author name
26
- set_default :slack_link_names, 1
28
+ # ### slack_link_names
29
+ # Sets the deployment author name
30
+ set :slack_link_names, 1
27
31
 
28
- # slack_parse
29
- # Sets the deployment author name
30
- set_default :slack_parse, 'full'
32
+ # slack_parse
33
+ # Sets the deployment author name
34
+ set :slack_parse, 'full'
31
35
 
32
- # icon_url
33
- # URL to an image to use as the icon for this message
34
- set_default :slack_icon_url, ''
36
+ # icon_url
37
+ # URL to an image to use as the icon for this message
38
+ set :slack_icon_url, ''
35
39
 
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:'
40
+ # icon_emoji
41
+ # Sets emoji to use as the icon for this message. Overrides `slack_icon_url`
42
+ set :slack_icon_emoji, ':slack:'
39
43
 
40
- # Control Tasks
41
- namespace :slack do
42
44
 
43
45
  # slack:notify_deploy_started
44
46
  desc "Send slack notification about new deploy start"
45
47
  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
+ # queue %[echo "-----> Sending start notification to Slack"]
49
+ comment %{Sending start notification to Slack}
50
+ text = "[Deploying] #{fetch(:slack_author)} is deploying #{fetch(:application)} on #{fetch(:domain)}...\n"
48
51
 
49
- for channel in slack_channels
52
+ slack_channels = fetch(:slack_channels)
53
+ for channel in fetch(:slack_channels)
50
54
  send_message(
51
55
  channel: channel,
52
56
  text: text
@@ -57,10 +61,13 @@ namespace :slack do
57
61
  # slack:notify_deploy_finished
58
62
  desc "Send slack notification about deploy finish"
59
63
  task :notify_deploy_finished => :environment do
60
- queue %[echo "-----> Sending finish notification to Slack"]
64
+ # queue %[echo "-----> Sending finish notification to Slack"]
65
+ comment %{Sending finish notification to Slack}
61
66
 
62
- text = "#{slack_author} finished deploying #{application}."
63
- text += " on server #{domain} \n" if domain != nil
67
+ text = "#{fetch(:slack_author)} finished deploying #{fetch(:application)}."
68
+ text += " on server #{fetch(:domain)} \n" if fetch(:domain) != nil
69
+ attachments = fetch(:attachments)
70
+ slack_channels = fetch(:slack_channels)
64
71
 
65
72
  for channel in slack_channels
66
73
  send_message(
@@ -74,18 +81,23 @@ namespace :slack do
74
81
  # slack:notify_deploy_finished
75
82
  desc "Send slack notification about deploying"
76
83
  task :notify_deploying => :environment do
77
- queue %[echo "-----> Sending finish notification to Slack"]
84
+ # queue %[echo "-----> Sending finish notification to Slack"]
85
+ comment %{Sending finish notification to Slack}
78
86
 
79
87
  # text = "[auto deployment] *#{slack_author}* finished deploying *#{application}*."
80
88
  # text += " on server #{domain} \n" if domain != nil
81
- # git_logs = %x[git log --stat]
89
+ git_logs = %x[git log --stat]
82
90
 
83
91
  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"
92
+ text = "*#{fetch(:slack_author).delete!("\n")}* deployed #{fetch(:application)} in #{fetch(:server_name)} (#{fetch(:domain)}) \n"
85
93
  git_logs.each_line do |line|
86
94
  text += "> #{line}"
87
95
  end
88
96
 
97
+ attachments = fetch(:attachments)
98
+
99
+ slack_channels = fetch(:slack_channels)
100
+ puts "\nslack_channels: #{slack_channels} \n"
89
101
  for channel in slack_channels
90
102
  send_message(
91
103
  channel: channel,
@@ -96,7 +108,7 @@ namespace :slack do
96
108
  end
97
109
 
98
110
  def send_message(params = {})
99
- slack_url = "https://#{slack_team_domain}.slack.com/services/hooks/slackbot?token=#{slack_api_token}&channel=%23#{params[:channel]}"
111
+ slack_url = "https://#{fetch(:slack_team_domain)}.slack.com/services/hooks/slackbot?token=#{fetch(:slack_api_token)}&channel=%23#{params[:channel]}"
100
112
  HTTParty.post(slack_url, {body: params[:text]})
101
113
  end
102
114
 
@@ -1,3 +1,3 @@
1
1
  module MinaSlackNotify
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "mina_slack_notify"
8
8
  spec.version = MinaSlackNotify::VERSION
9
9
  spec.authors = ["Tam Nguyen"]
10
- spec.email = ["nguyentamvinhlong@gmail.com"]
10
+ spec.email = ["ntamvl@gmail.com"]
11
11
 
12
12
  spec.summary = "Adds tasks to aid in the Slack notifications"
13
13
  spec.description = "Mina bindings for Slack"
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
18
  # delete this section to allow pushing this gem to any host.
19
19
  if spec.respond_to?(:metadata)
20
- # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://feels.com'"
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
21
  else
22
22
  raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
23
  end
@@ -27,11 +27,11 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_dependency "mina", "~> 0.3.8"
30
+ spec.add_dependency "mina", "~> 1.0"
31
31
 
32
32
  spec.add_development_dependency "bundler", "~> 1.12"
33
33
  spec.add_development_dependency "rake", "~> 11.2"
34
- spec.add_development_dependency "httparty"
34
+ spec.add_development_dependency "httparty", "~> 0"
35
35
  spec.add_development_dependency "rubygems-tasks", "~> 0.2"
36
36
  spec.add_development_dependency "yard", "~> 0.8"
37
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mina_slack_notify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tam Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-13 00:00:00.000000000 Z
11
+ date: 2016-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mina
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.8
19
+ version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.3.8
26
+ version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -56,14 +56,14 @@ dependencies:
56
56
  name: httparty
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
@@ -96,7 +96,7 @@ dependencies:
96
96
  version: '0.8'
97
97
  description: Mina bindings for Slack
98
98
  email:
99
- - nguyentamvinhlong@gmail.com
99
+ - ntamvl@gmail.com
100
100
  executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
@@ -104,7 +104,6 @@ files:
104
104
  - ".gitignore"
105
105
  - CODE_OF_CONDUCT.md
106
106
  - Gemfile
107
- - Gemfile.lock
108
107
  - LICENSE
109
108
  - LICENSE.txt
110
109
  - README.md
@@ -119,7 +118,8 @@ files:
119
118
  homepage: https://github.com/ntamvl/mina_slack_notify
120
119
  licenses:
121
120
  - MIT
122
- metadata: {}
121
+ metadata:
122
+ allowed_push_host: https://rubygems.org
123
123
  post_install_message:
124
124
  rdoc_options: []
125
125
  require_paths:
@@ -141,4 +141,3 @@ signing_key:
141
141
  specification_version: 4
142
142
  summary: Adds tasks to aid in the Slack notifications
143
143
  test_files: []
144
- has_rdoc:
@@ -1,37 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- mina_slack_notify (0.2.2)
5
- mina (~> 0.3.8)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- httparty (0.13.7)
11
- json (~> 1.8)
12
- multi_xml (>= 0.5.2)
13
- json (1.8.3)
14
- kramdown (1.9.0)
15
- mina (0.3.8)
16
- open4 (~> 1.3.4)
17
- rake
18
- multi_xml (0.5.5)
19
- open4 (1.3.4)
20
- rake (11.2.2)
21
- rubygems-tasks (0.2.4)
22
- yard (0.8.7.6)
23
-
24
- PLATFORMS
25
- ruby
26
-
27
- DEPENDENCIES
28
- bundler (~> 1.12)
29
- httparty
30
- kramdown
31
- mina_slack_notify!
32
- rake (~> 11.2)
33
- rubygems-tasks (~> 0.2)
34
- yard (~> 0.8)
35
-
36
- BUNDLED WITH
37
- 1.12.5