say2slack 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0a60a24acbd51a9d9e2f35ff9ee5e5abf3a29f74
4
+ data.tar.gz: 1692341fc5739053574837882487d5b0d4a30e93
5
+ SHA512:
6
+ metadata.gz: 0946150537a27ea9c9895684b794af792f549ff5e665f6ca2764645ab588e4583b6acf62aaea9302e4e8c4d79fa275753b10caac6d1aab5da97d9b19a2049637
7
+ data.tar.gz: 42fb6375faab456bca7b26c8a8aad0f7928a29683ad696608492e7b17018426ee91ad5878e6895ae759fc93cb0c89f987b7ccc1a8babe38b6bd4168331b352b5
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gem 'rest-client'
@@ -0,0 +1,31 @@
1
+ # Send2Slack
2
+
3
+ A simple ruby gem for sending messages to slack
4
+
5
+ ## Setup
6
+
7
+ `gem install say2slack`
8
+
9
+ or include in Gemfile
10
+
11
+ ```ruby
12
+ # Gemfile
13
+ source 'https://rubygems.org'
14
+
15
+ gem 'say2slack'
16
+ ```
17
+
18
+ ## Configuration
19
+
20
+ Set environment variables for:
21
+
22
+ - SLACK_API_TOKEN
23
+ - SLACK_BOT_IMG (url to image)
24
+
25
+ ## Usage
26
+
27
+ Call from your code:
28
+
29
+ `"FromName".says("Message").to("#roomName")`
30
+
31
+ where FromName is who you want the message to be sent from, Message is the text you want posted to the channel, and roomName is the name of the channel you're posting to. roomName can also be a @user. In this instance, it appear in the slackbot thread.
@@ -0,0 +1,8 @@
1
+ module Say2Slack
2
+ Dir[File.dirname(__FILE__) + '/say2slack/*.rb'].each do |file|
3
+ require file
4
+ end
5
+ if defined?(Rails)
6
+ require File.dirname(__FILE__) + '/say2slack/railtie/railtie.rb'
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ String.class_eval do
2
+ def says(message)
3
+ obj = Say2Slack::Main.new(self)
4
+ obj.says(message)
5
+ end
6
+
7
+ def to(channel='C03J89HD8')
8
+ url = [self, "&channel=#{channel}"].join
9
+ RestClient.post(URI.encode(url), {}, content_type: :json)
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ require 'rest-client'
2
+ module Say2Slack
3
+ class Main
4
+ def initialize(user)
5
+ @user = user
6
+ @token = ENV['SLACK_API_TOKEN'] || ""
7
+ @image = ENV['SLACK_BOT_IMG'] || ""
8
+ end
9
+
10
+ def says(message)
11
+ endpoint = "https://slack.com/api/chat.postMessage"
12
+ return [
13
+ "#{endpoint}?token=#{@token}",
14
+ "username=#{@user}",
15
+ "text=#{message}"
16
+ ].join("&")
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ # module Say2Slack
2
+ # class Say2SlackRailtie < ::Rails::Railtie
3
+ # initializer "say2slackrailtie.override_string" do
4
+ # class String
5
+ # def says(message)
6
+ # obj = Say2Slack::Main.new(self)
7
+ # obj.says(message)
8
+ # end
9
+
10
+ # def to(channel='C03J89HD8')
11
+ # url = [self, "&channel=#{channel}"].join
12
+ # RestClient.post(URI.encode(url), {}, content_type: :json)
13
+ # end
14
+ # end
15
+ # end
16
+ # end
17
+ # end
@@ -0,0 +1,3 @@
1
+ module Say2Slack
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,20 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'say2slack/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "say2slack"
8
+ spec.version = Say2Slack::VERSION
9
+ spec.authors = ["Nick Prokesch"]
10
+ spec.email = ["nick@prokes.ch"]
11
+ spec.summary = %q{A simple ruby gem for post messages to Slack}
12
+ spec.description = %q{A syntax and gem for posting to slack channels or DMs with one line of code}
13
+ spec.homepage = "http://nick.prokes.ch"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_dependency "rest-client", "~> 1.8"
20
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: say2slack
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Nick Prokesch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ description: A syntax and gem for posting to slack channels or DMs with one line of
28
+ code
29
+ email:
30
+ - nick@prokes.ch
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".gitignore"
36
+ - Gemfile
37
+ - README.md
38
+ - lib/say2slack.rb
39
+ - lib/say2slack/core_ext.rb
40
+ - lib/say2slack/main.rb
41
+ - lib/say2slack/railtie/railtie.rb
42
+ - lib/say2slack/version.rb
43
+ - say2slack.gemspec
44
+ homepage: http://nick.prokes.ch
45
+ licenses:
46
+ - MIT
47
+ metadata: {}
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubyforge_project:
64
+ rubygems_version: 2.4.5
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: A simple ruby gem for post messages to Slack
68
+ test_files: []