lita-slack 0.1.0 → 0.1.1

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: 756bfd5bc0c402ad707500b2d06fe4131ae61414
4
- data.tar.gz: ba2490c9f35bfbe7dda51dffb5d18da5c18b5bba
3
+ metadata.gz: 60febde35bc9d404a1f04851c1d0a94ba294a8a7
4
+ data.tar.gz: ce2b58b7860b97a173969f3664d1b4070098a510
5
5
  SHA512:
6
- metadata.gz: 99dd9b57499029f4feb8bd8624ed6c6f710c100f0b11cdcbb52ed9752516d6652a7e3b92e3ce3278299c604fb74b6a672bede4ea81b036af18605411dc3b58b6
7
- data.tar.gz: bc4639ebffb94030a59873e206a7708945a5b4b304a6d2d53be946233f0c3254eb2c1d6937b7a2f777ae88ece3af6b7aab7a0b10492f44b60eebcaf414d77e96
6
+ metadata.gz: 98ed9467a3b5f8bd8d095c1b36373b8ca630c02e117ab4d6f6a0fa3129cc253813c510a35dac92fbd92141e100a81e217669f3eb44017f5f4a3b1d51504cad8a
7
+ data.tar.gz: 96f291cb60d74b938d7f428dd5fcaed9ec2dd7acdd2d8acc44644e3662c1120743c645d017ec1d56941e8b47551388f609a0b617ed334353b16a86f231f5955d
data/.gitignore ADDED
@@ -0,0 +1,18 @@
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
+ lita_config.rb
@@ -8,16 +8,6 @@ module Lita
8
8
  # Required Lita config keys (via lita_config.rb)
9
9
  require_configs :incoming_token, :team_domain
10
10
 
11
- def initialize(robot)
12
- log.debug 'Slack::initialize started'
13
- super
14
- # Set config default values
15
- config.incoming_url ||= "https://#{config.team_domain}.slack.com/services/hooks/incoming-webhook"
16
- config.username ||= nil
17
- config.add_mention ||= false
18
- log.debug 'Slack::initialize ending'
19
- end
20
-
21
11
  # Adapter main run loop
22
12
  def run
23
13
  log.debug 'Slack::run started'
@@ -25,22 +15,24 @@ module Lita
25
15
  rescue Interrupt
26
16
  shut_down
27
17
  end
28
-
18
+
29
19
  def send_messages(target, strings)
30
20
  log.debug 'Slack::send_messages started'
31
21
  status = http_post prepare_payload(target, strings)
32
22
  log.error "Slack::send_messages failed to send (#{status})" if status != 200
33
23
  log.debug 'Slack::send_messages ending'
34
24
  end
35
-
25
+
36
26
  def set_topic(target, topic)
37
27
  # Slack currently provides no method
38
28
  log.info 'Slack::set_topic no implementation'
39
29
  end
40
-
30
+
41
31
  def shut_down
42
32
  end
43
-
33
+
34
+ private
35
+
44
36
  def prepare_payload(target, strings)
45
37
  if not defined?(target.room)
46
38
  channel_id = nil
@@ -48,17 +40,17 @@ module Lita
48
40
  else
49
41
  channel_id = target.room
50
42
  end
51
- payload = {'channel' => channel_id, 'username' => config.username}
43
+ payload = {'channel' => channel_id, 'username' => username}
52
44
  payload['text'] = strings.join('\n')
53
- if config.add_mention and defined?(target.user.id)
45
+ if add_mention? and defined?(target.user.id)
54
46
  payload['text'] = payload['text'].prepend("<@#{target.user.id}> ")
55
47
  end
56
48
  return payload
57
49
  end
58
-
50
+
59
51
  def http_post(payload)
60
52
  res = Faraday.post do |req|
61
- log.debug "Slack::http_post sending payload to #{config.incoming_url}; length: #{payload.to_json.size}"
53
+ log.debug "Slack::http_post sending payload to #{incoming_url}; length: #{payload.to_json.size}"
62
54
  req.url config.incoming_url, :token => config.incoming_token
63
55
  req.headers['Content-Type'] = 'application/json'
64
56
  req.body = payload.to_json
@@ -74,12 +66,25 @@ module Lita
74
66
  def config
75
67
  Lita.config.adapter
76
68
  end
77
-
69
+
78
70
  def log
79
71
  Lita.logger
80
72
  end
73
+
74
+ def incoming_url
75
+ config.incoming_url ||
76
+ "https://#{config.team_domain}.slack.com/services/hooks/incoming-webhook"
77
+ end
78
+
79
+ def username
80
+ config.username
81
+ end
82
+
83
+ def add_mention?
84
+ config.add_mention
85
+ end
81
86
  end
82
-
87
+
83
88
  # Register Slack adapter to Lita
84
89
  Lita.register_adapter(:slack, Slack)
85
90
  end
data/lita-slack.gemspec CHANGED
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-slack"
3
- spec.version = "0.1.0"
3
+ spec.version = "0.1.1"
4
4
  spec.authors = ["Ken J."]
5
5
  spec.email = ["kenjij@gmail.com"]
6
- spec.description = %q{Lita adapter for Slack}
7
- spec.summary = %q{Lita adapter for Slack using Sinatra. Requires lita-slack-handler gem.}
6
+ spec.description = %q{Lita adapter for Slack.}
7
+ spec.summary = %q{Lita adapter for Slack.}
8
8
  spec.homepage = "https://github.com/kenjij/lita-slack"
9
9
  spec.license = "MIT"
10
10
  spec.metadata = { "lita_plugin_type" => "adapter" }
@@ -14,11 +14,10 @@ Gem::Specification.new do |spec|
14
14
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
15
  spec.require_paths = ["lib"]
16
16
 
17
- spec.add_runtime_dependency "lita", "~> 2.7"
18
- spec.add_runtime_dependency "lita-slack-handler", "~> 0.2"
19
- spec.add_runtime_dependency "faraday", ">= 0.8.7"
17
+ spec.add_runtime_dependency "lita", ">= 2.7"
18
+ spec.add_runtime_dependency "lita-slack-handler", ">= 0.2.1"
20
19
 
21
20
  spec.add_development_dependency "bundler", "~> 1.3"
22
21
  spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec", ">= 2.14"
22
+ spec.add_development_dependency "rspec", ">= 3.0.0.beta2"
24
23
  end
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Lita::Adapters::Slack do
3
+ describe Lita::Adapters::Slack, lita: true do
4
4
  before do
5
5
  Lita.configure do |config|
6
6
  config.adapter.incoming_token = 'aN1NvAlIdDuMmYt0k3n'
@@ -16,13 +16,13 @@ describe Lita::Adapters::Slack do
16
16
  it "registers with Lita" do
17
17
  expect(Lita.adapters[:slack]).to eql(described_class)
18
18
  end
19
-
19
+
20
20
  it "fails without valid config: incoming_token and team_domain" do
21
21
  Lita.clear_config
22
22
  expect(Lita.logger).to receive(:fatal).with(/incoming_token, team_domain/)
23
23
  expect { subject }.to raise_error(SystemExit)
24
24
  end
25
-
25
+
26
26
  describe "#send_messages" do
27
27
  it "sends JSON payload via HTTP POST to Slack channel" do
28
28
  target = double("Lita::Source", room: "CR00M1D")
metadata CHANGED
@@ -1,57 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-slack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken J.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-17 00:00:00.000000000 Z
11
+ date: 2014-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.7'
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
26
  version: '2.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: lita-slack-handler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: '0.2'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ~>
39
- - !ruby/object:Gem::Version
40
- version: '0.2'
41
- - !ruby/object:Gem::Dependency
42
- name: faraday
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - '>='
46
32
  - !ruby/object:Gem::Version
47
- version: 0.8.7
33
+ version: 0.2.1
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - '>='
53
39
  - !ruby/object:Gem::Version
54
- version: 0.8.7
40
+ version: 0.2.1
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: bundler
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -86,21 +72,22 @@ dependencies:
86
72
  requirements:
87
73
  - - '>='
88
74
  - !ruby/object:Gem::Version
89
- version: '2.14'
75
+ version: 3.0.0.beta2
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - '>='
95
81
  - !ruby/object:Gem::Version
96
- version: '2.14'
97
- description: Lita adapter for Slack
82
+ version: 3.0.0.beta2
83
+ description: Lita adapter for Slack.
98
84
  email:
99
85
  - kenjij@gmail.com
100
86
  executables: []
101
87
  extensions: []
102
88
  extra_rdoc_files: []
103
89
  files:
90
+ - .gitignore
104
91
  - Gemfile
105
92
  - LICENSE
106
93
  - README.md
@@ -131,10 +118,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
118
  version: '0'
132
119
  requirements: []
133
120
  rubyforge_project:
134
- rubygems_version: 2.0.7
121
+ rubygems_version: 2.2.2
135
122
  signing_key:
136
123
  specification_version: 4
137
- summary: Lita adapter for Slack using Sinatra. Requires lita-slack-handler gem.
124
+ summary: Lita adapter for Slack.
138
125
  test_files:
139
126
  - spec/lita/adapters/slack_spec.rb
140
127
  - spec/spec_helper.rb