lita-irc 1.2.3 → 1.3.0

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: 7f6bcd5ab576ecbe1570ede78cde8a1adf99d0ae
4
- data.tar.gz: 9f47d348b44fd21011c85b6959d8b6d14b3b9cbe
3
+ metadata.gz: a5f6718f839abd60bc28ecfa83cc7fdad901bc39
4
+ data.tar.gz: cfe790709ff47c4e191e481099bee658e5049abf
5
5
  SHA512:
6
- metadata.gz: c73638cfc160a3f1271b1595dc580cd973bcd280d6db4807a741e0c870470169acb7c1841337b02eaf883d30a58a1a2f1ed9b9c9dd93df08b78a2245ee0605a0
7
- data.tar.gz: 84d8135f94be890ae7a477e1f7deacd442f26b99d74a32406478c2663ce1dc88deddf408e04a9a80da1fdf5c53014ee19c83c79052a59c869c3100ea797612c6
6
+ metadata.gz: 12fd0af0616013b03b98f74ed7d490f759e5b4bc55684c604642803cf2f695b2cbc17b2dc18d03be4016d95f4e386bca283208f3475efc6fd9574acf4233f9ef
7
+ data.tar.gz: b55553fd2aab232ec95a82be7ca433b8bd2c33628a0d375e4c1462e1ad28a97d562528be1b3aee78ce3f3a1bb4b6e8377b78c56b2c42da40f57579912423b948
@@ -14,7 +14,6 @@ module Lita
14
14
  super
15
15
 
16
16
  @cinch = Cinch::Bot.new
17
- normalize_config
18
17
  configure_cinch
19
18
  configure_logging
20
19
  register_plugin
@@ -25,6 +24,14 @@ module Lita
25
24
  cinch.start
26
25
  end
27
26
 
27
+ def join(room_id)
28
+ cinch.join(room_id)
29
+ end
30
+
31
+ def part(room_id)
32
+ cinch.part(room_id)
33
+ end
34
+
28
35
  def send_messages(target, strings)
29
36
  if target.private_message?
30
37
  user = Cinch::User.new(target.user.name, cinch)
@@ -50,15 +57,23 @@ module Lita
50
57
 
51
58
  private
52
59
 
53
- def normalize_config
54
- Lita.config.adapter.channels = Array(Lita.config.adapter.channels)
55
- Lita.config.adapter.nick = Lita.config.robot.name
60
+ def channels
61
+ Array(Lita.config.adapter.channels)
62
+ end
63
+
64
+ def nick
65
+ Lita.config.robot.name
56
66
  end
57
67
 
58
68
  def configure_cinch
59
69
  Lita.logger.debug("Configuring Cinch.")
60
70
  cinch.configure do |config|
71
+ config.channels = channels
72
+ config.nick = nick
73
+
61
74
  Lita.config.adapter.each do |key, value|
75
+ next if [:channels, :nick].include?(key.to_sym)
76
+
62
77
  if config.class::KnownOptions.include?(key)
63
78
  config.send("#{key}=", value)
64
79
  end
data/lita-irc.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-irc"
3
- spec.version = "1.2.3"
3
+ spec.version = "1.3.0"
4
4
  spec.authors = ["Jimmy Cuadra"]
5
5
  spec.email = ["jimmy@jimmycuadra.com"]
6
6
  spec.description = %q{An IRC adapter for Lita.}
@@ -14,12 +14,12 @@ 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.5"
18
- spec.add_runtime_dependency "cinch", "~> 2.0"
17
+ spec.add_runtime_dependency "lita", ">= 2.5"
18
+ spec.add_runtime_dependency "cinch", ">= 2.0"
19
19
 
20
20
  spec.add_development_dependency "bundler", "~> 1.3"
21
21
  spec.add_development_dependency "rake"
22
- spec.add_development_dependency "rspec", "~> 2.14"
22
+ spec.add_development_dependency "rspec", ">= 3.0.0.beta2"
23
23
  spec.add_development_dependency "simplecov"
24
24
  spec.add_development_dependency "coveralls"
25
25
  end
@@ -9,57 +9,47 @@ describe Lita::Adapters::IRC::CinchPlugin do
9
9
  let(:message) { double("Lita::Message", command!: nil, source: source) }
10
10
  let(:source) { double("Lita::Source", room: "#channel", user: user) }
11
11
  let(:m) do
12
- double(
12
+ instance_double(
13
13
  "Cinch::Message",
14
14
  action_message: "foo",
15
15
  message: "bar",
16
- action?: false
17
- ).as_null_object
16
+ action?: false,
17
+ channel: cinch_channel,
18
+ user: cinch_user
19
+ )
18
20
  end
19
21
  let(:invite_m) do
20
- double(
22
+ instance_double(
21
23
  "Cinch::Message",
22
- channel: double("Cinch::Channel"),
23
- user: double("Cinch::User", nick: "Carl")
24
+ channel: cinch_channel,
25
+ user: cinch_user
24
26
  )
25
27
  end
28
+ let(:cinch_channel) { instance_double("Cinch::Channel", name: "#lita.io") }
29
+ let(:cinch_user) { instance_double("Cinch::User", nick: "Carl") }
26
30
 
27
31
  before do
28
- allow(subject).to receive(:config).and_return(
29
- double("Hash", :[] => robot)
30
- )
32
+ allow(subject).to receive(:config).and_return(instance_double("Hash", :[] => robot))
31
33
  allow(Lita::Source).to receive(:new).and_return(source)
32
34
  end
33
35
 
34
36
  describe "#execute" do
35
37
  it "dispatches regular messages to the robot" do
36
- allow(Lita::Message).to receive(:new).with(
37
- robot,
38
- "bar",
39
- source
40
- ).and_return(message)
38
+ allow(Lita::Message).to receive(:new).with(robot, "bar", source).and_return(message)
41
39
  expect(robot).to receive(:receive).with(message)
42
40
  subject.execute(m)
43
41
  end
44
42
 
45
43
  it "dispatches action messages to the robot" do
46
44
  allow(m).to receive(:action?).and_return(true)
47
- allow(Lita::Message).to receive(:new).with(
48
- robot,
49
- "foo",
50
- source
51
- ).and_return(message)
45
+ allow(Lita::Message).to receive(:new).with(robot, "foo", source).and_return(message)
52
46
  expect(robot).to receive(:receive).with(message)
53
47
  subject.execute(m)
54
48
  end
55
49
 
56
50
  it "marks private messages as commands" do
57
51
  allow(source).to receive(:room).and_return(nil)
58
- allow(Lita::Message).to receive(:new).with(
59
- robot,
60
- "bar",
61
- source
62
- ).and_return(message)
52
+ allow(Lita::Message).to receive(:new).with(robot, "bar", source).and_return(message)
63
53
  allow(robot).to receive(:receive)
64
54
  expect(message).to receive(:command!)
65
55
  subject.execute(m)
@@ -76,9 +66,7 @@ describe Lita::Adapters::IRC::CinchPlugin do
76
66
  describe "#on_invite" do
77
67
  it "joins the room if the invite came from an admin" do
78
68
  allow(subject).to receive(:user_by_nick).and_return(user)
79
- allow(Lita::Authorization).to receive(
80
- :user_is_admin?
81
- ).with(user).and_return(true)
69
+ allow(Lita::Authorization).to receive(:user_is_admin?).with(user).and_return(true)
82
70
  expect(invite_m.channel).to receive(:join)
83
71
  subject.on_invite(invite_m)
84
72
  end
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Lita::Adapters::IRC, lita: true do
4
- let(:robot) { double("Lita::Robot") }
4
+ let(:robot) { instance_double("Lita::Robot") }
5
5
 
6
6
  subject { described_class.new(robot) }
7
7
 
@@ -40,9 +40,7 @@ describe Lita::Adapters::IRC, lita: true do
40
40
  end
41
41
 
42
42
  it "registers a plugin with Cinch" do
43
- expect(subject.cinch.config.plugins.plugins).to include(
44
- described_class::CinchPlugin
45
- )
43
+ expect(subject.cinch.config.plugins.plugins).to include(described_class::CinchPlugin)
46
44
  end
47
45
 
48
46
  it "turns Cinch's logging on if config.adapter.log_level is set" do
@@ -50,6 +48,20 @@ describe Lita::Adapters::IRC, lita: true do
50
48
  expect(subject.cinch.loggers).not_to be_empty
51
49
  end
52
50
 
51
+ describe "#join" do
52
+ it "joins a channel" do
53
+ expect(subject.cinch).to receive(:join).with("#lita.io")
54
+ subject.join("#lita.io")
55
+ end
56
+ end
57
+
58
+ describe "#part" do
59
+ it "parts from a channel" do
60
+ expect(subject.cinch).to receive(:part).with("#lita.io")
61
+ subject.part("#lita.io")
62
+ end
63
+ end
64
+
53
65
  describe "#run" do
54
66
  it "connects to IRC" do
55
67
  expect(subject.cinch).to receive(:start)
@@ -59,25 +71,19 @@ describe Lita::Adapters::IRC, lita: true do
59
71
 
60
72
  describe "#send_messages" do
61
73
  it "sends messages to rooms" do
62
- source = double("Lita::Source", room: "#foo", private_message?: false)
63
- channel = double("Cinch::Channel")
64
- allow(Cinch::Channel).to receive(:new).with(
65
- "#foo",
66
- subject.cinch
67
- ).and_return(channel)
74
+ source = instance_double("Lita::Source", room: "#foo", private_message?: false)
75
+ channel = instance_double("Cinch::Channel")
76
+ allow(Cinch::Channel).to receive(:new).with("#foo", subject.cinch).and_return(channel)
68
77
  expect(channel).to receive(:msg).with("Hello!")
69
78
  expect(channel).to receive(:msg).with("How are you?")
70
79
  subject.send_messages(source, ["Hello!", "How are you?"])
71
80
  end
72
81
 
73
82
  it "sends messages to users" do
74
- user = double("Lita::User", name: "Carl")
75
- source = double("Lita::Source", user: user, private_message?: true)
76
- user = double("Cinch::User")
77
- allow(Cinch::User).to receive(:new).with(
78
- "Carl",
79
- subject.cinch
80
- ).and_return(user)
83
+ user = instance_double("Lita::User", name: "Carl")
84
+ source = instance_double("Lita::Source", user: user, private_message?: true)
85
+ user = instance_double("Cinch::User")
86
+ allow(Cinch::User).to receive(:new).with("Carl", subject.cinch).and_return(user)
81
87
  expect(user).to receive(:msg).with("Hello!")
82
88
  expect(user).to receive(:msg).with("How are you?")
83
89
  subject.send_messages(source, ["Hello!", "How are you?"])
@@ -86,12 +92,9 @@ describe Lita::Adapters::IRC, lita: true do
86
92
 
87
93
  describe "#set_topic" do
88
94
  it "sets a new topic for the room" do
89
- source = double("Lita::Source", room: "#foo")
90
- channel = double("Cinch::Channel")
91
- expect(Cinch::Channel).to receive(:new).with(
92
- "#foo",
93
- subject.cinch
94
- ).and_return(channel)
95
+ source = instance_double("Lita::Source", room: "#foo")
96
+ channel = instance_double("Cinch::Channel")
97
+ expect(Cinch::Channel).to receive(:new).with("#foo", subject.cinch).and_return(channel)
95
98
  expect(channel).to receive(:topic=).with("Topic")
96
99
  subject.set_topic(source, "Topic")
97
100
  end
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-irc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Cuadra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-20 00:00:00.000000000 Z
11
+ date: 2014-02-23 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.5'
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.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: cinch
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '2.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
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
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '2.14'
75
+ version: 3.0.0.beta2
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '2.14'
82
+ version: 3.0.0.beta2
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: coveralls
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  description: An IRC adapter for Lita.
@@ -115,8 +115,8 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
- - .gitignore
119
- - .travis.yml
118
+ - ".gitignore"
119
+ - ".travis.yml"
120
120
  - Gemfile
121
121
  - LICENSE
122
122
  - README.md
@@ -139,17 +139,17 @@ require_paths:
139
139
  - lib
140
140
  required_ruby_version: !ruby/object:Gem::Requirement
141
141
  requirements:
142
- - - '>='
142
+ - - ">="
143
143
  - !ruby/object:Gem::Version
144
144
  version: '0'
145
145
  required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  requirements:
147
- - - '>='
147
+ - - ">="
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
150
  requirements: []
151
151
  rubyforge_project:
152
- rubygems_version: 2.1.11
152
+ rubygems_version: 2.2.0
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: An IRC adapter for the Lita chat robot.
@@ -157,3 +157,4 @@ test_files:
157
157
  - spec/lita/adapters/irc/cinch_plugin_spec.rb
158
158
  - spec/lita/adapters/irc_spec.rb
159
159
  - spec/spec_helper.rb
160
+ has_rdoc: