cinch-hangouts 1.0.6 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +32 -1
- data/cinch-hangouts.gemspec +9 -8
- data/lib/cinch/plugins/hangouts.rb +43 -37
- data/lib/cinch/plugins/hangouts/hangout.rb +16 -13
- data/lib/cinch/plugins/hangouts/subscription.rb +19 -16
- data/lib/cinch/plugins/hangouts/version.rb +1 -1
- data/spec/cinch-hangouts_spec.rb +65 -71
- data/spec/spec_helper.rb +2 -8
- metadata +67 -60
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 45fde4d2a553d57adc0da9c914d4523853acdbae
|
4
|
+
data.tar.gz: 4ff858cfa515f6f64465cf4cb524ae67c3a53125
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8fe3adc17dfe6cd57258170d665a3b68c9944e3078f45c33d6184d51480e4c578f1b31bfaa84e6c416c6a3f1835d9addc3eeceaa4d77749f277fe2b7728e4fad
|
7
|
+
data.tar.gz: 02e10783b7f9486e16fb7b3498634eb30133f94108721d4dd5dae08ca3018255bc9851c62e8a53af2c82eabf2a0f5d5e56a67f62a6f11bd223022590b3fe03dd
|
data/.travis.yml
CHANGED
@@ -1,4 +1,35 @@
|
|
1
1
|
language: ruby
|
2
|
+
addons:
|
3
|
+
code_climate:
|
4
|
+
repo_token: 8ef6d81d6b07ed7d9e852307f2d6a28c2c4f49b8a27c9ee5951ae4e1381a8396
|
5
|
+
before_install:
|
6
|
+
- gem update --system
|
7
|
+
- gem update bundler
|
8
|
+
env:
|
9
|
+
global:
|
10
|
+
- "JRUBY_OPTS=-Xcext.enabled=true"
|
2
11
|
rvm:
|
3
|
-
-
|
12
|
+
- 2.3.0
|
13
|
+
- 2.2.0
|
14
|
+
- 2.1.0
|
15
|
+
- 2.0.0
|
4
16
|
- 1.9.3
|
17
|
+
- 1.9.2
|
18
|
+
- 1.8.7
|
19
|
+
- jruby-18mode
|
20
|
+
- jruby-19mode
|
21
|
+
- ruby-head
|
22
|
+
- jruby-head
|
23
|
+
- ree
|
24
|
+
matrix:
|
25
|
+
allow_failures:
|
26
|
+
- rvm: 1.9.3
|
27
|
+
- rvm: 1.9.2
|
28
|
+
- rvm: 1.8.7
|
29
|
+
- rvm: 1.8.7
|
30
|
+
- rvm: ree
|
31
|
+
- rvm: jruby-18mode
|
32
|
+
- rvm: jruby-19mode
|
33
|
+
- rvm: jruby-head
|
34
|
+
- rvm: ruby-head
|
35
|
+
fast_finish: true
|
data/cinch-hangouts.gemspec
CHANGED
@@ -18,13 +18,14 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ['lib']
|
20
20
|
|
21
|
-
gem.add_development_dependency
|
22
|
-
gem.add_development_dependency
|
23
|
-
gem.add_development_dependency
|
24
|
-
gem.add_development_dependency
|
21
|
+
gem.add_development_dependency 'rake', '~> 10'
|
22
|
+
gem.add_development_dependency 'rspec', '~> 3'
|
23
|
+
gem.add_development_dependency 'cinch-test', '~> 0.1', '>= 0.1.1'
|
24
|
+
gem.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
|
25
25
|
|
26
|
-
gem.add_dependency
|
27
|
-
gem.add_dependency
|
28
|
-
gem.add_dependency
|
29
|
-
gem.add_dependency
|
26
|
+
gem.add_dependency 'cinch', '~> 2.0'
|
27
|
+
gem.add_dependency 'cinch-cooldown', '~> 1.1.7'
|
28
|
+
gem.add_dependency 'cinch-storage', '~> 1.2'
|
29
|
+
gem.add_dependency 'cinch-toolbox', '~> 1.1'
|
30
|
+
gem.add_dependency 'time-lord', '~> 1.0', '>= 1.0.1'
|
30
31
|
end
|
@@ -8,31 +8,30 @@ module Cinch::Plugins
|
|
8
8
|
# Plugin to track Google Hangout links
|
9
9
|
class Hangouts
|
10
10
|
include Cinch::Plugin
|
11
|
-
|
12
|
-
|
11
|
+
HANGOUT_FILENAME = 'yaml/hangouts.yml'
|
12
|
+
SUBSCRIPTION_FILENAME = 'yaml/hangout_subscriptions.yml'
|
13
|
+
|
14
|
+
# This is the regex that captures hangout links
|
15
|
+
# The regex will need to be updated if the url scheme changes in the future
|
16
|
+
HANGOUTS_REGEX = %r((?:_|call)/([a-z0-9]{10,40})(?:\?|$))
|
13
17
|
|
14
18
|
attr_accessor :storage
|
15
19
|
|
16
20
|
self.help = 'Use .hangouts to see the info for any recent hangouts. You ' +
|
17
21
|
'can also use .hangouts subscribe to sign up for notifications'
|
18
22
|
|
19
|
-
match
|
20
|
-
match
|
21
|
-
match
|
23
|
+
match(/hangouts\z/, method: :list_hangouts)
|
24
|
+
match(/hangouts subscribe/, method: :subscribe)
|
25
|
+
match(/hangouts unsubscribe/, method: :unsubscribe)
|
22
26
|
|
23
27
|
listen_to :channel
|
24
28
|
|
25
|
-
# This is the regex that captures hangout links
|
26
|
-
# The regex will need to be updated if the url scheme changes in the future
|
27
|
-
HANGOUTS_REGEX = %r(plus\.google\.com/hangouts/_/([a-z0-9]{10,40})(\?|$))
|
28
|
-
|
29
29
|
def initialize(*args)
|
30
30
|
super
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
@files = {
|
32
|
+
hangouts: config[:hangout_filename] || HANGOUT_FILENAME,
|
33
|
+
subscriptions: config[:subscription_filename] || SUBSCRIPTION_FILENAME
|
34
|
+
}
|
36
35
|
@expire = config[:expire_period] || 120
|
37
36
|
@response_type = config[:response_type] || :notice
|
38
37
|
end
|
@@ -43,55 +42,62 @@ module Cinch::Plugins
|
|
43
42
|
end
|
44
43
|
|
45
44
|
def process_hangout(hangout_id, m)
|
46
|
-
if Hangout.find_by_id(hangout_id)
|
45
|
+
if Hangout.find_by_id(hangout_id, @files)
|
47
46
|
# If it's an old hangout capture a new expiration time
|
48
|
-
hangout = Hangout.find_by_id(hangout_id)
|
47
|
+
hangout = Hangout.find_by_id(hangout_id, @files)
|
49
48
|
hangout.time = Time.now
|
50
49
|
hangout.save
|
50
|
+
debug "Old hangout with id:#{hangout_id} relinked."
|
51
51
|
else
|
52
|
-
Hangout.new(m.user.nick, hangout_id, Time.now)
|
53
|
-
|
54
|
-
|
52
|
+
Hangout.new(m.user.nick, hangout_id, Time.now, @files).save
|
53
|
+
Subscription.notify(hangout_id, @bot, @response_type, @files)
|
54
|
+
debug "New hangout with id:#{hangout_id} created."
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
def subscribe(m)
|
59
59
|
nick = m.user.nick
|
60
|
-
if Subscription.for_user(nick)
|
60
|
+
if Subscription.for_user(nick, @files)
|
61
61
|
msg = 'You are already subscribed. '
|
62
|
+
debug "#{nick} subscription request failed: Already subscribed."
|
62
63
|
else
|
63
|
-
sub = Subscription.new(nick)
|
64
|
+
sub = Subscription.new(nick, @files)
|
64
65
|
sub.save
|
65
|
-
msg = 'You are now subscribed. '
|
66
|
-
'
|
66
|
+
msg = 'You are now subscribed. I will let you know when a hangout ' \
|
67
|
+
' is linked. '
|
68
|
+
debug "#{nick} subscription request succeeded."
|
67
69
|
end
|
68
|
-
m.user.notice msg
|
70
|
+
m.user.notice "#{msg} To unsubscribe use `.hangouts unsubscribe`."
|
69
71
|
end
|
70
72
|
|
71
73
|
def unsubscribe(m)
|
72
74
|
nick = m.user.nick
|
73
|
-
if Subscription.for_user(nick)
|
74
|
-
Subscription.for_user(nick).
|
75
|
-
|
76
|
-
|
75
|
+
if Subscription.for_user(nick, @files)
|
76
|
+
debug Subscription.for_user(nick, @files).to_s
|
77
|
+
Subscription.for_user(nick, @files).destroy
|
78
|
+
msg = 'You are now unsubscribed, and will no longer receive a messages.'
|
79
|
+
debug "#{nick} unsubscription request succeeded."
|
77
80
|
else
|
78
|
-
msg = 'You are not subscribed.
|
81
|
+
msg = 'You are not subscribed.'
|
82
|
+
debug "#{nick} unsubscription request failed: Not subscribed."
|
79
83
|
end
|
80
|
-
m.user.notice msg
|
84
|
+
m.user.notice "#{msg} To subscribe use `.hangouts subscribe`."
|
81
85
|
end
|
82
86
|
|
83
87
|
def list_hangouts(m)
|
84
|
-
Hangout.delete_expired(@expire)
|
85
|
-
if Hangout.sorted.empty?
|
88
|
+
Hangout.delete_expired(@expire, @files)
|
89
|
+
if Hangout.sorted(@files).empty?
|
86
90
|
m.user.notice 'No hangouts have been linked recently!'
|
87
91
|
return
|
88
92
|
end
|
89
|
-
m.user.notice 'These hangouts have been linked in the last '
|
93
|
+
m.user.notice 'These hangouts have been linked in the last ' \
|
90
94
|
"#{@expire} minutes. They may or may not still be going."
|
91
|
-
Hangout.sorted
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
+
hangouts = Hangout.sorted(@files)
|
96
|
+
debug "#{m.user.nick} hangouts listing request; Sending #{hangouts.count} hangouts to them."
|
97
|
+
hangouts.each do |hangout|
|
98
|
+
m.user.notice "#{hangout.nick} started a hangout at " \
|
99
|
+
"#{Hangout.url(hangout.id)} it was last linked " \
|
100
|
+
"#{hangout.time.ago.to_words}"
|
95
101
|
end
|
96
102
|
end
|
97
103
|
end
|
@@ -3,40 +3,42 @@
|
|
3
3
|
class Hangout < Cinch::Plugins::Hangouts
|
4
4
|
attr_accessor :nick, :id, :time, :hangout_filename
|
5
5
|
|
6
|
-
def initialize(nick, id, time)
|
6
|
+
def initialize(nick, id, time, files)
|
7
7
|
@nick = nick
|
8
8
|
@id = id
|
9
9
|
@time = time
|
10
|
+
fail if files.nil? || !files.key?(:hangouts) || files[:hangouts].empty?
|
11
|
+
@filename = files[:hangouts]
|
10
12
|
end
|
11
13
|
|
12
14
|
def save
|
13
|
-
storage = Cinch::Storage.new(
|
15
|
+
storage = Cinch::Storage.new(@filename)
|
14
16
|
storage.data[:hangouts] ||= {}
|
15
17
|
storage.data[:hangouts][id] = self
|
16
18
|
storage.save
|
17
19
|
end
|
18
20
|
|
19
|
-
def self.find_by_id(id)
|
20
|
-
listing[id]
|
21
|
+
def self.find_by_id(id, files)
|
22
|
+
listing(files)[id]
|
21
23
|
end
|
22
24
|
|
23
|
-
def self.delete_expired(expire_time)
|
24
|
-
return if listing.nil?
|
25
|
-
storage = read_file
|
25
|
+
def self.delete_expired(expire_time, files)
|
26
|
+
return if listing(files).nil?
|
27
|
+
storage = read_file(files)
|
26
28
|
storage.data[:hangouts].delete_if do |id, hangout|
|
27
29
|
(Time.now - hangout.time) > (expire_time * 60)
|
28
30
|
end
|
29
31
|
storage.save
|
30
32
|
end
|
31
33
|
|
32
|
-
def self.sorted
|
33
|
-
hangouts = listing.values
|
34
|
+
def self.sorted(files)
|
35
|
+
hangouts = listing(files).values
|
34
36
|
hangouts.sort! { |x, y| y.time <=> x.time }
|
35
37
|
hangouts
|
36
38
|
end
|
37
39
|
|
38
|
-
def self.listing
|
39
|
-
read_file.data[:hangouts]
|
40
|
+
def self.listing(files)
|
41
|
+
read_file(files).data[:hangouts]
|
40
42
|
end
|
41
43
|
|
42
44
|
def self.url(id, shorten = true)
|
@@ -47,8 +49,9 @@ class Hangout < Cinch::Plugins::Hangouts
|
|
47
49
|
|
48
50
|
private
|
49
51
|
|
50
|
-
def self.read_file
|
51
|
-
|
52
|
+
def self.read_file(files)
|
53
|
+
fail "No Hangout filename passed" unless files.key?(:hangouts)
|
54
|
+
storage = Cinch::Storage.new(files[:hangouts])
|
52
55
|
unless storage.data[:hangouts]
|
53
56
|
storage.data[:hangouts] = {}
|
54
57
|
storage.save
|
@@ -3,36 +3,38 @@
|
|
3
3
|
class Subscription < Cinch::Plugins::Hangouts
|
4
4
|
attr_accessor :nick, :all_links
|
5
5
|
|
6
|
-
def initialize(nick)
|
6
|
+
def initialize(nick, files)
|
7
7
|
@nick = nick
|
8
8
|
@all_links = false
|
9
|
+
@files = files
|
9
10
|
save
|
10
11
|
end
|
11
12
|
|
12
13
|
def save
|
13
|
-
subs = Subscription.storage
|
14
|
-
subs.data[nick] = self
|
14
|
+
subs = Subscription.storage(@files)
|
15
|
+
subs.data[@nick] = self
|
15
16
|
subs.save
|
16
17
|
end
|
17
18
|
|
18
|
-
def
|
19
|
-
subs = Subscription.storage
|
20
|
-
subs.data.delete(nick)
|
19
|
+
def destroy
|
20
|
+
subs = Subscription.storage(@files)
|
21
|
+
subs.data.delete(@nick)
|
21
22
|
subs.save
|
22
23
|
end
|
23
24
|
|
24
|
-
def self.for_user(nick)
|
25
|
-
|
26
|
-
|
25
|
+
def self.for_user(nick, files)
|
26
|
+
nicks = list(files)
|
27
|
+
return nil unless nicks.key?(nick)
|
28
|
+
Subscription.new(nick[nick], files)
|
27
29
|
end
|
28
30
|
|
29
|
-
def self.list
|
30
|
-
storage.data
|
31
|
+
def self.list(files)
|
32
|
+
storage(files).data
|
31
33
|
end
|
32
34
|
|
33
|
-
def self.notify(hangout_id, bot, type)
|
34
|
-
nick = Hangout.find_by_id(hangout_id).nick
|
35
|
-
list.each_value do |s|
|
35
|
+
def self.notify(hangout_id, bot, type, files)
|
36
|
+
nick = Hangout.find_by_id(hangout_id, files).nick
|
37
|
+
list(files).each_value do |s|
|
36
38
|
# Don't link the person who linked it.
|
37
39
|
unless nick == s.nick
|
38
40
|
user = Cinch::User.new(s.nick, bot)
|
@@ -54,7 +56,8 @@ class Subscription < Cinch::Plugins::Hangouts
|
|
54
56
|
|
55
57
|
private
|
56
58
|
|
57
|
-
def self.storage
|
58
|
-
|
59
|
+
def self.storage(files)
|
60
|
+
fail "No Subscription filename passed" unless files.key?(:subscriptions)
|
61
|
+
Cinch::Storage.new(files[:subscriptions])
|
59
62
|
end
|
60
63
|
end
|
data/spec/cinch-hangouts_spec.rb
CHANGED
@@ -4,113 +4,106 @@ describe Cinch::Plugins::Hangouts do
|
|
4
4
|
include Cinch::Test
|
5
5
|
|
6
6
|
before(:each) do
|
7
|
-
files = { hangout_filename: '/tmp/hangout.yml',
|
8
|
-
|
9
|
-
files.values.each
|
10
|
-
|
11
|
-
end
|
12
|
-
@bot = make_bot(Cinch::Plugins::Hangouts, files)
|
7
|
+
@files = { hangout_filename: '/tmp/hangout.yml',
|
8
|
+
subscription_filename: '/tmp/subscription.yml' }
|
9
|
+
@files.values.each { |file| File.delete(file) if File.exist?(file) }
|
10
|
+
@bot = make_bot(Cinch::Plugins::Hangouts, @files)
|
13
11
|
end
|
14
12
|
|
15
|
-
describe '
|
16
|
-
it '
|
17
|
-
get_replies(make_message(@bot, '!hangouts', { channel: '#foo' })).first
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should not capture a malformed (invalid chars) Hangout link' do
|
22
|
-
msg = make_message(@bot, Hangout.url('82b5cc7f76b7a%19c180416c2f509027!!d8856d', false),
|
23
|
-
{ :channel => '#foo' })
|
24
|
-
get_replies(msg).should be_empty
|
25
|
-
msg = make_message(@bot, '!hangouts')
|
26
|
-
get_replies(msg).first.text.
|
27
|
-
should == "No hangouts have been linked recently!"
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should not capture a malformed (wrong length) Hangout link' do
|
31
|
-
msg = make_message(@bot, Hangout.url('82b5cc', false),
|
32
|
-
{ :channel => '#foo' })
|
33
|
-
get_replies(msg).should be_empty
|
34
|
-
msg = make_message(@bot, '!hangouts')
|
35
|
-
get_replies(msg).first.text.
|
36
|
-
should == "No hangouts have been linked recently!"
|
13
|
+
describe 'requesting hangout links (!hangouts)' do
|
14
|
+
it 'return an error if no one has linked a hangout' do
|
15
|
+
msg = get_replies(make_message(@bot, '!hangouts', { channel: '#foo' })).first
|
16
|
+
expect(msg.text).to eql('No hangouts have been linked recently!')
|
37
17
|
end
|
18
|
+
end
|
38
19
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
sleep
|
43
|
-
msg
|
44
|
-
reply = get_replies(
|
45
|
-
reply.
|
46
|
-
reply.
|
20
|
+
describe 'posting a valid hangout link' do
|
21
|
+
it 'captures the the link and stores it in @storage' do
|
22
|
+
msg = make_message(@bot, Hangout.url(random_hangout_id, false), { channel: '#foo' })
|
23
|
+
sleep 2
|
24
|
+
get_replies(msg)
|
25
|
+
reply = get_replies(make_message(@bot, '!hangouts')).last.text
|
26
|
+
expect(reply).to include('test started a hangout at')
|
27
|
+
expect(reply).to match(/it was last linked \d seconds? ago/)
|
47
28
|
end
|
48
29
|
|
49
|
-
it '
|
30
|
+
it 'captures even if it has trailing params' do
|
50
31
|
msg = make_message(@bot, Hangout.url(random_hangout_id + '?hl=en', false),
|
51
|
-
{ :
|
32
|
+
{ channel: '#foo' })
|
52
33
|
get_replies(msg)
|
53
|
-
sleep
|
34
|
+
sleep 2 # hack until 'time-lord' fix gets released
|
54
35
|
msg = make_message(@bot, '!hangouts')
|
55
36
|
reply = get_replies(msg).last.text
|
56
|
-
reply.
|
57
|
-
reply.
|
37
|
+
expect(reply).to include('test started a hangout at')
|
38
|
+
expect(reply).to match(/it was last linked \d seconds? ago/)
|
58
39
|
end
|
59
40
|
|
60
|
-
it '
|
41
|
+
it 'recaptures a link' do
|
61
42
|
id = random_hangout_id
|
62
43
|
msg = make_message(@bot, Hangout.url(id, false), { channel: '#foo' })
|
63
44
|
get_replies(msg)
|
64
|
-
sleep
|
45
|
+
sleep 2 # hack until 'time-lord' fix gets released
|
65
46
|
get_replies(msg)
|
66
|
-
sleep
|
47
|
+
sleep 2 # hack until 'time-lord' fix gets released
|
67
48
|
msg = make_message(@bot, '!hangouts')
|
68
|
-
|
69
|
-
.should == 2
|
49
|
+
expect(get_replies(msg).length).to eq(2)
|
70
50
|
end
|
71
51
|
|
72
|
-
it '
|
73
|
-
msg = make_message(@bot, Hangout.url('7acpjrpcmgl00u0b665mu25b1g', false), { :
|
74
|
-
get_replies(msg).
|
75
|
-
sleep
|
52
|
+
it 'capture a new short Hangout link and store it in @storage' do
|
53
|
+
msg = make_message(@bot, Hangout.url('7acpjrpcmgl00u0b665mu25b1g', false), { channel: '#foo' })
|
54
|
+
expect(get_replies(msg)).to be_empty
|
55
|
+
sleep 2 # hack until 'time-lord' fix gets released
|
76
56
|
msg = make_message(@bot, '!hangouts')
|
77
57
|
reply = get_replies(msg).last.text
|
78
|
-
reply.
|
79
|
-
reply.
|
58
|
+
expect(reply).to include('test started a hangout at')
|
59
|
+
expect(reply).to match(/it was last linked \d seconds? ago/)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe 'posting an invalid hangout link does not log' do
|
64
|
+
it 'when it is malformed (invalid chars)' do
|
65
|
+
msg = make_message(@bot, Hangout.url('82b5cc7f76b7a%19c180416c2f509027!!d8856d',
|
66
|
+
false), { channel: '#foo' })
|
67
|
+
expect(get_replies(msg)).to be_empty
|
68
|
+
msg = make_message(@bot, '!hangouts')
|
69
|
+
message = get_replies(msg).first.text
|
70
|
+
expect(message).to eq('No hangouts have been linked recently!')
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'when it is malformed (wrong length)' do
|
74
|
+
msg = make_message(@bot, Hangout.url('82b5cc', false), { channel: '#foo' })
|
75
|
+
expect(get_replies(msg)).to be_empty
|
76
|
+
msg = make_message(@bot, '!hangouts')
|
77
|
+
expect(get_replies(msg).first.text).to eq('No hangouts have been linked recently!')
|
80
78
|
end
|
81
79
|
end
|
82
80
|
|
83
81
|
describe 'subscriptions' do
|
84
82
|
it 'should allow users to subscribe' do
|
85
|
-
msg = make_message(@bot, '!hangouts subscribe')
|
86
|
-
|
87
|
-
should include("You are now subscribed")
|
83
|
+
msg = get_replies(make_message(@bot, '!hangouts subscribe'))
|
84
|
+
expect(msg.first.text).to include('You are now subscribed')
|
88
85
|
end
|
89
86
|
|
90
87
|
it 'should allow users to subscribe' do
|
91
88
|
get_replies(make_message(@bot, '!hangouts subscribe'))
|
92
|
-
Cinch::Plugins::Hangouts::Subscription.list.length
|
93
|
-
.should == 1
|
89
|
+
expect(Cinch::Plugins::Hangouts::Subscription.list({ subscriptions: @files[:subscription_filename] }).length).to eq(1)
|
94
90
|
end
|
95
91
|
|
96
92
|
it 'should inform users that they already subscribed' do
|
97
93
|
get_replies(make_message(@bot, '!hangouts subscribe'))
|
98
94
|
msg = make_message(@bot, '!hangouts subscribe')
|
99
|
-
get_replies(msg).first.text.
|
100
|
-
should include("You are already subscribed")
|
95
|
+
expect(get_replies(msg).first.text).to include('You are already subscribed')
|
101
96
|
end
|
102
97
|
|
103
98
|
it 'should allow users to unsubscribe' do
|
104
99
|
get_replies(make_message(@bot, '!hangouts subscribe'))
|
105
100
|
get_replies(make_message(@bot, '!hangouts unsubscribe'))
|
106
|
-
Cinch::Plugins::Hangouts::Subscription.list.length
|
107
|
-
.should == 0
|
101
|
+
expect(Cinch::Plugins::Hangouts::Subscription.list({ subscriptions: @files[:subscription_filename] }).length).to eq(0)
|
108
102
|
end
|
109
103
|
|
110
104
|
it 'should inform users that they are not subscribed on an unsubscribe' do
|
111
105
|
msg = make_message(@bot, '!hangouts unsubscribe')
|
112
|
-
get_replies(msg).first.text.
|
113
|
-
should include("You are not subscribed.")
|
106
|
+
expect(get_replies(msg).first.text).to include('You are not subscribed.')
|
114
107
|
end
|
115
108
|
|
116
109
|
#it 'should notify users when a new hangout is linked' do
|
@@ -120,18 +113,19 @@ describe Cinch::Plugins::Hangouts do
|
|
120
113
|
#end
|
121
114
|
|
122
115
|
it 'should not notify users when an old hangout is relinked' do
|
123
|
-
get_replies(make_message(@bot, '!hangouts subscribe'), { :
|
124
|
-
get_replies(make_message(@bot, Hangout.url(random_hangout_id, false), { :
|
125
|
-
msg = make_message(@bot, Hangout.url(random_hangout_id, false), { :
|
126
|
-
get_replies(msg).
|
127
|
-
should be_empty
|
116
|
+
get_replies(make_message(@bot, '!hangouts subscribe'), { channel: '#foo' } )
|
117
|
+
get_replies(make_message(@bot, Hangout.url(random_hangout_id, false), { channel: '#foo' }))
|
118
|
+
msg = make_message(@bot, Hangout.url(random_hangout_id, false), { channel: '#foo' })
|
119
|
+
expect(get_replies(msg)).to be_empty
|
128
120
|
end
|
121
|
+
|
122
|
+
|
129
123
|
end
|
130
124
|
|
131
|
-
def random_hangout_id(len =
|
132
|
-
chars =
|
125
|
+
def random_hangout_id(len = 27)
|
126
|
+
chars = ('a'..'z').to_a + ('0'..'9').to_a
|
133
127
|
string = ''
|
134
|
-
len.times { string << chars[rand(chars.length)] }
|
128
|
+
len.times { string << chars[rand(chars.length)] }
|
135
129
|
string
|
136
130
|
end
|
137
131
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,5 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
4
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
-
SimpleCov::Formatter::HTMLFormatter,
|
6
|
-
Coveralls::SimpleCov::Formatter
|
7
|
-
]
|
8
|
-
SimpleCov.start
|
1
|
+
require "codeclimate-test-reporter"
|
2
|
+
CodeClimate::TestReporter.start
|
9
3
|
|
10
4
|
require 'cinch-hangouts'
|
11
5
|
require 'cinch/test'
|
metadata
CHANGED
@@ -1,142 +1,151 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch-hangouts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Brian Haberer
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-05-03 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
19
|
+
version: '10'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
26
|
+
version: '10'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - "~>"
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
33
|
+
version: '3'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - "~>"
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version: '
|
40
|
+
version: '3'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
42
|
+
name: cinch-test
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.1'
|
48
|
+
- - ">="
|
52
49
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
50
|
+
version: 0.1.1
|
54
51
|
type: :development
|
55
52
|
prerelease: false
|
56
53
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
54
|
requirements:
|
59
|
-
- -
|
55
|
+
- - "~>"
|
60
56
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
57
|
+
version: '0.1'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.1.1
|
62
61
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
62
|
+
name: codeclimate-test-reporter
|
64
63
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
64
|
requirements:
|
67
|
-
- -
|
65
|
+
- - "~>"
|
68
66
|
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
67
|
+
version: '0.4'
|
70
68
|
type: :development
|
71
69
|
prerelease: false
|
72
70
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
71
|
requirements:
|
75
|
-
- -
|
72
|
+
- - "~>"
|
76
73
|
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
74
|
+
version: '0.4'
|
78
75
|
- !ruby/object:Gem::Dependency
|
79
76
|
name: cinch
|
80
77
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
78
|
requirements:
|
83
|
-
- - ~>
|
79
|
+
- - "~>"
|
84
80
|
- !ruby/object:Gem::Version
|
85
|
-
version: 2.0
|
81
|
+
version: '2.0'
|
86
82
|
type: :runtime
|
87
83
|
prerelease: false
|
88
84
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
85
|
requirements:
|
91
|
-
- - ~>
|
86
|
+
- - "~>"
|
92
87
|
- !ruby/object:Gem::Version
|
93
|
-
version: 2.0
|
88
|
+
version: '2.0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: cinch-cooldown
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 1.1.7
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.1.7
|
94
103
|
- !ruby/object:Gem::Dependency
|
95
104
|
name: cinch-storage
|
96
105
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
106
|
requirements:
|
99
|
-
- - ~>
|
107
|
+
- - "~>"
|
100
108
|
- !ruby/object:Gem::Version
|
101
|
-
version: 1.
|
109
|
+
version: '1.2'
|
102
110
|
type: :runtime
|
103
111
|
prerelease: false
|
104
112
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
113
|
requirements:
|
107
|
-
- - ~>
|
114
|
+
- - "~>"
|
108
115
|
- !ruby/object:Gem::Version
|
109
|
-
version: 1.
|
116
|
+
version: '1.2'
|
110
117
|
- !ruby/object:Gem::Dependency
|
111
118
|
name: cinch-toolbox
|
112
119
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
120
|
requirements:
|
115
|
-
- - ~>
|
121
|
+
- - "~>"
|
116
122
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.1
|
123
|
+
version: '1.1'
|
118
124
|
type: :runtime
|
119
125
|
prerelease: false
|
120
126
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
127
|
requirements:
|
123
|
-
- - ~>
|
128
|
+
- - "~>"
|
124
129
|
- !ruby/object:Gem::Version
|
125
|
-
version: 1.1
|
130
|
+
version: '1.1'
|
126
131
|
- !ruby/object:Gem::Dependency
|
127
132
|
name: time-lord
|
128
133
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
134
|
requirements:
|
131
|
-
- - ~>
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '1.0'
|
138
|
+
- - ">="
|
132
139
|
- !ruby/object:Gem::Version
|
133
140
|
version: 1.0.1
|
134
141
|
type: :runtime
|
135
142
|
prerelease: false
|
136
143
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
144
|
requirements:
|
139
|
-
- - ~>
|
145
|
+
- - "~>"
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '1.0'
|
148
|
+
- - ">="
|
140
149
|
- !ruby/object:Gem::Version
|
141
150
|
version: 1.0.1
|
142
151
|
description: Cinch Plugin to track any Google Hangouts that are linked into the channel
|
@@ -146,8 +155,8 @@ executables: []
|
|
146
155
|
extensions: []
|
147
156
|
extra_rdoc_files: []
|
148
157
|
files:
|
149
|
-
- .gitignore
|
150
|
-
- .travis.yml
|
158
|
+
- ".gitignore"
|
159
|
+
- ".travis.yml"
|
151
160
|
- Gemfile
|
152
161
|
- LICENSE.txt
|
153
162
|
- README.md
|
@@ -163,29 +172,27 @@ files:
|
|
163
172
|
homepage: https://github.com/bhaberer/cinch-hangouts
|
164
173
|
licenses:
|
165
174
|
- MIT
|
175
|
+
metadata: {}
|
166
176
|
post_install_message:
|
167
177
|
rdoc_options: []
|
168
178
|
require_paths:
|
169
179
|
- lib
|
170
180
|
required_ruby_version: !ruby/object:Gem::Requirement
|
171
|
-
none: false
|
172
181
|
requirements:
|
173
|
-
- -
|
182
|
+
- - ">="
|
174
183
|
- !ruby/object:Gem::Version
|
175
184
|
version: '0'
|
176
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
|
-
none: false
|
178
186
|
requirements:
|
179
|
-
- -
|
187
|
+
- - ">="
|
180
188
|
- !ruby/object:Gem::Version
|
181
189
|
version: '0'
|
182
190
|
requirements: []
|
183
191
|
rubyforge_project:
|
184
|
-
rubygems_version:
|
192
|
+
rubygems_version: 2.4.8
|
185
193
|
signing_key:
|
186
|
-
specification_version:
|
194
|
+
specification_version: 4
|
187
195
|
summary: Cinch Plugin for racking Google Hangouts
|
188
196
|
test_files:
|
189
197
|
- spec/cinch-hangouts_spec.rb
|
190
198
|
- spec/spec_helper.rb
|
191
|
-
has_rdoc:
|