slack_ci 0.0.3
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 +7 -0
- data/.gitignore +22 -0
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +6 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +72 -0
- data/Rakefile +19 -0
- data/lib/slack_ci/slack_ci_api.rb +23 -0
- data/lib/slack_ci/version.rb +4 -0
- data/lib/slack_ci.rb +12 -0
- data/slack_ci.gemspec +31 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/unit/slack_ci_spec.rb +12 -0
- metadata +148 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 79d4901e630b1d7c266683697e9ed7b3dc111690
|
4
|
+
data.tar.gz: 1f8032353dfcda0c71c8e1cfb2042432ca5e22f6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8464efc1fdf345ae9a9284f5d53c47f8c60d806dfb9106f26dff0a542ad3b7641a80b255b8b1c0cdbc62c82dec8085eba149513cdcae36de03ecff8748dd7c96
|
7
|
+
data.tar.gz: b44e7f88cacd56a1f0ab9acc2fb8ac60ef1bbbcf4e669cb42e7c113d659c2b75a304f08a9a1bd5f46690c40effa4fec4b1c7e92c534599773b547e6dde9db129
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2014-07-07 16:32:32 -0400 using RuboCop version 0.23.0.
|
3
|
+
# The point is for the user to remove these configuration records
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Jake Champlin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# SlackCI
|
2
|
+
===========
|
3
|
+
|
4
|
+
[](http://badge.fury.io/rb/slack-ci)
|
5
|
+
[](https://gemnasium.com/grubernaut/SlackCI)
|
6
|
+
[](https://travis-ci.org/grubernaut/SlackCI)
|
7
|
+
|
8
|
+
Slack Gem for Ruby. Includes Binary executable for instantly posting messages to slack via
|
9
|
+
the command line.
|
10
|
+
|
11
|
+
Aims as a learning project. Patience required
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
gem 'slack_ci'
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install slack_ci
|
26
|
+
|
27
|
+
## TODO
|
28
|
+
|
29
|
+
* Create Local Configuration File
|
30
|
+
* Create Binary from API
|
31
|
+
* Implement further tests
|
32
|
+
* Add YardDoc
|
33
|
+
* ...
|
34
|
+
|
35
|
+
## Running Tests / Contributing
|
36
|
+
|
37
|
+
I have created a new slack team and a new web integration just for rspec purposes of testing this gem. Please use team: ```slackCI``` and the integration token ```D7eRlWzfbmZuqL2CqtXHS4ZA``` when writing more rspec tests, or use your own team + token just ensure that the correct team + token values are set back to defaults before creating a PR. This ensures that any contributers do not have to have a Slack account to contribute and test the gem.
|
38
|
+
|
39
|
+
### Steps to contribute:
|
40
|
+
|
41
|
+
1. Fork it ( https://github.com/grubernaut/slack_ci/fork )
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
4. Ensure all tests pass (`rake test`)
|
45
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
46
|
+
6. Create a new Pull Request
|
47
|
+
|
48
|
+
## Usage
|
49
|
+
|
50
|
+
Require the Gem:
|
51
|
+
```
|
52
|
+
require 'slack_ci'
|
53
|
+
```
|
54
|
+
|
55
|
+
Initialize a Slack object with your team name and Webhook Token:
|
56
|
+
```
|
57
|
+
slack = SlackCi.new('team','token')
|
58
|
+
```
|
59
|
+
Post Messages to Slack by passing a Hash to SlackCi's ```say``` method:
|
60
|
+
```
|
61
|
+
message = {
|
62
|
+
'text' => 'This is one awesome message',
|
63
|
+
'channel' => '#general'
|
64
|
+
}
|
65
|
+
unless slack.say(message) == '200'
|
66
|
+
abort("Message failed to post")
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
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
|
+
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
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
|
5
|
+
# RSpec Test Task
|
6
|
+
RSpec::Core::RakeTask.new(:unit) do |t|
|
7
|
+
t.rspec_opts = [].tap do |a|
|
8
|
+
a.push('--color')
|
9
|
+
a.push('--format progress')
|
10
|
+
end.join(' ')
|
11
|
+
end
|
12
|
+
|
13
|
+
# RuboCop Test Task
|
14
|
+
RuboCop::RakeTask.new(:rubocop)
|
15
|
+
|
16
|
+
desc 'Run All Tests'
|
17
|
+
task 'test' => [:unit, :rubocop]
|
18
|
+
|
19
|
+
task 'default' => [:test]
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module SlackCi
|
5
|
+
# SlackAPI Class
|
6
|
+
class SlackCiApi
|
7
|
+
# Initialize the URI for the team and Integration Token.
|
8
|
+
def initialize(team, token)
|
9
|
+
@uri = URI.parse("https://#{team}.slack.com/services/hooks/incoming-webhook?token=#{token}")
|
10
|
+
@header = { 'Content-Type' => 'text/json' }
|
11
|
+
end
|
12
|
+
|
13
|
+
# Say Method to create an HTTP Post request with a JSON string as
|
14
|
+
# the post request body.
|
15
|
+
def say(message)
|
16
|
+
http = Net::HTTP.new(@uri.host, @uri.port)
|
17
|
+
http.use_ssl = true
|
18
|
+
req = Net::HTTP::Post.new(@uri.request_uri, @header)
|
19
|
+
req.body = message.to_json
|
20
|
+
http.request(req).code
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/slack_ci.rb
ADDED
data/slack_ci.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'slack_ci/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'slack_ci'
|
8
|
+
spec.version = SlackCi::VERSION
|
9
|
+
spec.authors = ['Jake Champlin']
|
10
|
+
spec.email = ['jake.champlin.27@gmail.com']
|
11
|
+
spec.summary = 'Use Slack from the terminal!'
|
12
|
+
spec.description = 'Post Slack Messages to a channel from the terminal!'
|
13
|
+
spec.homepage = 'https://github.com/grubernaut/SlackCI'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
# Require >= 1.9 Ruby
|
22
|
+
spec.required_ruby_version = '>=1.9'
|
23
|
+
|
24
|
+
# Dependencies
|
25
|
+
spec.add_dependency 'rspec', '~>3.0'
|
26
|
+
spec.add_dependency 'json', '~>1.8.1', '>= 1.8.1'
|
27
|
+
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
29
|
+
spec.add_development_dependency 'rake', '~> 10.3.2', '>=10.3.2'
|
30
|
+
spec.add_development_dependency 'rubocop', '~>0.23.0', '>= 0.23.0'
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SlackCi do
|
4
|
+
describe 'send' do
|
5
|
+
it 'should post, returning 200(OK) from SlackAPI' do
|
6
|
+
slack = SlackCi.new('slackCI', 'D7eRlWzfbmZuqL2CqtXHS4ZA')
|
7
|
+
expect(slack.say(
|
8
|
+
'text' => 'Sample Message', 'channel' => '#spectest'
|
9
|
+
)).to eq('200')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: slack_ci
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jake Champlin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.8.1
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.8.1
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.8.1
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.8.1
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.6'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1.6'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rake
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 10.3.2
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 10.3.2
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 10.3.2
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 10.3.2
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rubocop
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 0.23.0
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 0.23.0
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 0.23.0
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 0.23.0
|
101
|
+
description: Post Slack Messages to a channel from the terminal!
|
102
|
+
email:
|
103
|
+
- jake.champlin.27@gmail.com
|
104
|
+
executables: []
|
105
|
+
extensions: []
|
106
|
+
extra_rdoc_files: []
|
107
|
+
files:
|
108
|
+
- ".gitignore"
|
109
|
+
- ".rubocop.yml"
|
110
|
+
- ".rubocop_todo.yml"
|
111
|
+
- ".travis.yml"
|
112
|
+
- Gemfile
|
113
|
+
- LICENSE.txt
|
114
|
+
- README.md
|
115
|
+
- Rakefile
|
116
|
+
- lib/slack_ci.rb
|
117
|
+
- lib/slack_ci/slack_ci_api.rb
|
118
|
+
- lib/slack_ci/version.rb
|
119
|
+
- slack_ci.gemspec
|
120
|
+
- spec/spec_helper.rb
|
121
|
+
- spec/unit/slack_ci_spec.rb
|
122
|
+
homepage: https://github.com/grubernaut/SlackCI
|
123
|
+
licenses:
|
124
|
+
- MIT
|
125
|
+
metadata: {}
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '1.9'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 2.3.0
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: Use Slack from the terminal!
|
146
|
+
test_files:
|
147
|
+
- spec/spec_helper.rb
|
148
|
+
- spec/unit/slack_ci_spec.rb
|