slack_ci 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -2
- data/bin/slackci +72 -0
- data/lib/slack_ci/version.rb +1 -1
- data/slack_ci.gemspec +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27e94037f973c57e36e08b95e31c9681f5ae500a
|
4
|
+
data.tar.gz: 39982d33138d29cc8e545ba58c3b6eaefb9ad009
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abbcf36dedd1dc5730d83984d9ece2eb8ed647804d3b5a9de5b7786047648cc34bc0b0a173d33a2e0974a6316bb39307895be688d5d7af43b0fefe491bfff035
|
7
|
+
data.tar.gz: 383a74e264f9ac5c18f6487297c7b9207bd8592bd1cc874752a55e2ccd18410375bbe8ff3fdc6f259c0730842d340809659be046e9ab2c7187dcdfc258a5bb0c
|
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# SlackCI
|
2
|
-
===========
|
3
2
|
|
4
|
-
[![Gem Version](https://badge.fury.io/rb/
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/slack_ci.svg)](http://badge.fury.io/rb/slack_ci)
|
5
4
|
[![Dependency Status](https://gemnasium.com/grubernaut/SlackCI.svg)](https://gemnasium.com/grubernaut/SlackCI)
|
6
5
|
[![Build Status](https://travis-ci.org/grubernaut/SlackCI.svg?branch=master)](https://travis-ci.org/grubernaut/SlackCI)
|
7
6
|
|
@@ -70,3 +69,35 @@ end
|
|
70
69
|
To Create a webhook token for your team, start [here](https://slackci.slack.com/services/new/incoming-webhook), and select any channel for the webhook.
|
71
70
|
Then use the generated token from Slack as your access token. You will be able to post to different channels in slack with the same token, if you specify ```channel``` inside the message hash.
|
72
71
|
|
72
|
+
## CLI Usage
|
73
|
+
|
74
|
+
Install the Gem:
|
75
|
+
```
|
76
|
+
gem install slack_ci
|
77
|
+
```
|
78
|
+
|
79
|
+
Follow the instructions above to create a webhook token for your team.
|
80
|
+
|
81
|
+
Create a config file inside of your home directory:
|
82
|
+
```
|
83
|
+
touch ~/.slackci.yml
|
84
|
+
```
|
85
|
+
And add the following contents into the YAML configuration file. The only required information in the file is your team name, and your token. Every other parameter is optional.
|
86
|
+
**NOTE:** If you use ```icon_emoji``` _and_ ```icon_url``` SlackCI will use the emoji configuration first, as there can only be one of either.
|
87
|
+
```
|
88
|
+
---
|
89
|
+
team: '<team_name>'
|
90
|
+
token: '<webhook-token>'
|
91
|
+
icon_url: '<icon_url>'
|
92
|
+
icon_emoji: '<icon_emoji>'
|
93
|
+
username: '<username>'
|
94
|
+
```
|
95
|
+
|
96
|
+
Once you have the configuration file written correctly, simply run the SlackCI binary from the terminal.
|
97
|
+
```
|
98
|
+
slackci #channel this is one interesting message
|
99
|
+
```
|
100
|
+
|
101
|
+
**NOTE:** Messages do not have to be quote delimited. Anything after the channel name will be added to the message. Including any "<hyperlinks>" and ":emoji:" that you wish to send to slack.
|
102
|
+
|
103
|
+
|
data/bin/slackci
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'slack_ci'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
# If Incorrect number of arguments is used, exit hard
|
7
|
+
if ARGV.length < 2
|
8
|
+
puts 'CRITICAL: Wrong number of arguments'
|
9
|
+
puts 'Usage: slackci [CHANNEL] [MESSAGE]'
|
10
|
+
exit 3
|
11
|
+
end
|
12
|
+
|
13
|
+
# Assign Message Variables to arguments
|
14
|
+
# Argument Assignment. Shift takes first Argument and "pops" it.
|
15
|
+
channel = ARGV.shift
|
16
|
+
# Joins remaining arguments allowing string to be passed without
|
17
|
+
# encapsulating string in quotes inside of terminal
|
18
|
+
text = ARGV.join(' ')
|
19
|
+
|
20
|
+
# Checks if channel has an octothorpe in front of it.
|
21
|
+
# If it does not, throw a warning and fix it for the user.
|
22
|
+
# -- We fight for the users around here... --
|
23
|
+
unless channel[0, 1] == '#'
|
24
|
+
puts 'WARN: Please specify a channel name with \'#\' in front of the channel'
|
25
|
+
channel = "\##{channel}"
|
26
|
+
end
|
27
|
+
|
28
|
+
# Default Config when no config file present
|
29
|
+
@config = {
|
30
|
+
'team' => 'slackCI',
|
31
|
+
'token' => 'D7eRlWzfbmZuqL2CqtXHS4ZA'
|
32
|
+
}
|
33
|
+
|
34
|
+
# Read in config from file
|
35
|
+
begin
|
36
|
+
config = YAML.load_file(ENV['HOME'] + '/.slackci.yml')
|
37
|
+
rescue Errno::ENOENT
|
38
|
+
puts 'WARN: YAML config could not be found. Using defaults.'
|
39
|
+
rescue Psych::SyntaxError
|
40
|
+
puts 'CRITICAL: YAML config file contains invalid syntax.'
|
41
|
+
exit 1
|
42
|
+
end
|
43
|
+
|
44
|
+
if config.inspect != 'nil'
|
45
|
+
# Check for Required Config Values
|
46
|
+
if !config['team'] || !config['token']
|
47
|
+
puts 'CRITICAL: YAML config incorrectly written.'
|
48
|
+
exit 2
|
49
|
+
else
|
50
|
+
# Config File is correct for required parameters
|
51
|
+
@config.merge!(config)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
slack = SlackCi.new(@config['team'], @config['token'])
|
56
|
+
|
57
|
+
message = {
|
58
|
+
'text' => "#{text}",
|
59
|
+
'channel' => "#{channel}"
|
60
|
+
}
|
61
|
+
|
62
|
+
# Add optional config parameters
|
63
|
+
message.store('icon_emoji', @config['icon_emoji']) if @config['icon_emoji']
|
64
|
+
message.store('icon_url', @config['icon_url']) if @config['icon_url']
|
65
|
+
message.store('username', @config['username']) if @config['username']
|
66
|
+
|
67
|
+
# TODO: Check for status code on say method call
|
68
|
+
res = slack.say(message)
|
69
|
+
unless res == '200'
|
70
|
+
puts "CRITICAL: Error reaching Slack services. HTTP CODE:#{res}"
|
71
|
+
exit 4
|
72
|
+
end
|
data/lib/slack_ci/version.rb
CHANGED
data/slack_ci.gemspec
CHANGED
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
29
29
|
spec.add_development_dependency 'rake', '~> 10.3.2', '>=10.3.2'
|
30
|
-
spec.add_development_dependency 'rubocop', '~>0.
|
30
|
+
spec.add_development_dependency 'rubocop', '~>0.24.1', '>= 0.23.0'
|
31
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack_ci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Champlin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -84,7 +84,7 @@ dependencies:
|
|
84
84
|
requirements:
|
85
85
|
- - "~>"
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: 0.
|
87
|
+
version: 0.24.1
|
88
88
|
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: 0.23.0
|
@@ -94,14 +94,15 @@ dependencies:
|
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: 0.
|
97
|
+
version: 0.24.1
|
98
98
|
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: 0.23.0
|
101
101
|
description: Post Slack Messages to a channel from the terminal!
|
102
102
|
email:
|
103
103
|
- jake.champlin.27@gmail.com
|
104
|
-
executables:
|
104
|
+
executables:
|
105
|
+
- slackci
|
105
106
|
extensions: []
|
106
107
|
extra_rdoc_files: []
|
107
108
|
files:
|
@@ -113,6 +114,7 @@ files:
|
|
113
114
|
- LICENSE.txt
|
114
115
|
- README.md
|
115
116
|
- Rakefile
|
117
|
+
- bin/slackci
|
116
118
|
- lib/slack_ci.rb
|
117
119
|
- lib/slack_ci/slack_ci_api.rb
|
118
120
|
- lib/slack_ci/version.rb
|